-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Same old question (composite-d)
PostPosted: Fri Dec 17, 2004 7:34 pm 
Newbie

Joined: Thu Nov 18, 2004 12:32 pm
Posts: 8
Location: UK (Newcastle upon Tyne)
Hibernate version: JBoss4.0.1, Hibernate2.1

I know this has been gone through endlessly and I have been through all the post following the search on all forums.

I have got my composite-id working (and tested etc).

My problem is I cannot get the XDoclet to produce the correct hbm file for this composite-id (I have been to CodeHaus and seen XDoclet2 etc etc too).

At the moment I have repaired the hbm generated by XDoclet and overwrite the autogenerated one with my hand coded one (in my Ant scripts).

I cannot see a workaround to this (it seems the solutions are in the pipeline but not quite there yet).

To complete the story:

My composite table is Person_Organisation_List (person_id and org_id being primary keys with an extra (non-primary) attribute called designation, and no I cannot alter the schema).

Code:
public class PersonOrganisationList
{
   private String         designation   = null;
   private PersonOrgListPK   primaryKey   = null;

   /**
    *
    * @hibernate.property column="designation" type="string" length="40"
    *                     not-null="false"
    */
   public String getDesignation()

...
   /**
    *
    * @hibernate.id
    *
    */
   public PersonOrgListPK getPrimaryKey()
...


Code:
public class PersonOrgListPK implements Serializable
{
   public Long   person_id   = new Long(0);
   public Long   org_id      = new Long(0);

   public PersonOrgListPK()
   {
   }

   public PersonOrgListPK(Long person_id, Long org_id)
   {
      this.person_id = person_id;
      this.org_id = org_id;
   }

   public Long getOrg_id()
...

   public Long getPerson_id()
...




The hand repaired PersonOrganisationList.hbm.xml looks like:

Code:
        <composite-id
            name="primaryKey"
            class="PersonOrgListPK"
        >
      <key-property name="org_id" type="long"/>
      <key-property name="person_id" type="long"/>
        </composite-id>



No matter what I do, at the moment XDoclet (v1.2.2) only produces

Code:
        <composite-id
            name="primaryKey"
            class="PersonOrgListPK"
        />



Cheers
-raj

_________________
- cowboy maybe, but an injun at heart


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 18, 2004 6:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Your almost there:

You need to add the @hibernate.property tag(s) to the Key properties itself.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 18, 2004 7:23 pm 
Newbie

Joined: Thu Nov 18, 2004 12:32 pm
Posts: 8
Location: UK (Newcastle upon Tyne)
Much obliged squire, that did do the trick.

And for posterity's sake,

All I had to do was to add the property tags to my PrimaryKey class

Code:
public class PersonOrgListPK implements Serializable
{
   public Long   person_id   = new Long(0);
   public Long   org_id      = new Long(0);

   public PersonOrgListPK()
   {
   }

   public PersonOrgListPK(Long person_id, Long org_id)
   {
      this.person_id = person_id;
      this.org_id = org_id;
   }

   /**
    * @hibernate.property name="org_id" type="long" 
    */
   public Long getOrg_id()
...

   /**
    * @hibernate.property name="person_id" type="long" 
    */
   public Long getPerson_id()
...


Cheers
-raj

_________________
- cowboy maybe, but an injun at heart


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.