Announcement Announcement Module
Collapse
No announcement yet.
ROO + composite primary keys in data on demand Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ROO + composite primary keys in data on demand

    Hi,

    with roo, i generated mvc application from database schema. when i try to click on "List all Adf Controllers" in the UI screen. it is displying error message "ERROR org.hibernate.util.JDBCExceptionReporter - ORA-00907: missing right parenthesis".
    I think the issue is with composite primary keys.

    Is roo still nor supporting composite primary keys(https://jira.springsource.org/browse/ROO-2214) ?

    Anyone pls help me in this??

    Thanks,
    Pavan

  • #2
    Hi

    Currently I am working with Spring Roo + composite PKs and I realised there are lots of bugs and problems you have to solve.

    Even if generation finishes successfull you won't be able to show/edit etc Objects with composite PKs because the Composite PKs won't be saved on the Edit/Show Pages correctly. The toString() Method of the Composite PK gets called to fill up the hidden id field during Update etc so you have to implement a toString method that generates a primary Key for the ID Field and for the way back (id field => Primary Key) ...

    I solved it the following way : I pushed in the classes working with combined primary keys and gave all the PK's a toString() Method and the Controllers a StringToPK(String) method. I don't think thats the best way to achive it but it worked and the rest of the application is still manged by Roo ...

    Comment


    • #3
      I am looking at ROO-2070 at the moment.

      Comment


      • #4
        Hi cblicious ,

        I confused what u explained above......can you pls explain once again.....

        pls its urgent........

        Thanks,
        Pavan

        Comment


        • #5
          What confuses you ? Please explain !

          Comment


          • #6
            Hi,

            I'm using roo1.1.2. My roo application successfully running. But when i click on list link on some table in UI, Missing paranthesis exception is coming.

            I found for some of the "_Roo_Entity.aj" files has primarykey class. see below

            @EmbeddedId
            private EmfPageCriteriaFilterPK EmfPageCriteriaFilter.id;

            I think the issue with the PK class. Is there anyway to avoid creating PK classes.

            How to resolve this issue????????

            Thanks,
            Pavan

            Comment


            • #7
              I think you can't avoid PK Classes as long as your Databasedesign uses composite primary keys ...

              But the solution is quite simple ... If you add a toString() Method in the primary key (first Refactor -> push in so that the aspect's are gone) and in the next step you have to modify the show ... etc methods in the controllers.

              The toString method could generate someting like this :
              <keyvalue1>,<keyvalue2>,<keyvalue3> ...

              Following the sample of the "show" method
              Now the id in the URL contains your primary key. Now in order to use the default finder you will need a method which converts your ID String back to a primary key object. A normal Strinng.split() will do the the trick

              Comment


              • #8
                Hi,

                In My schema no table has composite primary key. even though it is creating PK classes for the tables.

                It is generating PK classes for those tables doesn't have primark key.

                Any Idea how to resolve thi issue???

                Thanks,
                Pavan

                Comment


                • #9
                  If your table does not have a primary key defined, then DBRE, by design, will create a composite key consisting of all the columns in the table, as JPA requires a key. Create a primary key from one field and DBRE will remove the composite key on next introspection.

                  Alan

                  Comment


                  • #10
                    Hi,

                    Thanks for ur reply.....

                    For some of the tables, when i click on list in roo UI, its throwing "ORA-01747: invalid user.table.column, table.column, or column specification" exception.

                    Is this exception also because of composite primary key or something else??

                    Thanks,
                    Pavan

                    Comment


                    • #11
                      Is this exception also because of composite primary key or something else??
                      Most likely. You will have to make your own DoD class for primary key testing until we have added the feature

                      Comment


                      • #12
                        Hi,

                        Thanks cblicious and Alan for ur reply .....

                        For some of the tables, when i click on list in roo UI, its throwing "ORA-01747: invalid user.table.column, table.column, or column specification" exception.

                        Is this exception also because of composite primary key or something else??

                        Thanks,
                        Pavan

                        Comment


                        • #13
                          Hi,

                          Thanks for ur reply alan/cblicious.

                          Please reply to my post....

                          Thanks,
                          Pavan

                          Comment


                          • #14
                            Originally posted by Alan Stewart View Post
                            Most likely. You will have to make your own DoD class for primary key testing until we have added the feature

                            Hi Alan,

                            DoD class means????

                            Instead of roo generating primary key class, do i need to write separate one???

                            Comment


                            • #15
                              Hi cblicious,

                              I followed ur steps....
                              First I refactor the aspectj files....
                              Added tostring() in PK class.

                              public String toString() {
                              StringBuilder sb = new StringBuilder();
                              sb.append("DoaId: ").append(getDoaId()).append(", ");
                              sb.append("MasterField: ").append(getMasterField()).append(", ");
                              sb.append("CreatedOn: ").append(getCreatedOn()).append(", ");
                              sb.append("CreatedBy: ").append(getCreatedBy()).append(", ");
                              sb.append("ModifiedOn: ").append(getModifiedOn()).append(", ");
                              sb.append("ModifiedBy: ").append(getModifiedBy()).append(", ");
                              sb.append("Status: ").append(getStatus());
                              return sb.toString();
                              }

                              After this i ran the roo applicaton...when i click on "List" link still i am getting "missing paranthesis error"...

                              Comment

                              Working...
                              X