Hibernate does not notice database updates made from another source

I have a small system consisting of a .net client and a java web service.

The .net client inserts the object into the database and then calls the web service. The web service is trying to restore this object by using hibernation. The first time it works fine, but each time it says that there is no object with this identifier.

I checked the database manually and the row is really there! (I debugged the web service and checked the string even before the session was opened).

Decision

Added this to hibernate config file

<property name="connection.isolation">1</property>

Here is what I have tried so far:

  • Layer 2 cache disabled
  • Added .setCacheMode parameter (CacheMode.REFRESH)

Here is the error code:

Session session = Program.HibernateUtil.getSessionFactory().openSession();      
try    
{
    return (Alert)session.load(Alert.class, id);                           
} ...
+3
3

, (, factory) , , , :

sessionFactory.evict(Alert.class) 

: .

+2

-, Session.load(), Session.get(). load() , .

-, ? , Hibernate . . , evict() , .

+1

:

hibernate.cache.provider_class= org.hibernate.cache.NoCacheProvider

0

Source: https://habr.com/ru/post/1715067/


All Articles