spring - Why would Hibernate throw a WrongClassException when the FlushMode is set to MANUAL? -



spring - Why would Hibernate throw a WrongClassException when the FlushMode is set to MANUAL? -

consider next scenario -

there 2 tables (identical in schema) called activeissue , resolvedissue. when issue active, in activeissue table , when issue resolved, moved resolvedissue table. issues can related each other.

i have method next -

get related issues issue activeissue get related issues issue resolvedissue

before calling method, set session.setflushmode(flushmode.manual) avoid next scenario -

get related issues activeissue in background, issue x gets resolved , moves activeissue resolvedissue get related issues resolvedissue (leads conflict because of issue x)

however, observe run wrongclassexception logic in place. instance,

org.hibernate.wrongclassexception: object id: 123456 not of specified subclass ... activeissue (loaded object of wrong class ... resolvedissue)

i using org.springframework.orm.hibernate3.support.hibernatedaosupport , phone call session session = getsession() on object. activeissue , resolvedissue both derive base of operations class called issue. utilize inheritancetype.table_per_class inheritance strategy on base of operations class, activeissue mapped activeissue table , resolvedissue mapped resolvedissue table.

i don't understand why wrongclassexception occurs when have explicitly set flushmode manual. shouldn't objects in session consistent?

setflushmode(...) : flushing process of synchronizing underlying persistent store persistable state held in memory.

in simple tell when update/remove (sync.) info memory taken db.

if go through flushmode come knwo setting flushmode manual means memory sync. when session.flush().

consider scenario 1 thread doing work shifting x issue activeissue resolvedissue , @ same time thread calling 1. related issues issue activeissue

so per before calling setting flushmode manual not sync. before query execution. per author

flushmode.auto : session flushed before query execution in order ensure queries never homecoming stale state.

so when query on table get related issues issue activeissue particular issue x (123456) may moved resolvedissue thread. id 123456 not of type activeissue getting exception

spring hibernate exception jpa orm

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -