-->
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.  [ 9 posts ] 
Author Message
 Post subject: Injecting named queries in reverse engineering->DAO proce
PostPosted: Tue Jan 10, 2006 8:44 pm 
Beginner
Beginner

Joined: Wed Nov 02, 2005 3:29 pm
Posts: 20
Using the eclipse plugins (beta 3) how can I inject named queries
in the reverse engineering to DAO process?

At the moment, the only way I seem to be able to do it is by

1) generate the hbm.xml files from the JDBC connection.
2) Edit the hbm.xml files and add the named queries
3) launch the Code Generator again and have it just generate the
DAO java files.

But if I want to add another table to the setup, or take advantage
of some new feature that causes the hbm.files to be re-generated,
I'll loose named queries.

So I would like to store the named queries somewhere else and
have the generation process pick them up at the right point.

George


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 6:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
put them in a different hbm.xml file and let the name starts with the entity name.

e.g.

<query name="org.hibernate.test.YourBean.someQueryName">
...

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 7:48 pm 
Beginner
Beginner

Joined: Wed Nov 02, 2005 3:29 pm
Posts: 20
Perfect.

Anything similar for java code that I would like have added to the
entity class *since <meta "class-code" would have the same problem
of being wiped out during a generation run)?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 2:26 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
not at the moment....it *might* make sense to add that support to reveng.xml but i just feel it might be pretty much overkill....there are more important things to put in the mappings (such as proper cascading) than this.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 5:27 am 
Beginner
Beginner

Joined: Wed Nov 02, 2005 3:29 pm
Posts: 20
max wrote:
not at the moment....it *might* make sense to add that support to reveng.xml but i just feel it might be pretty much overkill....there are more important things to put in the mappings (such as proper cascading) than this.


What is "proper cascading"?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 5:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
currently no cascading is define on all associations - that is most likely not what you want to run with in a real application.

If you don't know what cascading is at all then i suggest you go read the tutorial and ref documentation.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 13, 2006 6:55 pm 
Beginner
Beginner

Joined: Wed Nov 02, 2005 3:29 pm
Posts: 20
max wrote:
put them in a different hbm.xml file and let the name starts with the entity name.


gnl wrote:
Perfect.


Oops, not quite perfect :-(

The x.NamedQueries.hbm.xml file is only
picked up if the java source is generated from the hbm.xml
file. I.e. If I do complete run starting with the JDBC connection, no
named queries :-(

So if there are any changes to the database schema I will have
to do one run to generate the hbm.xml file, and then a second, non-JDBC, run to pick up the auxiliary file to produce the
final java source

George


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 13, 2006 7:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Huh ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 13, 2006 7:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
why are you generating hbm.xml AND java code just from the jdbc reveng ?

you should do:

1. reveng of hbm.xml's via rev.eng.

2. generate pojos from hibernate.cfg.xml with all your mapping files - including the x.NamedQueries.hbm.xml's

_________________
Max
Don't forget to rate


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