Results 1 to 10 of 10

Thread: Spring Roo DBRE and MS SQL Server 2008 with composite primary keys

  1. #1

    Default Spring Roo DBRE and MS SQL Server 2008 with composite primary keys

    If I am trying to generate a object with a composite key where different fields of the key are from the Type "char(2)"

    Spring Roo doesn't generate the " ,columnDefinition = "char", length = 2 " annotation, but only for the Fields which are in the primary composite key. Then this leads to an error during application startup, saying "Expected varchar(255) , but char(2) found"

    All other normal fields get annotated correctly ... what could that be ?

    Best regards

  2. #2
    Join Date
    Dec 2005
    Posts
    935

    Default

    Was a composite key class, eg FooPK, generated?
    Alan Stewart
    Spring Roo Committer
    twitter @alankstewart

  3. #3

    Default

    yes ... and all the fields in this class were not generated correctly ...

  4. #4
    Join Date
    Dec 2005
    Posts
    935

    Default

    I am not currently adding columnDefinition to fields in the PK class. Please raise a Jira request for this. It won't take long to do
    Alan Stewart
    Spring Roo Committer
    twitter @alankstewart

  5. #5
    Join Date
    Dec 2005
    Posts
    935

    Default

    https://jira.springsource.org/browse/ROO-2186 raised and completed.
    Regards
    Alan
    Alan Stewart
    Spring Roo Committer
    twitter @alankstewart

  6. #6

    Cool

    coool thanks !

    I have found another issue !

    The HQL in the "public static long count<<Objectname>>() {..." Method doesn't seem to fit ....

    If you have a composite Primary Key it says ... "select count(o) from IscsProduct o" which gets transformed into something like "select count((pkrow1,pkrow2,pkrow3,pkrow4)) from table" and there I get the SQL error "count takes just one parameter" So I replaced it with count(*) and it works ....

  7. #7
    Join Date
    Dec 2005
    Posts
    935

    Default

    Roo's support for composite primary keys is minimal at the moment. Can you try different ORMs, like OpenJPA or EclipseLink (if not already)?

    Raise an issue - I should be able to fix this quickly
    Alan Stewart
    Spring Roo Committer
    twitter @alankstewart

  8. #8

    Default

    how do i raise an issue ?

  9. #9
    Join Date
    Dec 2005
    Posts
    935

    Default

    Alan Stewart
    Spring Roo Committer
    twitter @alankstewart

  10. #10

    Default

    I am developing a method to that Spring Roo (or at last, what it has generated) can work nicely with composite PKs

    Currenlty I am using a toString mehtod for the PK and a decoder (eg. spilt) so that working with PKs trough the {id} Field works ...

    maybe interested in integrating this approach when it works ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •