hibernate JPA 单表树形结构 注解配置。(已解决)

[code="java"]
ublic class Category implements java.io.Serializable {

@Id 
@GeneratedValue(strategy=IDENTITY)
@Column(name="CAT_ID", unique=true, nullable=false)
 private Integer id;

@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="CAT_PARENT_ID")
 private Category parent;

@Column(name="CAT_NAME", nullable=false, length=50)
 private String name;

@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="Category")
 private Set<Category> children = new HashSet<Category>(0);

//省略getter/setter

}
[/code]
代码如上,请问但是在@OneToMany的部分总是 org.hibernate.AnnotationException: mappedBy reference an unknown target entity property 错误.
单表的无限级树形目录结构.
第一次使用注解方式,还望各位大拿赐教.


自己结了,看了半天jpa v1.0规范还是因为对mappedBy理解出了差错.
[code=Java]

public class Category implements java.io.Serializable {

@Id 
@GeneratedValue(strategy=IDENTITY)
@Column(name="CAT_ID", unique=true, nullable=false)
 private Integer id;

@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="CAT_PARENT_ID")
 private Category parent;

@Column(name="CAT_NAME", nullable=false, length=50)
 private String name;

@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="Category")//[color=#FF0000]这个里因该更改为parent[/color]
 private Set<Category> children = new HashSet<Category>(0);

//省略getter/setter

}
[/code]

这。。。就出来了

mappedBy="Category" 是对应属性名,你类中没有Category属性,你这应该是mappedBy="parent"