Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to avoid entity binding in application startup

 
Oscar Calderon
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all, since some months ago, i've started to develop simple applications using Hibernate. In this time i see something that i don't like, and is the fact that when you run the web application (i use netbeans), when internally entitymanager is initialized, it starts to do something like binding entities or checking if the named queries in entities are correct, and i see that because in Output window of netbeans prints something like this:



My question is, if is possible to tell hibernate not to do that, because for example, in my applications this happens when the user logins in the app so in the first login user feels that application is slow, and i don't like that.

Thanks in advance.
 
Srikanth Nutigattu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont know if it is similar, But we faced similar issue when a SessionFactory object is created. I guess you can reduce the delay if you instantiate the SessionFactory or EntityManager in ServletContext listener, because it will be called during application startup, the required SessionFactory/EntityManager will be ready by the time first request arrives.

I am a novice in Hibernate hence excuse if some thing sounds stupid!
 
Oscar Calderon
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Srikanth, in my case i'm using Struts 2 so right now i initialize EntityManager from custom interceptor. You don't know if exists something in hibernate like "map the entity the first time that you use it" instead "map all the entities when entitymanager is initialized"?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic