-->
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: cache and cascade actions
PostPosted: Sun Sep 24, 2006 11:52 am 
Newbie

Joined: Sat Aug 12, 2006 5:16 am
Posts: 4
Hi,

I hope you can help me!
I use jbosscache as a 2nd level cache for hibernate entity manager.
My problem is that the cache does'nt take care of cascade actions. If i add or remove from a collection and merging the owning class the db state is ok, but the cache contains the old data. The facts:

Hibernate version:
jboss 4.0.4 GA
hibernate-3.2
JBossCache 1.4.0.GA

Mapping documents:
persistence config:
Code:
<persistence>
   <persistence-unit name="xxx">
      <jta-data-source>java:/PostgresDS</jta-data-source>
      <properties>
         <property name="hibernate.dialect"
            value="org.hibernate.dialect.PostgreSQLDialect" />
         <property name="hibernate.cache.provider_class"
            value="org.jboss.ejb3.entity.TreeCacheProviderHook" />
         <property name="hibernate.treecache.mbean.object_name"
            value="jboss.cache:service=TreeCache" />
         <!-- JDBC connection pool (use the built-in) -->
         <property name="hibernate.cache.use_query_cache"
            value="true" />
         <property name="hibernate.default_batch_fetch_size"
            value="10" />

         <!-- Echo all executed SQL to stdout -->
         <property name="hibernate.show_sql">true</property>
      </properties>
   </persistence-unit>
</persistence>


cache config:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<server>
   <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar" />

   <mbean code="org.jboss.cache.TreeCache"
      name="jboss.cache:service=TreeCache">

      <depends>jboss:service=Naming</depends>
      <depends>jboss:service=TransactionManager</depends>
      <attribute name="NodeLockingScheme">PESSIMISTIC</attribute>
      <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
      <attribute name="CacheMode">LOCAL</attribute>
      <attribute name="UseReplQueue">false</attribute>
      <attribute name="ReplQueueInterval">0</attribute>
      <attribute name="ReplQueueMaxElements">0</attribute>
      <attribute name="LockAcquisitionTimeout">15000</attribute>
      <attribute name="EvictionPolicyConfig">
         <config>
            <attribute name="wakeUpIntervalSeconds">5</attribute>
            <!-- Cache wide default -->
            <region name="/_default_"
               policyClass="org.jboss.cache.eviction.LRUPolicy">
               <attribute name="maxNodes">10000</attribute>
               <attribute name="timeToLiveSeconds">10000</attribute>
            </region>
         </config>
      </attribute>
      <attribute name="UseRegionBasedMarshalling">false</attribute>

   </mbean>
</server>
   






mapping:
Code:
/**
* Felhasznalok generated by hbm2java
*/
@Entity
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@Table(name = "felhasznalok", schema = "privilegiumok", uniqueConstraints = { @UniqueConstraint(columnNames = { "f_nev" }) })
public class Felhasznalok implements java.io.Serializable {

   // Fields

   private int uid;

.
.
.
   private List<Kedvencek> kedvenceks = new ArrayList<Kedvencek>(0);


   // Property accessors
   @Id
   @Column(name = "uid", unique = true, nullable = false, insertable = true, updatable = true)
   public int getUid() {
      return this.uid;
   }
.
.
.

   @OneToMany(fetch = FetchType.LAZY, mappedBy = "felhasznalok")
   @OrderBy("id")
   @Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
   @org.hibernate.annotations.Cascade( {
         org.hibernate.annotations.CascadeType.ALL,
         org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
   public List<Kedvencek> getKedvenceks() {
      return this.kedvenceks;
   }

   public void setKedvenceks(List<Kedvencek> kedvenceks) {
      this.kedvenceks = kedvenceks;
   }

}



Code:
/**
* Kedvencek generated by hbm2java
*/
@Entity
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@Table(name = "kedvencek", schema = "privilegiumok", uniqueConstraints = {})
@org.hibernate.annotations.GenericGenerator(name = "SEQ_GEN", strategy = "sequence", parameters = { @Parameter(name = "sequence", value = "privilegiumok.kedvencek_k_index_seq") })
public class Kedvencek implements java.io.Serializable {

   // Fields

   private int KIndex;


   private Felhasznalok felhasznalok;

   

   // Property accessors
   @Id
   @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN")
   @Column(name = "k_index", unique = true, nullable = false, insertable = true, updatable = true)
   public int getKIndex() {
      return this.KIndex;
   }

.
.
.


   @ManyToOne(cascade = {}, fetch = FetchType.LAZY)
   @JoinColumn(name = "uid", unique = false, nullable = false, insertable = true, updatable = true)
   public Felhasznalok getFelhasznalok() {
      return this.felhasznalok;
   }

   public void setFelhasznalok(Felhasznalok felhasznalok) {
      this.felhasznalok = felhasznalok;
   }

}



Code between sessionFactory.openSession() and session.close():
Kedvencek kedvencek = new Kedvencek();
kedvencek.setFelhasznalok(felhasznalo);
kedvencek.setId(Integer.parseInt(i.getId()));
kedvencek.setName(i.getValue());
felhasznalo.getKedvenceks().add(kedvencek);
felhasznalokService.merge(felhasznalo);

Full stack trace of any exception that occurs:
There's no exception! Persisiting works fine. But my cache does not update itself! The "Felhasznalok" class's "Kedvencek" collection contains the same data in the cache before merging the entity. DB state is correct. (for adding and deleting too )


Name and version of the database you are using:
postgresql 8[/code]


Last edited by laszlo.fogas on Tue Sep 26, 2006 1:18 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 26, 2006 5:27 am 
Newbie

Joined: Sat Aug 12, 2006 5:16 am
Posts: 4
some interesting information on this topic:

http://forum.hibernate.org/viewtopic.php?t=956952

lazlo


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 02, 2006 8:08 am 
Newbie

Joined: Sat Aug 12, 2006 5:16 am
Posts: 4
What's your opinion? Should I provide more info? Should i post it to JIRA?

I would appriciate your help!

regards, lazlo


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.