anthony wrote:
it's not possible, do it in a DAO method implemented using jdbc
but be carefull with first and second level caches
I am using a Stateless Session Bean in my application. And, retrieving the POJO in one EJB method and passing it on directly to the web-tier. The web-tier updates the POJO and sends it back to another EJB method, which would persist the object to database.
If I don't enable 2nd level cache for this POJO class, I guess Hibernate won't try to cache it. So, I have to only worry about the 1st level cache, which happens only at the Session level. For the Session cache, I could evict() the object after its use in the EJB. I guess this will take care of the caching issue. Am I missing anything?
Another related question:
Before I update the row using JDBC, I want to lock the row. Can I use the Hibernate's Session.load(Class, key, LockMode.UPGRADE) to lock the row and then use JDBC to update the same row in my EJB method?