Hibernate 错误总结

1.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class
问题:主要出现在表映射上面,没有关联起来
1> 在配置文件(applicationContext.xml)里没有加入com.bask.model.PromotionItem会出现这个问题
2> 如下:
@Entity
@Table(name="promotion")
public class Promotion implements Serializable {
	@OneToMany(mappedBy="promotion",cascade=CascadeType.ALL)  
	private List<PromotionItem> promotionItem;
   //略.....
}
//缺少@Entity
public class PromotionItem implements Serializable {
	@ManyToOne(cascade={CascadeType.MERGE,CascadeType.PERSIST},fetch=FetchType.LAZY)
    private Promotion promotion;
  //略.....
}


注意在PromotionItem表上没有:
@Entity
@Table(name="promotion_item") 

你可能感兴趣的:(java,Hibernate,bean,xml)