hibernate4多对多Use of @OneToMany or @ManyToMany targeting an unmapped class:

出错之后先查了一下,大家有

@Entity

导错包的,不过我这里没错

import javax.persistence.Entity;

就是这个

还有的是没有注解@Table的,我这里也是没问题的

我这个问题就比较厉害了,忘记把另一个类加到hibernate的配置文件去了

添加上之后,问题解决

原文地址:https://www.cnblogs.com/jnhs/p/11439486.html

时间: 2024-08-30 09:42:29

hibernate4多对多Use of @OneToMany or @ManyToMany targeting an unmapped class:的相关文章

JPA OneToOne,OneToMany和ManyToMany的mappedBy属性

在四种关联关系OneToOne,OneToMany,ManyToOne和ManyToMany中,只有OneToOne.OneToMany和ManyToMany这三中关联关系有mappedBy属性. 下面是mappedBy属性在java doc里边的解释: the field that owns the relationship. Required unless the relationship is unidirectional. 翻译成中文是: 拥有关联关系的域,如果关系是单向的就不需要. 那

Django基础四<二>(OneToMany和 ManyToMany,ModelForm)

上一篇博文是关于setting.py文件数据库的配置以及model与数据库表关系,实现了通过操作BlogUser,把BlogUser的信息存入后台数据库中.实际开发中有许多东西是相互联系的,除了数据的显示和存储之外,我们也要理清各种数据对象之间的关系.Django框架定义了三种关系模型: OneToOne OneToOne(一对一) :这种对应关系最简单,就是字面的意思一对一.django用OneToOneField来表示这种对应关系. OneToMany OneToMany(一对多) :也是常

码农小汪-Hibernate学习8-hibernate关联关系注解表示@OneToMany mappedBy @ManyToMany @JoinTable

近期我也是有点郁闷,究竟是程序中处理关联关系.还是直接使用外键处理关联关系呢?这个的说法不一致!程序中处理这样的关联关系的话.自己去维护这样的约束.这样的非常乐观的一种做法!或者是直接在数据库中处理这样的直接的外键关联,悲观的做法!刚刚看到个帖子.有的公司表中一个外键都没得.直接在程序中处理这样的关联关系.假设在Hibernate中处理外键关系的话.我们首先得有个主表的对象吧,然后在创建外键.感觉有点啰嗦.为啥不直接操作呢! 我仅仅要晓得你这个Id是外键即可了.各有各的说法.我想你也在思考这个问

Configure One-to-Many(配置一对多关系)【Code-First系列】

现在,我们将学习怎么配置一对多的关系. Visit Entity Relationship section to understand how EF manages one-to-one, one-to-many, and many-to-many relationships between the entities. Note: You do not need to configure for one-to-many relationships either using DataAnnotat

spring jpa ManyToMany 理解和使用

1.java和jpa 中所有的关系都是单向的.这个关系数据库不同,关系数据库,通过外键定义并查询,使得反向查询总是存在的. 2.JPA还定义了一个OneToMany关系,它与ManyToMany关系类似,但反向关系(如果已定义)是ManyToOne关系. OneToMany与JPA中ManyToMany关系的主要区别在于,ManyToMany总是使用中间关系连接表来存储关系, OneToMany可以使用连接表或者目标对象的表引用中的外键源对象表的主键. @OneToMany(cascade =

spring4+springmvc+springdataJPA+hibernate4整合懒加载问题

摘要 第一个问题 解决办法 第二个问题 解决办法 摘要 本文主要是为了解决"spring4+springmvc+springdataJPA+hibernate4整合",注解了OneToMany.ManyToOne,并配置了懒加载,然后报错的问题 第一个问题 org.hibernate.LazyInitializationException: could not initialize proxy - no Session at 解决办法: 在web.xml中,配置springSevlet

Entity Framework Code-First(13):Configure Many-to-Many

Configure Many-to-Many relationship: Here, we will learn how to configure Many-to-Many relationship between the Student and Course entity classes. Student can join multiple courses and multiple students can join one course. Visit Entity Relationship 

Entity Framework Code-First(12):Configure One-to-Many

Configure One-to-Many Relationship: Here, we will learn how to configure One-to-Many relationship between two entities in code-first. Take an example of Student and Standard (grade) entities where one Standard can include many Students. So the relati

Hibernate-----4、Hibernate配置文件

一.创建Configuration对象 Configuration实例的唯一作用是创建SessionFactory实例:若映射定义文件在类加载路径中,则可用addResource()方法来添加映射定义文件 3种配置Hibernate方式: 使用hibernate.properties作为配置文件(\project\etc\hibernate.properties) Configuration cfg = new Configuration(); // 多次调用addResource方法,添加映射