I followed this great article
http://www.itsolut.com/chrismusings/2009/06/12/visiting-ehcache/?dzref=192797But I have some problem when trying to add the entity to the cache by adding the line
Code:
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
I get an error;
Type mismatch: cannot convert from Cache to AnnotationAny idea what I missed? Thanks
My code looks like that
Code:
package com.test.hibernate;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;
import net.sf.ehcache.*;
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Table(name = "keyword", catalog = "test")
public class Keyword implements java.io.Serializable {
// Fields
private Integer id;
private String keyword;
private Integer type;
// Constructors
/** default constructor */
public Keyword() {
}
/** full constructor */
public Keyword(String keyword, Integer type) {
this.keyword = keyword;
this.type = type;
}
// Property accessors
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "ID", unique = true, nullable = false)
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(name = "Keyword", nullable = false, length = 256)
public String getKeyword() {
return this.keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
@Column(name = "Type", nullable = false)
public Integer getType() {
return this.type;
}
public void setType(Integer type) {
this.type = type;
}
}