-->
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.  [ 5 posts ] 
Author Message
 Post subject: @NativeQuery overwritten on ReverseEngineer
PostPosted: Mon Jun 12, 2006 6:14 pm 
Newbie

Joined: Mon Jun 12, 2006 4:59 pm
Posts: 13
Hibernate version: 3.2

Mapping documents: N/A

Code between sessionFactory.openSession() and session.close(): N/A

Full stack trace of any exception that occurs: N/A

Name and version of the database you are using: N/A

The generated SQL (show_sql=true): N/A

Debug level Hibernate log excerpt: N/A

This must be a configuration issue or simply something that is not yet supported.

I'm using the Reverse Engineering abilities of Tools to create EJB3 based POJOs.

I also wish to define @NamedQuerys within the POJOs, however, when I rerun the Reverse Engineering, the Query definitions get deleted.

Are there suggestions on how to work around that?

My thoughts were to include them all at the package level somewhere, but there isn't any way that I've found to specify a different file for the AnnotationConfiguration to find the @NamedQuery definitions alternatly than from having them within the mapped POJOs.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 12, 2006 7:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
currently we generate a complete file and overwrite whatever is output directory.

To do what you want we would need to use something like jmerge which unforunately does not support jdk5/annotations syntax yet ;(
Then we could support merge of generated and hand written java files.

But that is still and outstanding issue.

a workaround is to put your named queries in a orm.xml if you are using ejb3 or add a hbm.xml file with the queries if you "just" uses the hibernate3 api.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 13, 2006 10:50 am 
Newbie

Joined: Mon Jun 12, 2006 4:59 pm
Posts: 13
I appreciate your reply.

I'm interested in the xml files that you mentioned.

Yes, I'm using ejb3 (you can tell by the annotations.)

This is also a stand-alone application (at least initially) so there is really no place for a META-INF/orm.xml file.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 13, 2006 11:00 am 
Newbie

Joined: Mon Jun 12, 2006 4:59 pm
Posts: 13
Never mind. Thank you for your help. I got it working just fine.

In my orm.xml I place the named query.

Code:
<named-query name="Link.findAll">
   <query>select l from Link l</query>
</named-query>


Then I load the orm.xml file as a resource

Code:
AnnotationConfiguration ac = new AnnotationConfiguration();
   ac.configure();
   ac.addResource( "org/test/orm.xml");


This works great! Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 13, 2006 3:15 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i don't understand why META-INF/orm.xml isn't possible to use for you?

_________________
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.  [ 5 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.