General J2EE: Generating hibernate xml file thru XDoclet for composite-id
- Posted by: Ajay G
- Posted on: December 20 2004 07:19 EST
I am trying to generate xxx.hbm.xml mapping file thru XDOCLET for composite-id type. I have got three table in my DB schema (Roles, User_Head & User_Det).
RoleId Varchar2(3) Primary Key
RoleDesc Varchar2(20) Not Null
UserId Varchar2(6) Primary Key
UserName Varchar2(20) Not Null
UserId Varchar2(6) Not Null References User_Head(UserId)
RoleId Varchar2(3) Not Null References Roles(RoleId)
Constraint userdet_pk Primary Key (UserId,RoleId)
For the Roles tables I have values already inserted in that
ROA Role A
ROB Role B
Now I want to create a composite-id for User_Det table I am unable to do it. What I have done is I have created a two Java Bean Class for User_Head table & User_Det table. But I am unable to create composite-id key thru XDOCLET.
Can anybody know how to workout for this.
Thanks in advance
XDoclet does not currently support composite id's.
XDoclet 2 was started to expand upon issues like this. However, after an announcement a while back ( http://www.theserverside.com/news/thread.tss?thread_id=21157 ), the project is still in development.
You could always add a custom parser to your ANT build to do this for you. Here's an example, http://www.jroller.com/comments/rkischuk/Weblog/hibernate_composite_id_generation_with
But a better work around for this is to use a static inner class for your primary key. This will also prevent you from having to create an additional key class.