IAmYourFaja
IAmYourFaja

Reputation: 56904

Resolving Hibernate subtleties

I have spent several days now researching Hibernate and have several small questions about it that in and of themselves don't really merit cluttering SO but I think, together, help give some insight to how Hibernate operates as a whole:

Thanks in advance!

Upvotes: 2

Views: 68

Answers (1)

JB Nizet
JB Nizet

Reputation: 691685

  1. Because it would force Hibernate to scan all the classes of the classpath to discover annotated classes. And because you might have some entities in the classpath that you don't want to use in your application. Or you might want to have some entities in a session factory, and some others in another one. Or even the same entity in two seperate session factories.

  2. The Criteria API has methods which bind the parameters directly: Restrictions.eq("someProperty", someValue); for example.

  3. It's of course possible to write your own second-level cache, but you would have to configure Hibernate to use it, as you do with all the other providers. Dropping the classes in the classpath is not sufficient.

Upvotes: 2

Related Questions