HappyEngineer
asked on
hibernate is attempting to update rows unexpectedly
When I view a particular page it loads some objects and then displays them.
For some reason it also updates some objects which should not be updated. I've stepped through my code carefully and I cannot for the life of me figure out where an update is occurring.
I've changed the cache type for that object to be read-only. Now displaying that page always gives an exception when a particular query is executed. Here's the query:
from com.knowlist.list.hh.Custo mObjFieldM eta as cofm
where
cofm.objType=:objType
and cofm.fieldType=:fieldType
Here's the stack trace:
01:04:55.796 WARN!! [P1-0] org.mortbay.jetty.servlet. ServletHan dler.handl e(ServletH andler.jav a:590) >11> /know/:
java.lang.UnsupportedOpera tionExcept ion: Can't write to a readonly object
at org.hibernate.cache.ReadOn lyCache.lo ck(ReadOnl yCache.jav a:43)
at org.hibernate.action.Entit yUpdateAct ion.execut e(EntityUp dateAction .java:69)
at org.hibernate.engine.Actio nQueue.exe cute(Actio nQueue.jav a:239)
at org.hibernate.engine.Actio nQueue.exe cuteAction s(ActionQu eue.java:2 23)
at org.hibernate.engine.Actio nQueue.exe cuteAction s(ActionQu eue.java:1 37)
at org.hibernate.event.def.Ab stractFlus hingEventL istener.pe rformExecu tions(Abst ractFlushi ngEventLis tener.java :274)
at org.hibernate.event.def.De faultAutoF lushEventL istener.on AutoFlush( DefaultAut oFlushEven tListener. java:48)
at org.hibernate.impl.Session Impl.autoF lushIfRequ ired(Sessi onImpl.jav a:659)
at org.hibernate.impl.Session Impl.prepa reQueries( SessionImp l.java:833 )
at org.hibernate.impl.Session Impl.getQu eries(Sess ionImpl.ja va:823)
at org.hibernate.impl.Session Impl.list( SessionImp l.java:782 )
at org.hibernate.impl.QueryIm pl.list(Qu eryImpl.ja va:74)
at org.hibernate.impl.Abstrac tQueryImpl .uniqueRes ult(Abstra ctQueryImp l.java:603 )
at com.knowlist.list.hh.dao.C ustomObjFi eldMetaDAO .findByFie ldType(Cus tomObjFiel dMetaDAO.j ava:51)
at com.knowlist.list.hh.Custo mObj.getFi eld(Custom Obj.java:1 41)
at com.knowlist.list.main.Mai nPage.serv ice(MainPa ge.java:45 )
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 688)
at org.mortbay.jetty.servlet. ServletHol der.handle (ServletHo lder.java: 427)
at org.mortbay.jetty.servlet. WebApplica tionHandle r.dispatch (WebApplic ationHandl er.java:49 6)
at org.mortbay.jetty.servlet. Dispatcher .dispatch( Dispatcher .java:263)
at org.mortbay.jetty.servlet. Dispatcher .forward(D ispatcher. java:157)
at org.apache.jasper.runtime. PageContex tImpl.doFo rward(Page ContextImp l.java:670 )
at org.apache.jasper.runtime. PageContex tImpl.forw ard(PageCo ntextImpl. java:637)
at org.apache.jsp.index_jsp._ jspService (index_jsp .java:45)
at org.apache.jasper.runtime. HttpJspBas e.service( HttpJspBas e.java:94)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 688)
at org.apache.jasper.servlet. JspServlet Wrapper.se rvice(JspS ervletWrap per.java:3 24)
at org.apache.jasper.servlet. JspServlet .serviceJs pFile(JspS ervlet.jav a:292)
at org.apache.jasper.servlet. JspServlet .service(J spServlet. java:236)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 688)
at org.mortbay.jetty.servlet. ServletHol der.handle (ServletHo lder.java: 427)
at org.mortbay.jetty.servlet. WebApplica tionHandle r.dispatch (WebApplic ationHandl er.java:49 6)
at org.mortbay.jetty.servlet. Dispatcher .dispatch( Dispatcher .java:263)
at org.mortbay.jetty.servlet. Dispatcher .forward(D ispatcher. java:157)
at org.mortbay.jetty.servlet. Default.ha ndleGet(De fault.java :312)
at org.mortbay.jetty.servlet. Default.se rvice(Defa ult.java:2 32)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 688)
at org.mortbay.jetty.servlet. ServletHol der.handle (ServletHo lder.java: 427)
at org.mortbay.jetty.servlet. WebApplica tionHandle r$CachedCh ain.doFilt er(WebAppl icationHan dler.java: 822)
at com.knowlist.hibernate.Hib ernateSess ionFilter. doFilter(H ibernateSe ssionFilte r.java:54)
at org.mortbay.jetty.servlet. WebApplica tionHandle r$CachedCh ain.doFilt er(WebAppl icationHan dler.java: 813)
at org.tuckey.web.filters.url rewrite.Ur lRewriteFi lter.doFil ter(UrlRew riteFilter .java:298)
at org.mortbay.jetty.servlet. WebApplica tionHandle r$CachedCh ain.doFilt er(WebAppl icationHan dler.java: 813)
at org.mortbay.jetty.servlet. WebApplica tionHandle r.dispatch (WebApplic ationHandl er.java:49 4)
at org.mortbay.jetty.servlet. ServletHan dler.handl e(ServletH andler.jav a:569)
at org.mortbay.http.HttpConte xt.handle( HttpContex t.java:148 2)
at org.mortbay.jetty.servlet. WebApplica tionContex t.handle(W ebApplicat ionContext .java:624)
at org.mortbay.http.HttpConte xt.handle( HttpContex t.java:143 4)
at org.mortbay.http.HttpServe r.service( HttpServer .java:896)
at org.mortbay.http.HttpConne ction.serv ice(HttpCo nnection.j ava:814)
at org.mortbay.http.HttpConne ction.hand leNext(Htt pConnectio n.java:981 )
at org.mortbay.http.HttpConne ction.hand le(HttpCon nection.ja va:831)
at org.mortbay.http.SocketLis tener.hand leConnecti on(SocketL istener.ja va:244)
at org.mortbay.util.ThreadedS erver.hand le(Threade dServer.ja va:366)
at org.mortbay.util.ThreadPoo l$PoolThre ad.run(Thr eadPool.ja va:534)
I cannot figure out where the stupid object is being updated (if anywhere).
For some reason it also updates some objects which should not be updated. I've stepped through my code carefully and I cannot for the life of me figure out where an update is occurring.
I've changed the cache type for that object to be read-only. Now displaying that page always gives an exception when a particular query is executed. Here's the query:
from com.knowlist.list.hh.Custo
where
cofm.objType=:objType
and cofm.fieldType=:fieldType
Here's the stack trace:
01:04:55.796 WARN!! [P1-0] org.mortbay.jetty.servlet.
java.lang.UnsupportedOpera
at org.hibernate.cache.ReadOn
at org.hibernate.action.Entit
at org.hibernate.engine.Actio
at org.hibernate.engine.Actio
at org.hibernate.engine.Actio
at org.hibernate.event.def.Ab
at org.hibernate.event.def.De
at org.hibernate.impl.Session
at org.hibernate.impl.Session
at org.hibernate.impl.Session
at org.hibernate.impl.Session
at org.hibernate.impl.QueryIm
at org.hibernate.impl.Abstrac
at com.knowlist.list.hh.dao.C
at com.knowlist.list.hh.Custo
at com.knowlist.list.main.Mai
at javax.servlet.http.HttpSer
at org.mortbay.jetty.servlet.
at org.mortbay.jetty.servlet.
at org.mortbay.jetty.servlet.
at org.mortbay.jetty.servlet.
at org.apache.jasper.runtime.
at org.apache.jasper.runtime.
at org.apache.jsp.index_jsp._
at org.apache.jasper.runtime.
at javax.servlet.http.HttpSer
at org.apache.jasper.servlet.
at org.apache.jasper.servlet.
at org.apache.jasper.servlet.
at javax.servlet.http.HttpSer
at org.mortbay.jetty.servlet.
at org.mortbay.jetty.servlet.
at org.mortbay.jetty.servlet.
at org.mortbay.jetty.servlet.
at org.mortbay.jetty.servlet.
at org.mortbay.jetty.servlet.
at javax.servlet.http.HttpSer
at org.mortbay.jetty.servlet.
at org.mortbay.jetty.servlet.
at com.knowlist.hibernate.Hib
at org.mortbay.jetty.servlet.
at org.tuckey.web.filters.url
at org.mortbay.jetty.servlet.
at org.mortbay.jetty.servlet.
at org.mortbay.jetty.servlet.
at org.mortbay.http.HttpConte
at org.mortbay.jetty.servlet.
at org.mortbay.http.HttpConte
at org.mortbay.http.HttpServe
at org.mortbay.http.HttpConne
at org.mortbay.http.HttpConne
at org.mortbay.http.HttpConne
at org.mortbay.http.SocketLis
at org.mortbay.util.ThreadedS
at org.mortbay.util.ThreadPoo
I cannot figure out where the stupid object is being updated (if anywhere).
ASKER
Ok, I've wittled the code down to the simplest possible code I could get that still showed this behavior.
This is executed at the beginning of a servlet, so nothing else has happened before this is executed.
Session s = CustomObjFieldMetaDAO.getI nstance(). getSession ();
Query query = s.getNamedQuery("com.knowl ist.list.h h.CustomOb jFieldMeta .findByObj TypeAndFie ldType");
query.setInteger("objType" ,100);
query.setInteger("fieldTyp e",10);
query.uniqueResult();
// No exeception has been thrown yet. But, when query.uniqueResult() is called again here, it will throw the exception I specified in my first message.
query.uniqueResult();
Note that I normally do not actually just call query.uniqueResult() twice in the row. Before wittling it down, the problem was occurring when I tried to execute this query multiple times. But, it looks like it fails the same if I just execute the same Query twice in a row.
This is executed at the beginning of a servlet, so nothing else has happened before this is executed.
Session s = CustomObjFieldMetaDAO.getI
Query query = s.getNamedQuery("com.knowl
query.setInteger("objType"
query.setInteger("fieldTyp
query.uniqueResult();
// No exeception has been thrown yet. But, when query.uniqueResult() is called again here, it will throw the exception I specified in my first message.
query.uniqueResult();
Note that I normally do not actually just call query.uniqueResult() twice in the row. Before wittling it down, the problem was occurring when I tried to execute this query multiple times. But, it looks like it fails the same if I just execute the same Query twice in a row.
ASKER
If it helps, here is the entire hbm file for the offending object:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping schema="know" package="com.knowlist.list .hh">
<class name="CustomObjFieldMeta" table="customobjfieldmeta" >
<!-- OPTIONS: read-write, nonstrict-read-write, read-only -->
<cache usage="read-only"/>
<id
column="id"
name="id"
type="integer"
>
<generator class="sequence"><param name="sequence">CustomObjF ieldMeta_i d_seq</par am></gener ator>
</id>
<property
column="visibility"
length="11"
name="visibility"
not-null="true"
type="integer"
/>
<property
column="versionId"
length="11"
name="versionId"
not-null="false"
type="integer"
/>
<property
column="objType"
length="11"
name="objType"
not-null="true"
type="integer"
/>
<property
column="versionOf"
length="11"
name="versionOf"
not-null="false"
type="integer"
/>
<property
column="shortDesc"
name="shortDesc"
not-null="false"
type="string"
/>
<property
column="longDesc"
name="longDesc"
not-null="false"
type="string"
/>
<many-to-one name="fieldType" class="com.knowlist.list.h h.CustomOb jFieldType " column="fieldType" not-null="true"/>
</class>
<query name="com.knowlist.list.hh .CustomObj FieldMeta. findByObjT ype">
<![CDATA[
select cofm
from
com.knowlist.list.hh.Custo mObjFieldM eta as cofm,
com.knowlist.list.hh.Custo mObjFieldT ype as coft
where
cofm.objType=:objType
and cofm.fieldType=coft
order by
cofm.fieldType
]]>
</query>
<query name="com.knowlist.list.hh .CustomObj FieldMeta. findByObjT ypeAndFiel dType">
<![CDATA[
from com.knowlist.list.hh.Custo mObjFieldM eta as cofm
where
cofm.objType=:objType
and cofm.fieldType=:fieldType
]]>
</query>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping schema="know" package="com.knowlist.list
<class name="CustomObjFieldMeta" table="customobjfieldmeta"
<!-- OPTIONS: read-write, nonstrict-read-write, read-only -->
<cache usage="read-only"/>
<id
column="id"
name="id"
type="integer"
>
<generator class="sequence"><param name="sequence">CustomObjF
</id>
<property
column="visibility"
length="11"
name="visibility"
not-null="true"
type="integer"
/>
<property
column="versionId"
length="11"
name="versionId"
not-null="false"
type="integer"
/>
<property
column="objType"
length="11"
name="objType"
not-null="true"
type="integer"
/>
<property
column="versionOf"
length="11"
name="versionOf"
not-null="false"
type="integer"
/>
<property
column="shortDesc"
name="shortDesc"
not-null="false"
type="string"
/>
<property
column="longDesc"
name="longDesc"
not-null="false"
type="string"
/>
<many-to-one name="fieldType" class="com.knowlist.list.h
</class>
<query name="com.knowlist.list.hh
<![CDATA[
select cofm
from
com.knowlist.list.hh.Custo
com.knowlist.list.hh.Custo
where
cofm.objType=:objType
and cofm.fieldType=coft
order by
cofm.fieldType
]]>
</query>
<query name="com.knowlist.list.hh
<![CDATA[
from com.knowlist.list.hh.Custo
where
cofm.objType=:objType
and cofm.fieldType=:fieldType
]]>
</query>
</hibernate-mapping>
Hi,
Let me have a look and will let you know tommorow.
Regards
Dave
Let me have a look and will let you know tommorow.
Regards
Dave
Hi,
>>"I've changed the cache type for that object to be read-only."
if you change it back to be NOT read-only, what is the error message?
Regards
Dave
>>"I've changed the cache type for that object to be read-only."
if you change it back to be NOT read-only, what is the error message?
Regards
Dave
ASKER
There isn't any error message in that case. But, the thing that put me onto this whole issue was that I was getting what appeared to be deadlocks in the DB just from viewing the front page. If I refreshed the page fast enough then it would eventually lock up and all future requests never finished.
I checked the DB and found that an apparent deadlock was occuring because a whole bunch of updates were being attempted to CustomObjFieldMeta even though no updates should have been occurring at all.
There are really two mysteries here. The first is the question of why these updates are occurring at all. The second is why lots of these updates result in a deadlock even though no transactions should be involved because I am obviously not wrapping this stuff in a transaction because I'm not actually doing any updates at all.
See two other topics I posted on this:
https://www.experts-exchange.com/questions/21409106/deadlock-in-same-transaction-URGENT.html
https://www.experts-exchange.com/questions/21410209/hibernate-causing-deadlocks-in-PostgresSql-8.html
The first one has info about the deadlocks and shows the updates that were occuring.
I checked the DB and found that an apparent deadlock was occuring because a whole bunch of updates were being attempted to CustomObjFieldMeta even though no updates should have been occurring at all.
There are really two mysteries here. The first is the question of why these updates are occurring at all. The second is why lots of these updates result in a deadlock even though no transactions should be involved because I am obviously not wrapping this stuff in a transaction because I'm not actually doing any updates at all.
See two other topics I posted on this:
https://www.experts-exchange.com/questions/21409106/deadlock-in-same-transaction-URGENT.html
https://www.experts-exchange.com/questions/21410209/hibernate-causing-deadlocks-in-PostgresSql-8.html
The first one has info about the deadlocks and shows the updates that were occuring.
ASKER
Also, note that I have lots of other hibernate objects, but this is the only one that actually caused any deadlocks. I haven't attempted to test if these updates are occuring for everything or just this object.
ASKER
I removed all servlet filters and moved the code into a separate servlet. It still does the update. To elminate the exception I made the cache read-write again. But, notice that in the log where it does an update.
Here's the test servlet:
package com.knowlist.list.main;
import java.io.IOException;
import javax.servlet.ServletExcep tion;
import javax.servlet.http.HttpSer vlet;
import javax.servlet.http.HttpSer vletReques t;
import javax.servlet.http.HttpSer vletRespon se;
import org.apache.log4j.Logger;
import org.hibernate.Query;
import org.hibernate.Session;
import com.knowlist.list.hh.Hiber nateInit;
import com.knowlist.list.hh.dao.C ustomObjFi eldMetaDAO ;
import com.knowlist.list.hh.dao._ RootDAO;
public class MainPageTest extends HttpServlet {
static {
HibernateInit.doInit();
}
protected void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
try {
Logger.getLogger(getClass( )).debug(" 1");
Session s = CustomObjFieldMetaDAO.getI nstance(). getSession ();
Query query = s.getNamedQuery("com.knowl ist.list.h h.CustomOb jFieldMeta .findByObj TypeAndFie ldType");
query.setInteger("objType" ,100);
query.setInteger("fieldTyp e",10);
Logger.getLogger(getClass( )).debug(" 2");
query.uniqueResult();
Logger.getLogger(getClass( )).debug(" 3");
query.uniqueResult();
Logger.getLogger(getClass( )).debug(" 4");
} catch(Exception e) {
throw new ServletException(e);
} finally {
_RootDAO.closeCurrentThrea dSessions( );
}
}
}
After my app server starts up, here is what is output after I hit this servlet 3 times in a row. Notice that it does the exact same thing each time.
DEBUG[2005-05-04 19:50:53,453] com.knowlist.list.main.Mai nPageTest. service(Ma inPageTest .java:29)( MainPageTe st.java29) : 1
DEBUG[2005-05-04 19:50:53,625] com.knowlist.list.main.Mai nPageTest. service(Ma inPageTest .java:34)( MainPageTe st.java34) : 2
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility7_, customobjf0_.versionId as versionId7_, customobjf0_.objType as objType7_, customobjf0_.versionOf as versionOf7_, customobjf0_.shortDesc as shortDesc7_, customobjf0_.longDesc as longDesc7_, customobjf0_.fieldType as fieldType7_ from know.customobjfieldmeta customobjf0_ where customobjf0_.objType=? and customobjf0_.fieldType=?
DEBUG[2005-05-04 19:50:53,703] com.knowlist.list.main.Mai nPageTest. service(Ma inPageTest .java:36)( MainPageTe st.java36) : 3
Hibernate: select customobjf0_.id as id0_, customobjf0_.keyName as keyName13_0_, customobjf0_.shortDesc as shortDesc13_0_, customobjf0_.longDesc as longDesc13_0_, customobjf0_.storageParam1 as storageP5_13_0_, customobjf0_.storageParam2 as storageP6_13_0_, customobjf0_.storageParam3 as storageP7_13_0_, customobjf0_.storageParam4 as storageP8_13_0_, customobjf0_.storageType as storageT9_13_0_ from know.customobjfieldtype customobjf0_ where customobjf0_.id=?
Hibernate: update know.customobjfieldmeta set visibility=?, versionId=?, objType=?, versionOf=?, shortDesc=?, longDesc=?, fieldType=? where id=?
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility7_, customobjf0_.versionId as versionId7_, customobjf0_.objType as objType7_, customobjf0_.versionOf as versionOf7_, customobjf0_.shortDesc as shortDesc7_, customobjf0_.longDesc as longDesc7_, customobjf0_.fieldType as fieldType7_ from know.customobjfieldmeta customobjf0_ where customobjf0_.objType=? and customobjf0_.fieldType=?
DEBUG[2005-05-04 19:50:53,750] com.knowlist.list.main.Mai nPageTest. service(Ma inPageTest .java:38)( MainPageTe st.java38) : 4
DEBUG[2005-05-04 19:51:03,046] com.knowlist.list.main.Mai nPageTest. service(Ma inPageTest .java:29)( MainPageTe st.java29) : 1
DEBUG[2005-05-04 19:51:03,046] com.knowlist.list.main.Mai nPageTest. service(Ma inPageTest .java:34)( MainPageTe st.java34) : 2
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility7_, customobjf0_.versionId as versionId7_, customobjf0_.objType as objType7_, customobjf0_.versionOf as versionOf7_, customobjf0_.shortDesc as shortDesc7_, customobjf0_.longDesc as longDesc7_, customobjf0_.fieldType as fieldType7_ from know.customobjfieldmeta customobjf0_ where customobjf0_.objType=? and customobjf0_.fieldType=?
DEBUG[2005-05-04 19:51:03,046] com.knowlist.list.main.Mai nPageTest. service(Ma inPageTest .java:36)( MainPageTe st.java36) : 3
Hibernate: update know.customobjfieldmeta set visibility=?, versionId=?, objType=?, versionOf=?, shortDesc=?, longDesc=?, fieldType=? where id=?
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility7_, customobjf0_.versionId as versionId7_, customobjf0_.objType as objType7_, customobjf0_.versionOf as versionOf7_, customobjf0_.shortDesc as shortDesc7_, customobjf0_.longDesc as longDesc7_, customobjf0_.fieldType as fieldType7_ from know.customobjfieldmeta customobjf0_ where customobjf0_.objType=? and customobjf0_.fieldType=?
DEBUG[2005-05-04 19:51:03,062] com.knowlist.list.main.Mai nPageTest. service(Ma inPageTest .java:38)( MainPageTe st.java38) : 4
DEBUG[2005-05-04 19:51:04,203] com.knowlist.list.main.Mai nPageTest. service(Ma inPageTest .java:29)( MainPageTe st.java29) : 1
DEBUG[2005-05-04 19:51:04,203] com.knowlist.list.main.Mai nPageTest. service(Ma inPageTest .java:34)( MainPageTe st.java34) : 2
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility7_, customobjf0_.versionId as versionId7_, customobjf0_.objType as objType7_, customobjf0_.versionOf as versionOf7_, customobjf0_.shortDesc as shortDesc7_, customobjf0_.longDesc as longDesc7_, customobjf0_.fieldType as fieldType7_ from know.customobjfieldmeta customobjf0_ where customobjf0_.objType=? and customobjf0_.fieldType=?
DEBUG[2005-05-04 19:51:04,218] com.knowlist.list.main.Mai nPageTest. service(Ma inPageTest .java:36)( MainPageTe st.java36) : 3
Hibernate: update know.customobjfieldmeta set visibility=?, versionId=?, objType=?, versionOf=?, shortDesc=?, longDesc=?, fieldType=? where id=?
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility7_, customobjf0_.versionId as versionId7_, customobjf0_.objType as objType7_, customobjf0_.versionOf as versionOf7_, customobjf0_.shortDesc as shortDesc7_, customobjf0_.longDesc as longDesc7_, customobjf0_.fieldType as fieldType7_ from know.customobjfieldmeta customobjf0_ where customobjf0_.objType=? and customobjf0_.fieldType=?
DEBUG[2005-05-04 19:51:04,234] com.knowlist.list.main.Mai nPageTest. service(Ma inPageTest .java:38)( MainPageTe st.java38) : 4
Here's the test servlet:
package com.knowlist.list.main;
import java.io.IOException;
import javax.servlet.ServletExcep
import javax.servlet.http.HttpSer
import javax.servlet.http.HttpSer
import javax.servlet.http.HttpSer
import org.apache.log4j.Logger;
import org.hibernate.Query;
import org.hibernate.Session;
import com.knowlist.list.hh.Hiber
import com.knowlist.list.hh.dao.C
import com.knowlist.list.hh.dao._
public class MainPageTest extends HttpServlet {
static {
HibernateInit.doInit();
}
protected void service(HttpServletRequest
throws ServletException, IOException
{
try {
Logger.getLogger(getClass(
Session s = CustomObjFieldMetaDAO.getI
Query query = s.getNamedQuery("com.knowl
query.setInteger("objType"
query.setInteger("fieldTyp
Logger.getLogger(getClass(
query.uniqueResult();
Logger.getLogger(getClass(
query.uniqueResult();
Logger.getLogger(getClass(
} catch(Exception e) {
throw new ServletException(e);
} finally {
_RootDAO.closeCurrentThrea
}
}
}
After my app server starts up, here is what is output after I hit this servlet 3 times in a row. Notice that it does the exact same thing each time.
DEBUG[2005-05-04 19:50:53,453] com.knowlist.list.main.Mai
DEBUG[2005-05-04 19:50:53,625] com.knowlist.list.main.Mai
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility7_, customobjf0_.versionId as versionId7_, customobjf0_.objType as objType7_, customobjf0_.versionOf as versionOf7_, customobjf0_.shortDesc as shortDesc7_, customobjf0_.longDesc as longDesc7_, customobjf0_.fieldType as fieldType7_ from know.customobjfieldmeta customobjf0_ where customobjf0_.objType=? and customobjf0_.fieldType=?
DEBUG[2005-05-04 19:50:53,703] com.knowlist.list.main.Mai
Hibernate: select customobjf0_.id as id0_, customobjf0_.keyName as keyName13_0_, customobjf0_.shortDesc as shortDesc13_0_, customobjf0_.longDesc as longDesc13_0_, customobjf0_.storageParam1
Hibernate: update know.customobjfieldmeta set visibility=?, versionId=?, objType=?, versionOf=?, shortDesc=?, longDesc=?, fieldType=? where id=?
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility7_, customobjf0_.versionId as versionId7_, customobjf0_.objType as objType7_, customobjf0_.versionOf as versionOf7_, customobjf0_.shortDesc as shortDesc7_, customobjf0_.longDesc as longDesc7_, customobjf0_.fieldType as fieldType7_ from know.customobjfieldmeta customobjf0_ where customobjf0_.objType=? and customobjf0_.fieldType=?
DEBUG[2005-05-04 19:50:53,750] com.knowlist.list.main.Mai
DEBUG[2005-05-04 19:51:03,046] com.knowlist.list.main.Mai
DEBUG[2005-05-04 19:51:03,046] com.knowlist.list.main.Mai
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility7_, customobjf0_.versionId as versionId7_, customobjf0_.objType as objType7_, customobjf0_.versionOf as versionOf7_, customobjf0_.shortDesc as shortDesc7_, customobjf0_.longDesc as longDesc7_, customobjf0_.fieldType as fieldType7_ from know.customobjfieldmeta customobjf0_ where customobjf0_.objType=? and customobjf0_.fieldType=?
DEBUG[2005-05-04 19:51:03,046] com.knowlist.list.main.Mai
Hibernate: update know.customobjfieldmeta set visibility=?, versionId=?, objType=?, versionOf=?, shortDesc=?, longDesc=?, fieldType=? where id=?
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility7_, customobjf0_.versionId as versionId7_, customobjf0_.objType as objType7_, customobjf0_.versionOf as versionOf7_, customobjf0_.shortDesc as shortDesc7_, customobjf0_.longDesc as longDesc7_, customobjf0_.fieldType as fieldType7_ from know.customobjfieldmeta customobjf0_ where customobjf0_.objType=? and customobjf0_.fieldType=?
DEBUG[2005-05-04 19:51:03,062] com.knowlist.list.main.Mai
DEBUG[2005-05-04 19:51:04,203] com.knowlist.list.main.Mai
DEBUG[2005-05-04 19:51:04,203] com.knowlist.list.main.Mai
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility7_, customobjf0_.versionId as versionId7_, customobjf0_.objType as objType7_, customobjf0_.versionOf as versionOf7_, customobjf0_.shortDesc as shortDesc7_, customobjf0_.longDesc as longDesc7_, customobjf0_.fieldType as fieldType7_ from know.customobjfieldmeta customobjf0_ where customobjf0_.objType=? and customobjf0_.fieldType=?
DEBUG[2005-05-04 19:51:04,218] com.knowlist.list.main.Mai
Hibernate: update know.customobjfieldmeta set visibility=?, versionId=?, objType=?, versionOf=?, shortDesc=?, longDesc=?, fieldType=? where id=?
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility7_, customobjf0_.versionId as versionId7_, customobjf0_.objType as objType7_, customobjf0_.versionOf as versionOf7_, customobjf0_.shortDesc as shortDesc7_, customobjf0_.longDesc as longDesc7_, customobjf0_.fieldType as fieldType7_ from know.customobjfieldmeta customobjf0_ where customobjf0_.objType=? and customobjf0_.fieldType=?
DEBUG[2005-05-04 19:51:04,234] com.knowlist.list.main.Mai
Hi HappyEngineer,
After debugging all your codes, I have to apologize that I do not know where the errors are. I hope that other experts can help you. If this thread has no more response and since your question has not been answered, you can get refund.
Regards
Dave
After debugging all your codes, I have to apologize that I do not know where the errors are. I hope that other experts can help you. If this thread has no more response and since your question has not been answered, you can get refund.
Regards
Dave
Truly apologize.
I agree that it is very strange.
It is also consistent, the updates always happens after the third time :-0
To isolate the problem do you mind to take out the cache settings from Hibernate configuration and see if you can reproduce it?
It is also consistent, the updates always happens after the third time :-0
To isolate the problem do you mind to take out the cache settings from Hibernate configuration and see if you can reproduce it?
ASKER
Ok, I've got some interesting new info. After a lot of experimentation, I've discovered the following:
The following does NOT cause updates:
protected void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
try {
Session s = CustomObjFieldMetaDAO.getI nstance(). getSession ();
Query query = s.createQuery("from com.knowlist.list.hh.Custo mObjFieldM eta as cofm");
query.list();
} catch(Exception e) {
throw new ServletException(e);
} finally {
_RootDAO.closeCurrentThrea dSessions( );
}
try {
Session s = CustomObjFieldMetaDAO.getI nstance(). getSession ();
Query query = s.createQuery("from com.knowlist.list.hh.Custo mObjFieldM eta as cofm");
query.list();
} catch(Exception e) {
throw new ServletException(e);
} finally {
_RootDAO.closeCurrentThrea dSessions( );
}
}
The following DOES cause updates:
protected void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
try {
Session s = CustomObjFieldMetaDAO.getI nstance(). getSession ();
Query query = s.createQuery("from com.knowlist.list.hh.Custo mObjFieldM eta as cofm");
query.list();
query.list();
} catch(Exception e) {
throw new ServletException(e);
} finally {
_RootDAO.closeCurrentThrea dSessions( );
}
}
In the first case I run the query.list() in separate sessions. In the latter I run them in the same session.
Furthermore, if I execute query.list() more than two times in a row, it only causes ONE update. That one update occurs when the second call to query.list() is made.
Another interesting bit is that, you may notice I'm doing list() instead of uniqueResult() now. I found that by changing the query to increase the number of results, it will actually update all results returned. So, if query.list() returns 50 results then I actually see 50 update statements run.
Lastly, the CustomObjFieldMeta object have a variety of attributes. One of them is called shortDesc. I override that method as such:
public CustomObjFieldType getFieldType() {
return CustomObjFieldTypeDAO.getI nstance(). load(getFi eldTypeId( ));
}
public java.lang.String getShortDesc() {
String shortDesc = super.getShortDesc();
if(shortDesc==null || "".equals(shortDesc))
return getFieldType().getShortDes c();
return shortDesc;
}
I found that if I comment out the section of getShortDesc() which calls getFieldType() then no updates occur. So, somehow loading the corresponding CustomObjFieldType causes the CustomObjFieldMeta to become "dirty" somehow. But, the key here is that getShortDesc() is NOT called except before the second execution of the query. Why that should be the case is totally inexplicable to me.
As it turns out, turning off ehcache does not appear to have an effect on this. It's hard to tell because I haven't removing the cache enabling lines in all the other hbm files.
The following does NOT cause updates:
protected void service(HttpServletRequest
throws ServletException, IOException
{
try {
Session s = CustomObjFieldMetaDAO.getI
Query query = s.createQuery("from com.knowlist.list.hh.Custo
query.list();
} catch(Exception e) {
throw new ServletException(e);
} finally {
_RootDAO.closeCurrentThrea
}
try {
Session s = CustomObjFieldMetaDAO.getI
Query query = s.createQuery("from com.knowlist.list.hh.Custo
query.list();
} catch(Exception e) {
throw new ServletException(e);
} finally {
_RootDAO.closeCurrentThrea
}
}
The following DOES cause updates:
protected void service(HttpServletRequest
throws ServletException, IOException
{
try {
Session s = CustomObjFieldMetaDAO.getI
Query query = s.createQuery("from com.knowlist.list.hh.Custo
query.list();
query.list();
} catch(Exception e) {
throw new ServletException(e);
} finally {
_RootDAO.closeCurrentThrea
}
}
In the first case I run the query.list() in separate sessions. In the latter I run them in the same session.
Furthermore, if I execute query.list() more than two times in a row, it only causes ONE update. That one update occurs when the second call to query.list() is made.
Another interesting bit is that, you may notice I'm doing list() instead of uniqueResult() now. I found that by changing the query to increase the number of results, it will actually update all results returned. So, if query.list() returns 50 results then I actually see 50 update statements run.
Lastly, the CustomObjFieldMeta object have a variety of attributes. One of them is called shortDesc. I override that method as such:
public CustomObjFieldType getFieldType() {
return CustomObjFieldTypeDAO.getI
}
public java.lang.String getShortDesc() {
String shortDesc = super.getShortDesc();
if(shortDesc==null || "".equals(shortDesc))
return getFieldType().getShortDes
return shortDesc;
}
I found that if I comment out the section of getShortDesc() which calls getFieldType() then no updates occur. So, somehow loading the corresponding CustomObjFieldType causes the CustomObjFieldMeta to become "dirty" somehow. But, the key here is that getShortDesc() is NOT called except before the second execution of the query. Why that should be the case is totally inexplicable to me.
As it turns out, turning off ehcache does not appear to have an effect on this. It's hard to tell because I haven't removing the cache enabling lines in all the other hbm files.
ASKER
Ok, this is getting stupid. First, check out my previous update. That's all true. But, here's another crazy thing. If I do:
query.setMaxResults(1);
then call
query.list();
query.list();
query.list();
query.list();
query.list();
query.list();
query.list();
I get the following. Note that now UPDATE is now also run on the customobjfieldtype object. This only happens if I use setMaxResults(1). If I don't call that method it will just update customobjfieldmeta a bunch of times before the 2nd query.list(). Now, with setMaxResults(1), it updates customobjfieldmeta after every update plus it updates customobjfieldtype twice.
This is just nonsensical. I've tried doing a clean remake from the hbm files and a clean rebuild of the entire project. It doesn't change anything.
DEBUG[2005-05-05 01:29:09,984] com.knowlist.list.main.Mai nPageTest. service(Ma inPageTest .java:35)( MainPageTe st.java35) : 1
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility0_, customobjf0_.versionId as versionId0_, customobjf0_.objType as objType0_, customobjf0_.versionOf as versionOf0_, customobjf0_.shortDesc as shortDesc0_, customobjf0_.longDesc as longDesc0_, customobjf0_.fieldType as fieldType0_ from know.customobjfieldmeta customobjf0_ limit ?
Hibernate: select customobjf0_.id as id0_, customobjf0_.keyName as keyName1_0_, customobjf0_.shortDesc as shortDesc1_0_, customobjf0_.longDesc as longDesc1_0_, customobjf0_.storageParam1 as storageP5_1_0_, customobjf0_.storageParam2 as storageP6_1_0_, customobjf0_.storageParam3 as storageP7_1_0_, customobjf0_.storageParam4 as storageP8_1_0_, customobjf0_.storageType as storageT9_1_0_ from know.customobjfieldtype customobjf0_ where customobjf0_.id=?
Hibernate: update know.customobjfieldmeta set visibility=?, versionId=?, objType=?, versionOf=?, shortDesc=?, longDesc=?, fieldType=? where id=?
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility0_, customobjf0_.versionId as versionId0_, customobjf0_.objType as objType0_, customobjf0_.versionOf as versionOf0_, customobjf0_.shortDesc as shortDesc0_, customobjf0_.longDesc as longDesc0_, customobjf0_.fieldType as fieldType0_ from know.customobjfieldmeta customobjf0_ limit ?
Hibernate: update know.customobjfieldmeta set visibility=?, versionId=?, objType=?, versionOf=?, shortDesc=?, longDesc=?, fieldType=? where id=?
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility0_, customobjf0_.versionId as versionId0_, customobjf0_.objType as objType0_, customobjf0_.versionOf as versionOf0_, customobjf0_.shortDesc as shortDesc0_, customobjf0_.longDesc as longDesc0_, customobjf0_.fieldType as fieldType0_ from know.customobjfieldmeta customobjf0_ limit ?
Hibernate: select customobjf0_.id as id0_, customobjf0_.keyName as keyName1_0_, customobjf0_.shortDesc as shortDesc1_0_, customobjf0_.longDesc as longDesc1_0_, customobjf0_.storageParam1 as storageP5_1_0_, customobjf0_.storageParam2 as storageP6_1_0_, customobjf0_.storageParam3 as storageP7_1_0_, customobjf0_.storageParam4 as storageP8_1_0_, customobjf0_.storageType as storageT9_1_0_ from know.customobjfieldtype customobjf0_ where customobjf0_.id=?
Hibernate: update know.customobjfieldmeta set visibility=?, versionId=?, objType=?, versionOf=?, shortDesc=?, longDesc=?, fieldType=? where id=?
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility0_, customobjf0_.versionId as versionId0_, customobjf0_.objType as objType0_, customobjf0_.versionOf as versionOf0_, customobjf0_.shortDesc as shortDesc0_, customobjf0_.longDesc as longDesc0_, customobjf0_.fieldType as fieldType0_ from know.customobjfieldmeta customobjf0_ limit ?
Hibernate: select customobjf0_.id as id0_, customobjf0_.keyName as keyName1_0_, customobjf0_.shortDesc as shortDesc1_0_, customobjf0_.longDesc as longDesc1_0_, customobjf0_.storageParam1 as storageP5_1_0_, customobjf0_.storageParam2 as storageP6_1_0_, customobjf0_.storageParam3 as storageP7_1_0_, customobjf0_.storageParam4 as storageP8_1_0_, customobjf0_.storageType as storageT9_1_0_ from know.customobjfieldtype customobjf0_ where customobjf0_.id=?
Hibernate: update know.customobjfieldtype set keyName=?, shortDesc=?, longDesc=?, storageParam1=?, storageParam2=?, storageParam3=?, storageParam4=?, storageType=? where id=?
Hibernate: update know.customobjfieldmeta set visibility=?, versionId=?, objType=?, versionOf=?, shortDesc=?, longDesc=?, fieldType=? where id=?
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility0_, customobjf0_.versionId as versionId0_, customobjf0_.objType as objType0_, customobjf0_.versionOf as versionOf0_, customobjf0_.shortDesc as shortDesc0_, customobjf0_.longDesc as longDesc0_, customobjf0_.fieldType as fieldType0_ from know.customobjfieldmeta customobjf0_ limit ?
Hibernate: select customobjf0_.id as id0_, customobjf0_.keyName as keyName1_0_, customobjf0_.shortDesc as shortDesc1_0_, customobjf0_.longDesc as longDesc1_0_, customobjf0_.storageParam1 as storageP5_1_0_, customobjf0_.storageParam2 as storageP6_1_0_, customobjf0_.storageParam3 as storageP7_1_0_, customobjf0_.storageParam4 as storageP8_1_0_, customobjf0_.storageType as storageT9_1_0_ from know.customobjfieldtype customobjf0_ where customobjf0_.id=?
Hibernate: update know.customobjfieldtype set keyName=?, shortDesc=?, longDesc=?, storageParam1=?, storageParam2=?, storageParam3=?, storageParam4=?, storageType=? where id=?
Hibernate: update know.customobjfieldmeta set visibility=?, versionId=?, objType=?, versionOf=?, shortDesc=?, longDesc=?, fieldType=? where id=?
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility0_, customobjf0_.versionId as versionId0_, customobjf0_.objType as objType0_, customobjf0_.versionOf as versionOf0_, customobjf0_.shortDesc as shortDesc0_, customobjf0_.longDesc as longDesc0_, customobjf0_.fieldType as fieldType0_ from know.customobjfieldmeta customobjf0_ limit ?
Hibernate: select customobjf0_.id as id0_, customobjf0_.keyName as keyName1_0_, customobjf0_.shortDesc as shortDesc1_0_, customobjf0_.longDesc as longDesc1_0_, customobjf0_.storageParam1 as storageP5_1_0_, customobjf0_.storageParam2 as storageP6_1_0_, customobjf0_.storageParam3 as storageP7_1_0_, customobjf0_.storageParam4 as storageP8_1_0_, customobjf0_.storageType as storageT9_1_0_ from know.customobjfieldtype customobjf0_ where customobjf0_.id=?
Hibernate: update know.customobjfieldmeta set visibility=?, versionId=?, objType=?, versionOf=?, shortDesc=?, longDesc=?, fieldType=? where id=?
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility0_, customobjf0_.versionId as versionId0_, customobjf0_.objType as objType0_, customobjf0_.versionOf as versionOf0_, customobjf0_.shortDesc as shortDesc0_, customobjf0_.longDesc as longDesc0_, customobjf0_.fieldType as fieldType0_ from know.customobjfieldmeta customobjf0_ limit ?
Is it possible the connection pool might be messing things up somehow? I think I'll try a different connection pool next.
query.setMaxResults(1);
then call
query.list();
query.list();
query.list();
query.list();
query.list();
query.list();
query.list();
I get the following. Note that now UPDATE is now also run on the customobjfieldtype object. This only happens if I use setMaxResults(1). If I don't call that method it will just update customobjfieldmeta a bunch of times before the 2nd query.list(). Now, with setMaxResults(1), it updates customobjfieldmeta after every update plus it updates customobjfieldtype twice.
This is just nonsensical. I've tried doing a clean remake from the hbm files and a clean rebuild of the entire project. It doesn't change anything.
DEBUG[2005-05-05 01:29:09,984] com.knowlist.list.main.Mai
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility0_, customobjf0_.versionId as versionId0_, customobjf0_.objType as objType0_, customobjf0_.versionOf as versionOf0_, customobjf0_.shortDesc as shortDesc0_, customobjf0_.longDesc as longDesc0_, customobjf0_.fieldType as fieldType0_ from know.customobjfieldmeta customobjf0_ limit ?
Hibernate: select customobjf0_.id as id0_, customobjf0_.keyName as keyName1_0_, customobjf0_.shortDesc as shortDesc1_0_, customobjf0_.longDesc as longDesc1_0_, customobjf0_.storageParam1
Hibernate: update know.customobjfieldmeta set visibility=?, versionId=?, objType=?, versionOf=?, shortDesc=?, longDesc=?, fieldType=? where id=?
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility0_, customobjf0_.versionId as versionId0_, customobjf0_.objType as objType0_, customobjf0_.versionOf as versionOf0_, customobjf0_.shortDesc as shortDesc0_, customobjf0_.longDesc as longDesc0_, customobjf0_.fieldType as fieldType0_ from know.customobjfieldmeta customobjf0_ limit ?
Hibernate: update know.customobjfieldmeta set visibility=?, versionId=?, objType=?, versionOf=?, shortDesc=?, longDesc=?, fieldType=? where id=?
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility0_, customobjf0_.versionId as versionId0_, customobjf0_.objType as objType0_, customobjf0_.versionOf as versionOf0_, customobjf0_.shortDesc as shortDesc0_, customobjf0_.longDesc as longDesc0_, customobjf0_.fieldType as fieldType0_ from know.customobjfieldmeta customobjf0_ limit ?
Hibernate: select customobjf0_.id as id0_, customobjf0_.keyName as keyName1_0_, customobjf0_.shortDesc as shortDesc1_0_, customobjf0_.longDesc as longDesc1_0_, customobjf0_.storageParam1
Hibernate: update know.customobjfieldmeta set visibility=?, versionId=?, objType=?, versionOf=?, shortDesc=?, longDesc=?, fieldType=? where id=?
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility0_, customobjf0_.versionId as versionId0_, customobjf0_.objType as objType0_, customobjf0_.versionOf as versionOf0_, customobjf0_.shortDesc as shortDesc0_, customobjf0_.longDesc as longDesc0_, customobjf0_.fieldType as fieldType0_ from know.customobjfieldmeta customobjf0_ limit ?
Hibernate: select customobjf0_.id as id0_, customobjf0_.keyName as keyName1_0_, customobjf0_.shortDesc as shortDesc1_0_, customobjf0_.longDesc as longDesc1_0_, customobjf0_.storageParam1
Hibernate: update know.customobjfieldtype set keyName=?, shortDesc=?, longDesc=?, storageParam1=?, storageParam2=?, storageParam3=?, storageParam4=?, storageType=? where id=?
Hibernate: update know.customobjfieldmeta set visibility=?, versionId=?, objType=?, versionOf=?, shortDesc=?, longDesc=?, fieldType=? where id=?
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility0_, customobjf0_.versionId as versionId0_, customobjf0_.objType as objType0_, customobjf0_.versionOf as versionOf0_, customobjf0_.shortDesc as shortDesc0_, customobjf0_.longDesc as longDesc0_, customobjf0_.fieldType as fieldType0_ from know.customobjfieldmeta customobjf0_ limit ?
Hibernate: select customobjf0_.id as id0_, customobjf0_.keyName as keyName1_0_, customobjf0_.shortDesc as shortDesc1_0_, customobjf0_.longDesc as longDesc1_0_, customobjf0_.storageParam1
Hibernate: update know.customobjfieldtype set keyName=?, shortDesc=?, longDesc=?, storageParam1=?, storageParam2=?, storageParam3=?, storageParam4=?, storageType=? where id=?
Hibernate: update know.customobjfieldmeta set visibility=?, versionId=?, objType=?, versionOf=?, shortDesc=?, longDesc=?, fieldType=? where id=?
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility0_, customobjf0_.versionId as versionId0_, customobjf0_.objType as objType0_, customobjf0_.versionOf as versionOf0_, customobjf0_.shortDesc as shortDesc0_, customobjf0_.longDesc as longDesc0_, customobjf0_.fieldType as fieldType0_ from know.customobjfieldmeta customobjf0_ limit ?
Hibernate: select customobjf0_.id as id0_, customobjf0_.keyName as keyName1_0_, customobjf0_.shortDesc as shortDesc1_0_, customobjf0_.longDesc as longDesc1_0_, customobjf0_.storageParam1
Hibernate: update know.customobjfieldmeta set visibility=?, versionId=?, objType=?, versionOf=?, shortDesc=?, longDesc=?, fieldType=? where id=?
Hibernate: select customobjf0_.id as id, customobjf0_.visibility as visibility0_, customobjf0_.versionId as versionId0_, customobjf0_.objType as objType0_, customobjf0_.versionOf as versionOf0_, customobjf0_.shortDesc as shortDesc0_, customobjf0_.longDesc as longDesc0_, customobjf0_.fieldType as fieldType0_ from know.customobjfieldmeta customobjf0_ limit ?
Is it possible the connection pool might be messing things up somehow? I think I'll try a different connection pool next.
ASKER
I got an answer. It's because I overrode one of the methods of the object. Apparently it compares all fields in the object when it pulls the object from the 1st level cache to determine the dirtiness of the object. It then flushes the object to the DB if it's different. Of course, it's not different, but the overridden method does return different values.
So, the fix is: don't override any methods that are generated for the base class of hibernate objects.
For read only pages, I can call:
Session s = ObjTypeDAO.getInstance().g etSession( );
s.setFlushMode(FlushMode.N EVER);
and that also prevents updates.
I think it's crazy that it works this way, but I'll just have to work around it.
Thanks for the help!
So, the fix is: don't override any methods that are generated for the base class of hibernate objects.
For read only pages, I can call:
Session s = ObjTypeDAO.getInstance().g
s.setFlushMode(FlushMode.N
and that also prevents updates.
I think it's crazy that it works this way, but I'll just have to work around it.
Thanks for the help!
Glad you sorted it out :-)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The exception is occured because you want to write to read-only object. The problem is to find where the codes that does this "updating". can you post your codes?
regards
Dave