-->
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.  [ 7 posts ] 
Author Message
 Post subject: How to generate <import/> from xdoclet ....
PostPosted: Thu Feb 26, 2004 10:14 pm 
Newbie

Joined: Thu Feb 26, 2004 10:05 pm
Posts: 15
Hi all,

I am new to hibernate and wanted to use XDoclet to generate the mapping xml finle. I was playing around with the Hibernate2.1 download. I wanted to generate the exact xml mapping for the sample app, 'eg' and ran into problem of not knowing how to set the hibernate.query.imports property from xdoclet tag, i.e. I want to tag the AuctionItem.java class so that it know how to generate the <import/> in the AuctionItem.hbm.xml file.

Thanks for any help,

--danny


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2004 10:57 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
First, what is it you are wanting to import? The AuctionItem class? That happens by default without having to specify anything at all.

If something else, I'm pretty sure there is not a tag for generating an import statement. I think you'd have to use a merge file.


Top
 Profile  
 
 Post subject: dependent object AuctionInfo is...
PostPosted: Fri Feb 27, 2004 1:09 pm 
Newbie

Joined: Thu Feb 26, 2004 10:05 pm
Posts: 15
the AuctionItem's dependent object AuctionInfo is being use by one of the HQL query statement. And this is why, at runtime, hibernate need to see this class for the return values of the executed query. Here is the snipet of the codes in the example 'eg' that comes with the Hibernate distribution.

List auctions = s.createQuery(
"select new AuctionInfo( item.id, item.description, item.ends, max(bid.amount) ) "
+ "from AuctionItem item "
+ "left join item.bids bid "
+ "group by item.id, item.description, item.ends "
+ "order by item.ends desc"
)
.setMaxResults(100)
.list();
the xml:

<hibernate-mapping
package="org.hibernate.auction">

<import class="AuctionInfo"/>

<class name="AuctionItem">
<id name="id">
<generator class="native"/>
</id>
<property name="description"/>
<property name="ends"/>
<property name="condition"/>
<many-to-one name="seller" not-null="true"/>
<many-to-one name="successfulBid" outer-join="false"/>
<bag name="bids" lazy="true" inverse="true" cascade="all">
<key column="item"/>
<one-to-many class="Bid"/>
</bag>
</class>

</hibernate-mapping>

and I need to generate this exact mapping using xdoclet extenstion for hibernate.

Thanks,

--danny


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 27, 2004 3:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Just add a separate mapping document with only that <import> in it


Top
 Profile  
 
 Post subject: But how would you control this from XDoclet ?
PostPosted: Fri Feb 27, 2004 6:24 pm 
Newbie

Joined: Thu Feb 26, 2004 10:05 pm
Posts: 15
Gavin,

Thanks for you response, but how can you control this from xdoclet? Because AuctionInfo is a dependent object of AuctionItem. Even though there isn't any component mappin for AuctionInfo inside the AuctionItem mapping xml, but the HQL statem on AuctionItem's db tables return a collection of AuctionInfo, and for that the current session need know how to load the AuctionInfo.class to construct the return collection.

Thanks,

--danny


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 27, 2004 8:33 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
WHy would you need to generate it from XDoclet?? Just write it! :)


Top
 Profile  
 
 Post subject: To Start from Xdoclet and not to write xml mapping by hand..
PostPosted: Fri Feb 27, 2004 9:14 pm 
Newbie

Joined: Thu Feb 26, 2004 10:05 pm
Posts: 15
Gavin,

I've used n2n ORM tool about 3-4 yrs ago while working @ebuilt, where we build our own product calle Codigo, and the tool wasn't that flexible. And the thing that catch my attention on Hibernate was its flexibilities in going any directions for mapping. At my current company where I am doing re-engineer of a existing product, I choose XDoclet to start from the DO layer and generate the Mapping files. Mapping metadata provides good documentation of how an instance of a class related to other classes. And since HQL statement may associate with other java class that is not mapped to the database table( which mean there isn't a mapping xml file for it), and I need to tag these java class so that hibernate knows to imports these java class when it try to execute the HQL statement. If you know that xdoclet is not supporting this, then do you know of a way to get around it?

Thanks,

--danny


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