0

In Java, are @NamedQueries that are changed available right away, or is there a caching issue in Hibernate?

@NamedQueries( {
    @NamedQuery(name = etc..

I made changes to 2 @NamedQuery but they are not doing what they should.

Does Hibernate need to be restarted?

Cache cleared somewhere?

Just takes time and they will show up?

What exactly is the procedure when changing @NamedQueries?

Thank you so much!

Ben
  • 4,980
  • 3
  • 43
  • 84
JoJo
  • 4,643
  • 9
  • 42
  • 65
  • They are parsed at deploy/sessionfactorycreation time and cached. Don't really understand, are you using jRebel or something? – Affe Jul 10 '12 at 21:13
  • So if I am restarting the server then that should re-query Hibernate I guess.... Jboss/Seam/JSF/Facelets/Hibernate oh and RichFaces! – JoJo Jul 10 '12 at 23:36

1 Answers1

3

You can't change a named query. They're part of the source code of the class. If you change them in your source file, you need to recompile the source file and restart the application.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • Thanks. I *am* restarting the application which made me wonder why my changes were not being reflected in the web page. When I take the HQL from the NamedQuery and transpose it into MySql I get the correct results... so I am not sure what is missing still. I will try and read up on Hibernate. – JoJo Jul 10 '12 at 23:38