Hiberate and JDBC in same transaction – Flush is a must if JDBC code depends on changes made by Hibernate

Hibernate may not issue queries or inserts to the database until the transaction is closed. So any change made to DB using Hibernate is only visble to Hibernate API. So if you have a JDBC code that executes after some Hibernate modifications, that JDBC code won’t see the change (like if JDBC code is accessing the same record hibernate modified, as in a legacy code) unless you issue a flush in Hibernate.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: