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.  [ 2 posts ] 
Author Message
 Post subject: Optimistic locking & JBoss
PostPosted: Fri Oct 27, 2006 10:12 am 
Newbie

Joined: Tue Oct 25, 2005 6:04 am
Posts: 10
Hibernate 3.1, Jboss 4.0.3SP1

I'm trying to get optimistic locking to work, but with no luck.

I'm using Jboss cache 1.4. Configuration of cache and session factory:
Code:
<server>
    <mbean code="org.jboss.cache.TreeCache" name="jboss.har:service=HarSecondLevelCache">
       <attribute name="CacheMode">LOCAL</attribute>
       <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute>
      <attribute name="NodeLockingScheme">OPTIMISTIC</attribute>
      <attribute name="EvictionPolicyConfig">
         <config>
            <attribute name="wakeUpIntervalSeconds">5</attribute>
            <!--  Cache wide default -->
            <region name="/_default_">
               <attribute name="maxNodes">50000</attribute>
               <attribute name="timeToLiveSeconds">1000</attribute>
               <!-- Maximum time an object is kept in cache regardless of idle time -->
               <attribute name="maxAgeSeconds">600</attribute>
            </region>
         </config>
      </attribute>
   </mbean>
   <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Chip_HB_LOCAL">
      <attribute name="DatasourceName">java:/jdbc/ChipDS_LOCAL</attribute>
      <attribute name="Dialect">org.hibernate.dialect.PostgreSQLDialect</attribute>
      <attribute name="SessionFactoryName">java:/hibernate/ChipHB_LOCAL</attribute>
      <attribute name="CacheProviderClass">org.jboss.hibernate.cache.DeployedTreeCacheProvider</attribute>
      <attribute name="DeployedTreeCacheObjectName">jboss.har:service=HarSecondLevelCache</attribute>
        <attribute name="ReflectionOptimizationEnabled">false</attribute>
      <attribute name="MaxFetchDepth">1</attribute>
      <attribute name="ScanForMappingsEnabled">true</attribute>
      <attribute name="StatGenerationEnabled">true</attribute>
      <attribute name="ShowSqlEnabled">false</attribute>
      <!--attribute name="Hbm2ddlAuto">update</attribute-->
   </mbean>
</server>


Here is my class that I expect to be optimistically locked:
Code:
/*
* $Id$
*/
package hr.chipoteka.erp.data;

import java.util.Date;

/**
* @hibernate.class lazy = "false" dynamic-update = "true"
*/
public abstract class Analitika extends DataObject {
...

   /**
    * @hibernate.version type = "timestamp"
    */
   public Date getTs() {
      return ts;
   }

   public void setTs(Date ts) {
      this.ts = ts;
   }
}


and one subclass:

Code:
package hr.chipoteka.erp.data.artikl;

import hr.chipoteka.erp.data.Analitika;
import hr.chipoteka.erp.data.SlimDataObject;
import hr.chipoteka.erp.data.osoba.PoslovniPartner;
import hr.chipoteka.erp.data.osoba.adresa.Drzava;

import java.util.*;

/**
* @hibernate.union-subclass lazy = "false" dynamic-update = "true"
*/
public class Artikl extends Analitika implements SlimDataObject {
...
}


Generated hbm.xml looks like this:
Code:
?xml version="1.0" encoding="UTF-8"?>

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

<hibernate-mapping

>

    <class
            name="hr.chipoteka.erp.data.Analitika"
            lazy="false"
            dynamic-update="true"
    >

...

        <version
            name="ts"
            column="ts"
            type="timestamp"
        />

...

    <union-subclass
        name="hr.chipoteka.erp.data.artikl.Artikl"
            dynamic-update="true"
            lazy="false"
    >

...

    </union-subclass>
...
   </class>   

</hibernate-mapping>


I use hibernate within stateless session beans.

When running some HQL queries, I stop jboss at a breakpoint and check locks in the database (postgres):


Code:
select pg_class.relname,pg_locks.locktype, page, tuple, transaction, pid, mode, granted from pg_class,pg_locks where pg_class.relfilenode=pg_locks.relation and pid = 31761 order by relname;
    relname    | locktype | page | tuple | transaction |  pid  |      mode       | granted
---------------+----------+------+-------+-------------+-------+-----------------+---------
artikl        | relation |      |       |     5378326 | 31761 | AccessShareLock | t
(1 rows)


What am I doing wrong?


Top
 Profile  
 
 Post subject: AccesShareLock
PostPosted: Thu Oct 04, 2007 10:39 am 
Newbie

Joined: Thu Oct 04, 2007 10:20 am
Posts: 1
Hi All, I am too facing the same problem with Postgres and Hibernate. Please let me know if there is a solution to this


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.