M
M
Maxim Sitnikov2016-05-15 20:58:35
Java
Maxim Sitnikov, 2016-05-15 20:58:35

Why doesn't Hibernate pick up new records in the database?

There is a database manager application with a web face and an application that pulls records from this database. As ORM I use Hibernate. The bottom line: if you put the n-th number of records in the database and then run the application, it will pull them out and process them. But if during the execution of the application (it is spinning in an eternal loop) an entry is added to the database, then Hibernate categorically refuses to pull it out and returns empty collections. Than it can be caused?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Cheremisin, 2016-05-15
@leahch

I suspect it's a caching issue. To flush cache use Session.clear()

S
Sergey Gornostaev, 2016-05-16
@sergey-gornostaev

From the instructions :
There are a lot of cleaning options, as seen in documentation .

V
Vladimir Smirnov, 2016-05-16
@bobzer

Check how your transactions are completed after adding records, you may have forgotten to commit. Try to add a record and check its availability using the database itself (SQL query), and not in your application.
Plus, check the data reading logic, work under the debugger (or add messages to the log) and make sure that the application calls the read method periodically, and not just at startup.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question