我创建了抽象通用的@MappedSuperclass。这适用于select,insert查询。但是hibernate不会生成更新查询。我不明白泛型课有什么问题。
@MappedSuperclass
@Cacheable
public abstract class Category<T extends Category> {
private Integer id;
private String name;
private T parent;
private List<T> children;
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
public Integer getId() {
return id;
}
//omitted
}
@Entity
@Table(name = "staticPageCategory")
public class StaticPageCategory extends Category<StaticPageCategory> implements Serializable {
@ManyToOne
@Override
public StaticPageCategory getParent() {
return super.getParent();
}
@OrderBy("ordering asc, name asc")
@OneToMany(mappedBy = "parent")
@Override
public List<StaticPageCategory> getChildren() {
return super.getChildren();
}
}
问题是为什么hibernate忽略了getCurrentSession()。update(myCategory);