Title: RE: [Xdoclet-user] Xdoclet 1.2b3 will not merge hibernate composite key

Ok.. problem fixed.  Once i started to think about the problem the way hibernate intends composite keys to be used, things just fell into place.  Before I was trying to use the same object to represent the key AND the Domain concept.  Separating them fixed all issues, so the problem was not in Xdoclet but in the way my classes were laid out. 

And Konstantin, Thanks for helping me out.

eric.


> -----Original Message-----
> From: Konstantin Priblouda [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 05, 2003 5:12 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [Xdoclet-user] Xdoclet 1.2b3 will not merge hibernate
> compos ite key
>
>
>
> --- Eric Mckenna <[EMAIL PROTECTED]> wrote:
> > I am trying to get this:
> > <hibernate-mapping>
> >     <class name="model.trial.ECPromoECItemRelation"
> > table="ECPromoECItem">
> >         <composite-id name="relation"
> > class="model.trial.ECPromoECItemRelation">
> >             <key-property name="promoId" type="int"
> > column="promoId"/>
> >               <key-property name="itemId" type="int"
> > column="itemId"/>
> >         </composite-id>
> >     </class>
> > </hibernate-mapping>
> >
> > But keep getting this: (generated from class below)
> >
> > <hibernate-mapping>
> >     <class name="model.trial.ECPromoECItemRelation"
> > table="ECPromoECItem">
> >         <composite-id name="relation"
> > class="model.trial.ECPromoECItemRelation">
> >             <key-property name="promoId" type="int"
> > column="promoId"/>
> >               <key-property name="itemId" type="int"
> > column="itemId"/>
> >         </composite-id>
> >
> >         <property name="promoId" type="int"
> > column="promoId"/>
> >         <property name="itemId" type="int"
> > column="itemId"/>
> >     </class>
> > </hibernate-mapping>
>
> Well, you defined hibernate properties in your
> main class, and you got them generated. XDoclet did
> what you asked for :)
>
>
> > Xdoclet is only doing what I tell it to do, so the
> > way I have my composite
> > class set up is probably the problem.  Just
> > frustrating since all i had to
> > do before (xdoclet beta2) was merge in the composite
> > id element ;)
>
> Well I recall that there was merge point for composite
> key. BUt not it' supported by xdoclet .)
>
>
> > here's the class for reference
> > /**
> >  * @hibernate.class
> >  *      table="ECPromoECItem"
> >  */
> > public class ECPromoECItemRelation implements
> > Serializable {
> >
> >     private int promoId   = -1;
> >     private int itemId    = -1;
> >     public ECPromoECItemRelation() {}
>
>
> Well, you should provide default constructor without
> parameters. And beany getter/setter - hibernate will
> use them to init your class off database. If you need
> further initialization consider implementing
> lifecycle.
>
>
> >     /**
> >      * Constructs the Releation with the promoId and
> > itemId.
> >      * @param promoId
> >      * @param itemId
> >      */
> >     public ECPromoECItemRelation(long promoId, long
> > itemId)
> >     {
> >         String promoIdStr = String.valueOf(promoId);
> >         setPromoId(Integer.parseInt(promoIdStr));
> >
> >         String itemIdStr = String.valueOf(itemId);
> >         setItemId(Integer.parseInt(itemIdStr));
> >     }
> >
> >     /**
> >      * This is a work around to enable xdoclet to
> > correctly generate the
> > hibernate
> >      * xml mapping file.
> >      * @hibernate.id
> >      *      generator-class="assigned"
> >      * @return this object
> >      */
> >     private ECPromoECItemRelation getRelation(int
> > promoId, int itemId) {
> >         return new ECPromoECItemRelation(promoId,
> > itemId);
> >     }
>
> This is kind of wrong. This getter shall be without
> any parameters. Just  getter / setter for  your
> composite ID class. Hibernate will not use this
> method.
> ( I hope :) )
>
>
> >     private void setRelation(ECPromoECItemRelation
> > relation)
> >     {}
>
>   id value shall be stored somewhere...
>
>
>
> Well, now to your PK class. It shall be:
>  - javabean with default constructor
>  - getter / setter pairs for identity properties
>  - it shall have @hibernate.property tags on those
> properties.
>
>
> regards,
>
> =====
> ----[ Konstantin Pribluda ( ko5tik ) ]----------------
> Zu Verstärkung meines Teams suche ich ab Sofort einen
> Softwareentwickler[In] für die Festanstellung.
> Arbeitsort: Mainz
> Skills:  Programieren, Kentnisse in OpenSource-Bereich
> ----[ http://www.pribluda.de ]------------------------
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> xdoclet-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/xdoclet-user
>

Reply via email to