Hi all,
my current task at work is to update our e-commerce application DAO layer from H2 to H3. For this task I really appreciated your "Migration Guide" and want to thank you very much for doing so.
But I have a problem with the current (old) code that uses the H2 Lifecycle interface in this way (example code):
Code:
public class ExampleEntity implements Serializable, Lifecycle {
protected SessionFactory sessionFactory;
...
public void onLoad(Session session, Serializable arg1) {
sessionFactory = session.getSessionFactory();
}
....
public Float getPrice() {
if (this.price == null) {
Session session = SessionFactoryUtils.getSession(sessionFactory, false);
Query query = session.createQuery("....");
...
price = query.uniqueResult();
}
return this.price;
}
}
where SessionFactoryUtils is a Spring helper class that offers transparent hibernate session handling but it doesn't matter in this context.
Following the "migration guide" i have to use an interceptor and I agree that it can work. Please can confirm me that the only(or the best) way to convert my existing code (I have different entities that implement the deprecated Lifecycle interface as on the code fragment above) to H3 is to use org.hibernate.Interceptor?
Thank you very much.
Indrit