Mar 16th, 2011, 01:26 AM
ROO + composite primary keys in data on demand
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??
Mar 16th, 2011, 03:32 AM
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 ...
Mar 16th, 2011, 04:29 PM
I am looking at ROO-2070 at the moment.
Mar 18th, 2011, 10:56 AM
Hi cblicious ,
I confused what u explained above......can you pls explain once again.....
pls its urgent........
Mar 18th, 2011, 08:51 PM
What confuses you ? Please explain !
Mar 19th, 2011, 04:23 AM
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
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????????
Mar 19th, 2011, 05:45 AM
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 :
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
Mar 19th, 2011, 07:13 AM
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???
Mar 19th, 2011, 07:19 AM
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.
Mar 20th, 2011, 05:58 AM
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??