-
Notifications
You must be signed in to change notification settings - Fork 0
add missing flushes #9
Comments
Flushes should not be required if the transaction is committed properly. In fact too many flushes can impact the performance of Hibernate on a busy system so it is not really a recommended practice. The only time I've seen this behavior in HbnContainer it was caused by the session-per-request pattern being implemented incorrectly, or not implemented at all. Could you please set a breakpoint in the doFilter method of your SessionInterceptor class and run your application to verify for me that the method is being called? Specifically, I want to be sure that the active transaction is being committed properly when your session completes. |
First of all: You're right, too many flushes will cause really bad performance. We noticed this while trying to solve the error. Sending a flush() after each SQL-call would be really bad. But it is required only after the insert / update / delete. And theese should not be so numerous. I'm not a Hibernate expert, so maybe you can tell me what we are doing wrong and what to do, to get it running without the flushes. I'll try to explain our setup more in detail. We use Vaadin 6, Hibernate 4, mySql 5, c3p0 Pool and com.mysql.jdbc.Driver. For our spring services we use @transactional, but to the HbnContainer we pass the plain sessionFactory.getCurrentSession() without any transaction. The error in HbnContainer occurs e.g. when deleting an entity. As I understand, the frontend will send just a single request to the server for deleting the entity. This request will call removeItem of the table, which passes it further to the container. In the removeItem comes:
There is the delete() directly followed by the refreshing of the complete container content.Without the flush() we added, this will result in an error. I don't really understand why, perhaps you know better. But at least I think at this point it does not matter, if there is a transaction or not, because all statements (DELETE and SELECTs) would be in the same without requiring a commit between. So, what do you think now, is there an error in out setup? And can you explain why the flush() is needed for us? Or shouldn't really HbnContainer use the flushes to work also with this setup? |
GP: Horst Krause I found this thread because I have a similar error. I use the HbnContainer and after deleting an item, I get the following exception twice. Does anybody know what to do? 15.12.2012 20:45:03 com.vaadin.Application terminalError Horst Krause After further investigating and even debugging into to core, I think the problem occurs, when an item is deleted form outside the table and its container. Controlling entity = getHbnContainer().getEntity(target); As you can see, after checking if deleting is allowed, I delete the entity through my service (because using the removeItem(target) also caused the error above (without deleting in db). The recreateHbnContainer reloads the container of the table. This will show the right result (wow!), but in the log file there is an exception: java.util.ConcurrentModificationException Does anybody know, how to force the table to update its view without any errors? Thanks for any help, Horst Horst Krause Finally we managed to solve this issue. There error occured because of some strange hibernate session <-> db synchronising. We copied the underlying HbnContainer and added a session.flush() after each insert, update, delete and now it works really good and fast. |
We had an issue with HbnContainer 1.1 with Hibernate4.
Updating and deleting always failed.
We found out, that the changes were not written to db and the following re-loading came to unsynchronized data between table, container and database.
Simple flush()es after the data changed statements solved the errors.
For detaols see here:
https://vaadin.com/forum/-/message_boards/view_message/2243680
The text was updated successfully, but these errors were encountered: