Generating hibernate xml file thru XDoclet for composite-id


General J2EE: Generating hibernate xml file thru XDoclet for composite-id

  1. Hi All,

    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

    RoleId RoleDesc
    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


    Threaded Messages (2)

  2. Hibernate Composite-id Not Supported[ Go to top ]

    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 ( ), 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,

  3. Use static inner class[ Go to top ]

    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.