Let me rephrase the problem - it's not that someone adds record. The problem is that hibernate doesn't read added records during refreshing it's data.
For example - I have an order that I inserted into the database. But due to some business logic triggers the database extends the item list in the database and adds transport cost to the order. I am aware of that logic and I refresh my order to make sure that I synchronized it with the database. Those items that were updated by the trigger refresh fine. However any item that was inserted by the trigger is not visible.
It's not what I would expect from cascaded refresh. I would rather expect that hibernate reads not only updated records, but also all the related inserted records. However looking at the SQL statements generated hibernate cannot deduce related child records added to parent.
Cameron McKenzie wrote:
If someone is inserting data into the database, you can just have Hibernate refresh its data.
The point here is that Hibernate won't refresh the inserted data. It only refreshes updated data, it probably noticed deleted data, but it's simply impossible to grab inserted data with such sql statements. So I can't just have Hibernate refresh its data.