-->
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.  [ 1 post ] 
Author Message
 Post subject: Caching collections, enumerations.
PostPosted: Wed Mar 09, 2011 9:10 am 
Newbie

Joined: Thu Jan 13, 2011 8:20 am
Posts: 3
Hi all,

I use to Ehcache as second level cache provider. Everything look great, but...
For one collection hibernate always hit the database, other collections work correctly.
Hibernate version 3.2.7.ga.
Entity from collection:
Code:
@Entity
@Table(name = "TD_TABLE")
@SequenceGenerator(name = "SEQUENCE_GENERATOR", sequenceName = "SEQ_TABLE")
@Proxy(lazy = false)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = Region.REGION_RW)
public class MyClass extends SomeClass {

   private static final long serialVersionUID = 1L;
   
   @Column(name = "NAME")
   @Enumerated(EnumType.STRING)
   private SomeEnum enum;

   public SomeEnum getEnum() {
      return enum;
   }

   public void setEnum(SomeEnum enum) {
      this.enum = enum;
   }

   @Override
   public boolean equals(Object o) {
      if(o == null)return false;
      MyClass r = (MyClass) o;
      return r.getEnum().name().equals(this.getEnum().name());
   }
   
   @Override
   public int hashCode() {
      return this.getId().intValue(); //database id
   }
}

Collection: (other collections in this class work great)
Code:
...
    @OneToMany(cascade = CascadeType.ALL)
    @JoinColumn(name = "ELEMENT__ID")
    @Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
    @Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = Region.REGION_RW)
    @org.hibernate.annotations.Fetch(FetchMode.JOIN)
    private Set<MyClass> myClass;
...


Into SomeEnum I have enums as well:
Code:
public enum SomeEnum {
     name_enum(SomeEnum_1.NAME_1, SomeEnum_2.NAME_2, ...)
     ...
}

Have someone of you idea why hibernate don't hit cache for this collection?
Did I something wrong with enumeration?


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

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.