-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: flush exception when i saveorupdate PO
PostPosted: Sat Nov 01, 2003 6:27 am 
Beginner
Beginner

Joined: Sat Nov 01, 2003 6:14 am
Posts: 30
i have two PO : user 1 - 1 forumuser , i don't use one-to-one relation in mapping ,just use forumuser many-to-one user

in my business:

1.load user and forumuser , set the user to forumuser
2.in UI , edit some infos of them
3.update them in logic layer.

i can successfully save user info when i use flush. but in next step when i save the forumuser in the same way , something gone wrong. the exception like below:

Code:
ERROR [2003-11-01 18:21:58,664] net.sf.hibernate.AssertionFailure  - An AssertionFailure occured - this may indicate a bug in Hibernate
java.lang.UnsupportedOperationException: Can't write to a readonly object
   at net.sf.hibernate.cache.ReadOnlyCache.release(ReadOnlyCache.java:39)
   at net.sf.hibernate.impl.ScheduledUpdate.afterTransactionCompletion(ScheduledUpdate.java:36)
   at net.sf.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:459)
   at net.sf.hibernate.impl.SessionImpl.disconnect(SessionImpl.java:2958)
   at net.sf.hibernate.impl.SessionImpl.close(SessionImpl.java:438)
   at net.magician.util.HibernateSessionFactory.closeSession(HibernateSessionFactory.java:60)
   at net.magician.business.forumnuke.dao.hibernate.ForumUserDAOHibernateImpl.saveForumUser(ForumUserDAOHibernateImpl.java:59)
   at net.magician.business.forumnuke.helper.ForumUserHelper.saveOrUpdateForumUser(ForumUserHelper.java:63)
   at net.magician.business.forumnuke.action.SaveUserProfileAction.execute(SaveUserProfileAction.java:51)
   at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
   at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
   at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
   at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
   at net.magician.business.forumnuke.util.ForumNukeAuthFilter.doFilter(ForumNukeAuthFilter.java:46)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
   at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
   at java.lang.Thread.run(Thread.java:534)


and this is my code and mapping file:

User.java

Code:
package net.magician.business.usermanager.views;

import java.util.Date;
/**
* 用户对象
*
* @hibernate.class table="User" dynamic-insert="true" dynamic-update="true"
* @hibernate.jcs-cache usage="read-write"
*/
public class User
{
   /**
    * 用户ID
    */
   private int userID;

   /**
    * 用户名
    */
   private String userName;

   /**
    * 注册日期
    */
   private Date registerDate;

   /**
    * 用户EMAIL
    */
   private String email;

   /**
    * QQ号码
    */
   private String QQ;

   /**
    * MSN号码
    */
   private String MSN;

   /**
    * 性别,TURE为男,FALSE为女
    */
   private boolean sex;

   /**
    * 来自
    */
   private String location;

   /**
    * 密码
    */
   private String passWord;

   /**
    * 用户取回密码时提示问题
    */
   private String passWordQuestion;

   /**
    * 用户取回密码时提示问题答案
    */
   private String passWordQuestionAnswer;

   public User()
   {

   }

   /**
    * @hibernate.id generator-class="native" unsaved-value="0"
    */
   public int getUserID()
   {
      return userID;
   }

   public void setUserID(int aUserID)
   {
      userID = aUserID;
   }

   /**
    * @hibernate.property length="16" not-null="true"
    */
   public String getUserName()
   {
      return userName;
   }

   public void setUserName(String aUserName)
   {
      userName = aUserName;
   }

   /**
    * @hibernate.property
    */
   public java.util.Date getRegisterDate()
   {
      return registerDate;
   }

   public void setRegisterDate(java.util.Date aRegisterDate)
   {
      registerDate = aRegisterDate;
   }

   /**
    * @hibernate.property length="50" not-null="true"
    */
   public String getEmail()
   {
      return email;
   }

   public void setEmail(String aEmail)
   {
      email = aEmail;
   }

   /**
    * @hibernate.property length="15"
    */
   public String getQQ()
   {
      return QQ;
   }

   public void setQQ(String aQQ)
   {
      QQ = aQQ;
   }

   /**
    * @hibernate.property length="50"
    */
   public String getMSN()
   {
      return MSN;
   }

   public void setMSN(String aMSN)
   {
      MSN = aMSN;
   }

   /**
    * @hibernate.property
    */
   public boolean getSex()
   {
      return sex;
   }

   public void setSex(boolean aSex)
   {
      sex = aSex;
   }
   
   /**
    * @hibernate.property length="16"
    */
   public String getLocation()
   {
      return location;
   }

   public void setLocation(String string)
   {
      location = string;
   }

   /**
    * @hibernate.property length="50"
    */
   public String getPassWordQuestion()
   {
      return passWordQuestion;
   }

   public void setPassWordQuestion(String aPassWordQuestion)
   {
      passWordQuestion = aPassWordQuestion;
   }

   /**
    * @hibernate.property length="50"
    */
   public String getPassWordQuestionAnswer()
   {
      return passWordQuestionAnswer;
   }

   public void setPassWordQuestionAnswer(String aPassWordQuestionAnswer)
   {
      passWordQuestionAnswer = aPassWordQuestionAnswer;
   }

   /**
    * @hibernate.property length="32" not-null="true"
    */
   public String getPassWord()
   {
      return passWord;
   }

   public void setPassWord(String aPassWord)
   {
      passWord = aPassWord;
   }
}


ForumUser.java

Code:
package net.magician.business.forumnuke.views;

import java.util.Date;
/**
* 论坛用户,与用户信息一一对应
*
* @hibernate.class table="ForumUser" dynamic-insert="true" dynamic-update="true" polymorphism="explicit"
* @hibernate.jcs-cache usage="read-write"
*/
public class ForumUser extends SimpleForumUser
{   
   /**
    * 该论坛用户是否可用
    */
   private boolean active;

   /**
    * 是否隐身登录
    */
   private boolean invisible;

   /**
    * 是否接收悄悄话
    */
   private boolean acceptPriMsg;

   /**
    * 是否自动登录
    */
   private boolean autoLogin;

   /**
    * 有人回帖后是否邮件通知
    */
   private boolean emailNotice;

   /**
    * 是否在帖子后附上签名
    */
   private boolean showSign;

   /**
    * 最后访问时间
    */
   private Date lastVisit;

   public ForumUser()
   {

   }

   /**
    * @hibernate.property
    */
   public java.util.Date getLastVisit()
   {
      return lastVisit;
   }

   public void setLastVisit(java.util.Date aLastVisit)
   {
      lastVisit = aLastVisit;
   }

   /**
    * @hibernate.property
    */
   public boolean getActive()
   {
      return active;
   }

   public void setActive(boolean aActive)
   {
      active = aActive;
   }

   /**
    * @hibernate.property
    */
   public boolean getInvisible()
   {
      return invisible;
   }

   public void setInvisible(boolean aInvisible)
   {
      invisible = aInvisible;
   }

   /**
    * @hibernate.property
    */
   public boolean getAcceptPriMsg()
   {
      return acceptPriMsg;
   }

   public void setAcceptPriMsg(boolean aAcceptPriMsg)
   {
      acceptPriMsg = aAcceptPriMsg;
   }

   /**
    * @hibernate.property
    */
   public boolean getAutoLogin()
   {
      return autoLogin;
   }

   public void setAutoLogin(boolean aAutoLogin)
   {
      autoLogin = aAutoLogin;
   }
   
   /**
    * @hibernate.property
    */
   public boolean getEmailNotice()
   {
      return emailNotice;
   }

   /**
    * @hibernate.property
    */
   public boolean getShowSign()
   {
      return showSign;
   }

   public void setEmailNotice(boolean b)
   {
      emailNotice = b;
   }

   public void setShowSign(boolean b)
   {
      showSign = b;
   }
}


User.hbm.xml

Code:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
    <class
        name="net.magician.business.usermanager.views.User"
        table="User"
        dynamic-update="true"
        dynamic-insert="true"
    >

        <jcs-cache usage="read-write" />

        <id
            name="userID"
            column="userID"
            type="int"
            unsaved-value="0"
        >
            <generator class="native">
            </generator>
        </id>

        <property
            name="userName"
            type="java.lang.String"
            update="true"
            insert="true"
            column="userName"
            length="16"
            not-null="true"
        />

        <property
            name="registerDate"
            type="java.util.Date"
            update="true"
            insert="true"
            column="registerDate"
        />

        <property
            name="email"
            type="java.lang.String"
            update="true"
            insert="true"
            column="email"
            length="50"
            not-null="true"
        />

        <property
            name="QQ"
            type="java.lang.String"
            update="true"
            insert="true"
            column="QQ"
            length="15"
        />

        <property
            name="MSN"
            type="java.lang.String"
            update="true"
            insert="true"
            column="MSN"
            length="50"
        />

        <property
            name="sex"
            type="boolean"
            update="true"
            insert="true"
            column="sex"
        />

        <property
            name="location"
            type="java.lang.String"
            update="true"
            insert="true"
            column="location"
            length="16"
        />

        <property
            name="passWordQuestion"
            type="java.lang.String"
            update="true"
            insert="true"
            column="passWordQuestion"
            length="50"
        />

        <property
            name="passWordQuestionAnswer"
            type="java.lang.String"
            update="true"
            insert="true"
            column="passWordQuestionAnswer"
            length="50"
        />

        <property
            name="passWord"
            type="java.lang.String"
            update="true"
            insert="true"
            column="passWord"
            length="32"
            not-null="true"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-User.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>


ForumUser.hbm.xml

Code:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
    <class
        name="net.magician.business.forumnuke.views.ForumUser"
        table="ForumUser"
        polymorphism="explicit"
        dynamic-update="true"
        dynamic-insert="true"
    >

        <jcs-cache usage="read-write" />

        <id
            name="forumUserID"
            column="forumUserID"
            type="int"
            unsaved-value="0"
        >
            <generator class="native">
            </generator>
        </id>

        <property
            name="lastVisit"
            type="java.util.Date"
            update="true"
            insert="true"
            column="lastVisit"
        />

        <property
            name="active"
            type="boolean"
            update="true"
            insert="true"
            column="active"
        />

        <property
            name="invisible"
            type="boolean"
            update="true"
            insert="true"
            column="invisible"
        />

        <property
            name="acceptPriMsg"
            type="boolean"
            update="true"
            insert="true"
            column="acceptPriMsg"
        />

        <property
            name="autoLogin"
            type="boolean"
            update="true"
            insert="true"
            column="autoLogin"
        />

        <property
            name="emailNotice"
            type="boolean"
            update="true"
            insert="true"
            column="emailNotice"
        />

        <property
            name="showSign"
            type="boolean"
            update="true"
            insert="true"
            column="showSign"
        />

        <many-to-one
            name="user"
            class="net.magician.business.usermanager.views.User"
            cascade="none"
            outer-join="true"
            update="true"
            insert="true"
            column="userID"
            not-null="true"
        />

        <property
            name="signature"
            type="java.lang.String"
            update="true"
            insert="true"
            column="signature"
            length="500"
        />

        <property
            name="postCount"
            type="int"
            update="true"
            insert="true"
            column="postCount"
        />

        <property
            name="title"
            type="java.lang.String"
            update="true"
            insert="true"
            column="title"
            length="100"
        />

        <many-to-one
            name="face"
            class="net.magician.business.views.Pic"
            cascade="all"
            outer-join="true"
            update="true"
            insert="true"
            column="faceID"
            not-null="false"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-ForumUser.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>


any one can tell me what's wrong with my code?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 01, 2003 8:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Since ReadOnlyCache is being called, I would assume that you are -actually- using usage="read-only" somewhere. I don't think these are the actual mappings being used at runtime,


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 02, 2003 9:20 pm 
Beginner
Beginner

Joined: Sat Nov 01, 2003 6:14 am
Posts: 30
gavin wrote:
Since ReadOnlyCache is being called, I would assume that you are -actually- using usage="read-only" somewhere. I don't think these are the actual mappings being used at runtime,


:)

it's just the exactly xml file i used in project

but the forumuser has a many-to-one relation is cached by "read-only"

i found it yestoday

thanks for your kind reply!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.