Link to home
Start Free TrialLog in
Avatar of HappyEngineer
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.CustomObjFieldMeta 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.ServletHandler.handle(ServletHandler.java:590) >11> /know/:
java.lang.UnsupportedOperationException: Can't write to a readonly object
      at org.hibernate.cache.ReadOnlyCache.lock(ReadOnlyCache.java:43)
      at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:69)
      at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
      at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
      at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:48)
      at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:659)
      at org.hibernate.impl.SessionImpl.prepareQueries(SessionImpl.java:833)
      at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:823)
      at org.hibernate.impl.SessionImpl.list(SessionImpl.java:782)
      at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
      at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:603)
      at com.knowlist.list.hh.dao.CustomObjFieldMetaDAO.findByFieldType(CustomObjFieldMetaDAO.java:51)
      at com.knowlist.list.hh.CustomObj.getField(CustomObj.java:141)
      at com.knowlist.list.main.MainPage.service(MainPage.java:45)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:427)
      at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:496)
      at org.mortbay.jetty.servlet.Dispatcher.dispatch(Dispatcher.java:263)
      at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:157)
      at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:670)
      at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:637)
      at org.apache.jsp.index_jsp._jspService(index_jsp.java:45)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:427)
      at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:496)
      at org.mortbay.jetty.servlet.Dispatcher.dispatch(Dispatcher.java:263)
      at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:157)
      at org.mortbay.jetty.servlet.Default.handleGet(Default.java:312)
      at org.mortbay.jetty.servlet.Default.service(Default.java:232)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:427)
      at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:822)
      at com.knowlist.hibernate.HibernateSessionFilter.doFilter(HibernateSessionFilter.java:54)
      at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:813)
      at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:298)
      at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:813)
      at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:494)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:569)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
      at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:624)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1434)
      at org.mortbay.http.HttpServer.service(HttpServer.java:896)
      at org.mortbay.http.HttpConnection.service(HttpConnection.java:814)
      at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:981)
      at org.mortbay.http.HttpConnection.handle(HttpConnection.java:831)
      at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)
      at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:366)
      at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)

I cannot figure out where the stupid object is being updated (if anywhere).
Avatar of suprapto45
suprapto45
Flag of Singapore image

Mm....

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
Avatar of HappyEngineer
HappyEngineer

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.getInstance().getSession();
                Query query = s.getNamedQuery("com.knowlist.list.hh.CustomObjFieldMeta.findByObjTypeAndFieldType");
                query.setInteger("objType",100);
                query.setInteger("fieldType",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.
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">CustomObjFieldMeta_id_seq</param></generator>
            </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.hh.CustomObjFieldType" column="fieldType" not-null="true"/>

      </class>
      
      
      <query name="com.knowlist.list.hh.CustomObjFieldMeta.findByObjType">
            <![CDATA[
                  select cofm
                  from
                        com.knowlist.list.hh.CustomObjFieldMeta as cofm,
                        com.knowlist.list.hh.CustomObjFieldType as coft
                  where
                        cofm.objType=:objType
                        and cofm.fieldType=coft
                  order by
                        cofm.fieldType
            ]]>
      </query>
      
      <query name="com.knowlist.list.hh.CustomObjFieldMeta.findByObjTypeAndFieldType">
            <![CDATA[
                  from com.knowlist.list.hh.CustomObjFieldMeta as cofm
                  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
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
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.
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.
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.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.hibernate.Query;
import org.hibernate.Session;

import com.knowlist.list.hh.HibernateInit;
import com.knowlist.list.hh.dao.CustomObjFieldMetaDAO;
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.getInstance().getSession();
            Query query = s.getNamedQuery("com.knowlist.list.hh.CustomObjFieldMeta.findByObjTypeAndFieldType");
            query.setInteger("objType",100);
            query.setInteger("fieldType",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.closeCurrentThreadSessions();
        }
      }
}




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.MainPageTest.service(MainPageTest.java:29)(MainPageTest.java29): 1
DEBUG[2005-05-04 19:50:53,625] com.knowlist.list.main.MainPageTest.service(MainPageTest.java:34)(MainPageTest.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.MainPageTest.service(MainPageTest.java:36)(MainPageTest.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.MainPageTest.service(MainPageTest.java:38)(MainPageTest.java38): 4
DEBUG[2005-05-04 19:51:03,046] com.knowlist.list.main.MainPageTest.service(MainPageTest.java:29)(MainPageTest.java29): 1
DEBUG[2005-05-04 19:51:03,046] com.knowlist.list.main.MainPageTest.service(MainPageTest.java:34)(MainPageTest.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.MainPageTest.service(MainPageTest.java:36)(MainPageTest.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.MainPageTest.service(MainPageTest.java:38)(MainPageTest.java38): 4
DEBUG[2005-05-04 19:51:04,203] com.knowlist.list.main.MainPageTest.service(MainPageTest.java:29)(MainPageTest.java29): 1
DEBUG[2005-05-04 19:51:04,203] com.knowlist.list.main.MainPageTest.service(MainPageTest.java:34)(MainPageTest.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.MainPageTest.service(MainPageTest.java:36)(MainPageTest.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.MainPageTest.service(MainPageTest.java:38)(MainPageTest.java38): 4
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
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?
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.getInstance().getSession();
            Query query = s.createQuery("from com.knowlist.list.hh.CustomObjFieldMeta as cofm");
            query.list();
        } catch(Exception e) {
            throw new ServletException(e);
        } finally {
            _RootDAO.closeCurrentThreadSessions();
        }
       
        try {
            Session s = CustomObjFieldMetaDAO.getInstance().getSession();
            Query query = s.createQuery("from com.knowlist.list.hh.CustomObjFieldMeta as cofm");
            query.list();
        } catch(Exception e) {
            throw new ServletException(e);
        } finally {
            _RootDAO.closeCurrentThreadSessions();
        }
      }

The following DOES cause updates:
      protected void service(HttpServletRequest req, HttpServletResponse res)
                  throws ServletException, IOException
      {
        try {
            Session s = CustomObjFieldMetaDAO.getInstance().getSession();
            Query query = s.createQuery("from com.knowlist.list.hh.CustomObjFieldMeta as cofm");
            query.list();
            query.list();
        } catch(Exception e) {
            throw new ServletException(e);
        } finally {
            _RootDAO.closeCurrentThreadSessions();
        }
      }


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.getInstance().load(getFieldTypeId());
    }
    public java.lang.String getShortDesc() {
        String shortDesc = super.getShortDesc();
        if(shortDesc==null || "".equals(shortDesc))
            return getFieldType().getShortDesc();
        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.
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.MainPageTest.service(MainPageTest.java:35)(MainPageTest.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.
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().getSession();
            s.setFlushMode(FlushMode.NEVER);
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
Avatar of suprapto45
suprapto45
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial