-->
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.  [ 13 posts ] 
Author Message
 Post subject: Generating composite-element with Xdoclet
PostPosted: Thu Aug 28, 2003 4:16 am 
Newbie

Joined: Wed Aug 27, 2003 3:09 am
Posts: 17
I am not sure whether my question is offtopic, it is about "how to generate the <property> inside <composite-element> with xDoclet" ?
Example:
Code:
<set role="relationship">
    <key column="fk_of_foo"/>
    <composite-element class="Relationship">
        <property name="multiplicity" type="short"/>
        <property name="created" type="date"/>
        <many-to-one name="bar" class="Bar"/>
    </composite-element>
</set>



I want to generate <property> and <many-to-one> using xDocle,

For now, i use something like this:
Code:
/**
    * @hibernate.set  inverse="false"
    * table="policy"
    *  lazy="false"
    * cascade="save-update"
    *
    * @hibernate.collection-key  column="roleId"
    * @hibernate.composite-element  class="Policy"
    *
    */

After that, i manually add back <property> and <many-to-one> to the .hbm.xml.

It seems that xDoclet does not support nested <property>.

Any hints are great~!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2003 5:27 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Hmmm. I'm not 100% sure. I would have _expected_ it to work if you have @hibernate.property tags on the composite element class.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2003 6:08 am 
Newbie

Joined: Wed Aug 27, 2003 3:09 am
Posts: 17
Oh, i have tried that, not successful. It will generate the unwanted .hbm.xml

I do think all the tags should be placed in the parent class, just below the
Code:
@hibernate.composite-element  class="Policy"


So maybe xDoclet does not support it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2003 6:14 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
no, no. it won't generate an unwanted mapping unless you also specify an @hibernate.class!

And nah, I don't think the tags should go in the parent class. They should go on the composite element class.

We might just be missing a line from the XDoclet tempate or something. Or perhaps you are still doing something wrong.


(I don't have an xdoclet checkout on my new laptop yet.)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2003 6:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Note, this should all work the same for composite-elements as it does for components (which DOES work, I know for sure).


Top
 Profile  
 
 Post subject: Re: Generating composite-element with Xdoclet
PostPosted: Thu Aug 28, 2003 9:08 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 8:55 am
Posts: 28
Location: Dallas, TX
Try adding a column attribute to the composite-element tag:

Code:
/**
  * @hibernate.set  inverse="false"
  * table="policy"
  * lazy="false"
  * cascade="save-update"
  *
  * @hibernate.collection-key  column="roleId"
  * @hibernate.composite-element  class="Policy"
  * column="fk_of_bar "
  *
  */


I think you will need this so Hibernate will know what column ties a Foo to a Bar in the M-N relationship.

Good luck.

Ryan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2003 9:09 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 8:55 am
Posts: 28
Location: Dallas, TX
Oops. By code was from the Hibernate generic example, but I think you get my point.


Top
 Profile  
 
 Post subject: XDoclet documentation error
PostPosted: Thu Aug 28, 2003 9:18 am 
Newbie

Joined: Wed Aug 27, 2003 2:17 am
Posts: 1
Location: Stockholm, Sweden
The documentation is wrong.

The tag should be @hibernate.collection-composite-element.

HTH

Olle


Top
 Profile  
 
 Post subject: Re: XDoclet documentation error
PostPosted: Thu Aug 28, 2003 9:54 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 8:55 am
Posts: 28
Location: Dallas, TX
olle wrote:
The documentation is wrong.

The tag should be @hibernate.collection-composite-element.

HTH

Olle


Ah yes. I forgot about this. This is a bug in the lasest beta of XDoclet 1.2. Here is some more details on this:

http://opensource.atlassian.com/projects/xdoclet/secure/ViewIssue.jspa?key=XDT-560

Ryan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2003 10:28 am 
Newbie

Joined: Wed Aug 27, 2003 3:09 am
Posts: 17
Finally worked..

What Gavin suggested is absolutely correct.
Specify something like
Code:
/**
     *  @hibernate.many-to-one
     *  cascade="save-update"
     */

for the extra foreign keys in the composite-element class..

Or specify something like
Code:
/**
     * @hibernate.property
     */
for the extra property in the composite-element class.

Do not add stupid things like @hibernate.class or @hibernate.id, everything will work.

Also, remember to provide getters for all the FK and Properties!


Top
 Profile  
 
 Post subject: Composite and Xdoclet - having exact same problem
PostPosted: Thu Nov 06, 2003 10:42 pm 
Newbie

Joined: Thu Nov 06, 2003 10:39 pm
Posts: 1
Geek,

Could you post a full example that shows how you got this to work? I'm having the exact same problem and I can't figure it out. I've tried doing everything suggested above but I'm probably missing something stupid.

Thanks,

Mads


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 07, 2003 4:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I think it would be good to have a contrib page showing the various ways to map XDoclet tags including some of the more advanced features.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 07, 2003 4:49 am 
Newbie

Joined: Wed Oct 22, 2003 2:29 pm
Posts: 1
Location: China
I am also coming across such a problem. I do eager the contrib page can be built as soon as possible!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 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.