-->
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.  [ 2 posts ] 
Author Message
 Post subject: Location of NamedNativeQuery annotation in Entity class file
PostPosted: Thu Aug 24, 2017 11:51 am 
Newbie

Joined: Thu Aug 24, 2017 11:37 am
Posts: 1
I asked about this on StackOverflow a couple of days ago, but haven't gotten any bites. I converted a project at work from mapping through XML files, to using annotations directly in the classes that represent the database tables. Everything has gone well (I just need to do extensive testing to make sure things are stilling getting in and out of the database properly) but there's one cosmetic thing that's nagging me.

It seems that my NamedNativeQuery annotations can only be at the top of the class file? Or maybe it's specifically before the @Entity annotation? They currently sit after the imports, and before the class declaration (which has @Entity and @Table right above it). Generally this is ok since for most classes this only takes up a dozen lines or so, but I have one class that has several hundred lines of this. It looks really terrible having it all there at the top of the file taking up 400 lines before the class even starts. I wanted to move them to the bottom of the file, but then Java gives me some error about reaching the end of file. What is going on here? I'm guessing since it's at annotation, my current placement of them is actually where they SHOULD be, basically annotating the class itself? Is there a solution to this other than the one I saw about putting them in their own file?


Top
 Profile  
 
 Post subject: Re: Location of NamedNativeQuery annotation in Entity class file
PostPosted: Thu Aug 24, 2017 12:34 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Don't migrate native queries to annotations. You should keep them in the XML files, it's way better. You can use HBM mappings files or JPA XML files for storing the SQL queries.


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