http://alinazh.blog.51cto.com/5459270/1279354
错误一
org.hibernate.AnnotationException:
Collection has neither generic type or OneToMany.targetEntity() defined: com.hibernate.SubStation.bays
错误解决方法
org.hibernate.AnnotationException: Collection has neither generic type or OneToMany.targetEntity() defined: org.svse.org.model.Order.orderItems
在用annotation做数据库映射一对多和多对一的时候要注意:因为这个问题只有在用annotation的时候才有,用xml文件的时候就没有在一对多关系映射中
一的一方直接写Set就可以不用指定相应的元素类型!!
请 检查orderItems这个属性是否使用了泛型,如:Set<OrderItem>.
如 果未使用泛型,请在OneToMany注释中使用targetEntity指定元素的类型
错误二
org.hibernate.AnnotationException:
mappedBy reference an unknown target entity property: com.hibernate.Bay.group in com.hibernate.SubStation.bays
错误解决方法
在用annotation做数据库映射一对多和多对一的时候要注意:
@OneToMany(mappedBy = "
news_type", cascade = CascadeType.ALL,fetch = FetchType.LAZY) 这里的mappedBy 要对应
@ManyToOne
@JoinColumn(name="news_type", nullable=true, insertable = true, updatable = true)
private NewsType newsType;的
NewsType对象名,也就是newsType而不是字段名news_type。
错误三
node to traverse cannot be null!
出现这种问题是因为HQL语句出现问题,引起内部查询对象为空,无法处理为空值引起的。解决方法,检查HQL语句(尤其是关键字)。
分享到:
相关推荐
基于HIBERNATE 操作表的关系练习例子
Spring data jpa 多表联查 一对多的关系和操作多表的操作步骤 客户:一家公司 联系人:这家公司的员工
spring jpa 对其进一步一对多的了解 ,spring jpa 对其进一步一对多的了解
博文链接:https://llying.iteye.com/blog/220809
onetomany-hibernate在myeclipse下的使用开发hibernate程序
• Single Table per Class Hierarchy Strategy: the <subclass> element in Hibernate 每个类层次结构一张表 • Joined Subclass Strategy: the <joined-subclass> element in Hibernate 连接的子类策略 @...
NULL 博文链接:https://tgwall163.iteye.com/blog/1277750
hibernate对象三状态及OneToOne&OneToMany&ManyToMany讲解,代码示例,数据库示例!非常全面
javax.persistence.OneToMany.class javax.persistence.OneToOne.class javax.persistence.OptimisticLockException.class javax.persistence.OrderBy.class javax.persistence.OrderColumn.class javax/persistence...
NULL 博文链接:https://tianjun309.iteye.com/blog/695332
JPA_OneToMany学习教程JPA_OneToMany学习教程JPA_OneToMany学习教程JPA_OneToMany学习教程
一对多关系的 Hibernate 注释
使用MySql示例的带有Hibernate的Spring Data JPA 该项目使用MySql Example描述了带有Spring Data JPA和Hibernate的Spring Boot示例。 描述 该项目显示了存储在MySql数据库中的用户列表。 使用以下端点,可以实现...
“#跟踪狐狸”“#跟踪狐狸”“#跟踪狐狸”“#跟踪狐狸”“#跟踪狐狸”“#跟踪狐狸”“#跟踪狐狸”“#跟踪狐狸”“#跟踪狐狸”“#跟踪狐狸”
targetEntity = org.hibernate.test.annotations.manytomany.Employee.class, cascade = {CascadeType.PERSIST, CascadeType.MERGE} ) @JoinTable( name = "EMPLOYER_EMPLOYEE", joinColumns = {@JoinColumn...
* 9.increnment 插入数据的时候hibernate会给主键添加一个自增的主键,但是一个hibernate实例就维护一个计数器,所以在多个实例运行的时候不能使用这个方法。 * 例:@GeneratedValue(generator = ...
oneToMany-OneToOne-search,xml方式、注解方式实现一对一查询、一对多查询,、注解方式实现一对一查询、一对多查询、注解方式实现一对一查询、一对多查询
EJB基本知识介绍。如OneToOne,OneToMany等经典实例推荐
NULL 博文链接:https://tgwall163.iteye.com/blog/1280912
是hibernate框架实现1对1 1对多 多对多的源代码 用eclipse+myeclipse实现的