-->
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: Using a timestamp field without automatic versioning?
PostPosted: Mon May 23, 2005 9:59 am 
Beginner
Beginner

Joined: Tue Nov 09, 2004 9:48 am
Posts: 23
Hibernate version:
Hibernate 2

Guys,

I'd like to use a timestamp field without using automatic versioning. In other words, I have a need for a timestamp to be updated whenever anything happens to a particular object and its assocations. The <timestamp/> field works perfectly for this, but I get the StaleObjectStateException exceptions, which I do not want or need.

Is there a way to turn off automatic versioning, yet still have the timestamp column updated properly?

Thanks!

Jbwiv


Top
 Profile  
 
 Post subject: optimistic-lock="none" doesn't work
PostPosted: Mon May 23, 2005 10:26 am 
Beginner
Beginner

Joined: Tue Nov 09, 2004 9:48 am
Posts: 23
I tried setting this at this class level, but get the following message:

Code:
[java] 10:24:10,145 ERROR HibernateDAOFactory:38 - net.sf.hibernate.MappingException: optimistic-lock attribute not supported for joined-subclass mappings: aero.timco.approval.document.Document


Here's the entire mapping file (note, with optimistic-lock="none" still there...

Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
          "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
          "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
   <class name="aero.timco.approval.document.Document" table="document" optimistic-lock="none">
      <meta attribute="implements">
         aero.timco.approval.Identifiable
      </meta>
      <meta attribute="class-code">
      public Long getId() {
          return getDid();
       }

       public void setId(Long id) {
          setDid(id);
       }
       public int getNumberApprovals() {
          return approvals.size();
       }
       public int getNumberAccepted() {
         int accepted = 0;
         java.util.Iterator it = approvals.iterator();
         while(it.hasNext()) {
            if(((Approval)it.next()).getApproved() == 1) {
            accepted++;
            }
         }
         return accepted;
      }
      public int getNumberRejected() {
         int rejected = 0;
         java.util.Iterator it = approvals.iterator();
         while(it.hasNext()) {
            if(((Approval)it.next()).getApproved() == 2) {
               rejected++;
            }
         }
         return rejected;
      }
      public int getNumberPending() {
         int pending = 0;
         java.util.Iterator it = approvals.iterator();
         while(it.hasNext()) {
            if(((Approval)it.next()).getApproved() == 0) {
               pending++;
            }
         }
         return pending;
      }
      </meta>
      <meta attribute="class-code">static final long serialVersionUID = 0L;</meta>
      <id name="did" column="did" type="long">
         <generator class="native"/>
      </id>
      <timestamp column="last_updated" name="lastUpdated"/>
      <property name="name" column="name" type="string" length="50" not-null="true"/>
      <property name="description" column="description" type="text"/>
      <property name="createTime" column="create_time" type="timestamp" not-null="true"/>
      <property name="dueTime" column="due_time" type="timestamp"/>
      <!--<property name="lastUpdated" column="last_updated" type="timestamp"/>
      --><property name="submitted" column="submitted" type="boolean" not-null="true"/>
      <property name="stopOnRejection" column="stop_on_rejection" type="boolean" not-null="true"/>
      <many-to-one name="author" class="aero.timco.approval.document.User" cascade="none">
         <meta attribute="finder-method">findByAuthorID</meta>
         <column name="author_id" not-null="true"/>
      </many-to-one>
      <many-to-one name="documentType" class="aero.timco.approval.document.DocumentType" cascade="none">
         <column name="document_type_id" not-null="true"/>
      </many-to-one>
      <!-- set lazy to true when done testing and put accessors to notes in dao -->
      <set name="notes" lazy="false" inverse="true" cascade="all">
         <key column="document_id"/>
         <one-to-many class="aero.timco.approval.document.Note"/>
      </set>
      <!-- set lazy to true when done testing and put accessors to attachments in dao -->
      <set name="attachments" lazy="false" inverse="true" cascade="all">
         <key column="document_id"/>
         <one-to-many class="aero.timco.approval.document.Attachment"/>
      </set>
      <!-- set lazy to true when done testing and put accessors to attachments in dao -->
      <set name="approvals" lazy="false" inverse="true" cascade="all">
         <meta attribute="scope-field">protected</meta>
         <key column="document_id"/>
         <one-to-many class="aero.timco.approval.document.Approval"/>
      </set>
      <joined-subclass name="aero.timco.approval.document.CapexDocument" table="capex_document">
         <key column="capex_id"/>
         <property name="npv" column="npv" type="big_decimal"/>
      </joined-subclass>
   </class>
</hibernate-mapping>
<!--
   signoffs
-->


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 24, 2005 4:44 pm 
Beginner
Beginner

Joined: Tue Nov 09, 2004 9:48 am
Posts: 23
I'm still at a loss here....has noone faced a simlar need!?

Thanks,
Jbwiv


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.