Hibernate4 复合主键使用Ehcahe无效呢

penweizgx 15-07-24
              

Hibernate4 中得实体配置如下,但查询的时候无效果,非复合主键的实体是可以正常进入缓存的。

*/
@Embeddable
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE,region="com.kmp.business.entity.StudentClassesPK")
public class StudentClassesPK implements Serializable{
private static final long serialVersionUID = 8086967036014159916L;

@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name =
"student_id",referencedColumnName="id",nullable=true)
private Student student;

@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name =
"classes_id",referencedColumnName="id",nullable=true )
private Classes classes;



@Entity
@Table(name="T_ClassesStudent")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE,region=
"com.kmp.business.entity.StudentClasses")
public class StudentClasses extends BaseEntity{
private static final long serialVersionUID = -6300584354851171783L;

@EmbeddedId
StudentClassesPK pk = new StudentClassesPK();