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?