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?
|