java - Re-attach deserialized hibernate proxies -
i have retrieved database proxy object empp(domain class:employee)
hibernate using hql. i'd serialize it(step1) file , deserialize it(step2). step1 , step2 in 2 different threads.
problem in order:
- i serialize empp in step1.
- in step1 in not serialize attached session of
empp
in((proxyobject)empp).gethandler().session
,session
transient
. - in different thread, deserialize
empp
emppdeserialized
, have emppempp.gethandler().getsession()
equalnull
. step2 different session.
now, whenever call getter
emppdeserialized
, throws could not initialize proxy - no session
.
in step2, i'd emppdeserialized
attached current session getter calls successful.
now, 1 stupid way can think of is:
((org.hibernate.proxy.pojo.javassist.javassistlazyinitializer)((javassist.util.proxy.proxyobject)emppdeserialized).gethandler()) .setsession((org.hibernate.engine.spi.sessionimplementor)sessionfactory.getcurrentsession());
question is, i'd know best practice available , least sql calls in step2. in advance.
Comments
Post a Comment