- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我找不到我的错误在哪里,我没有映射我的类,但对我来说一切都应该没问题..但不是。
谁能帮我找到它?
org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: com.bytecode.entities.Event.categorytagit[com.bytecode.entities.Categorytagit]
at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1068)
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:600)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:541)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:324)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
package com.bytecode.entities;
// Generated 29/03/2011 12:15:48 by Hibernate Tools 3.2.1.GA
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
* Event generated by hbm2java
*/
@Entity
@Table(name = "event", catalog = "tagit")
public class Event implements java.io.Serializable {
private Integer id;
private User user;
private String name;
private Date iniEventDate;
private Date iniInscDate;
private Date endInscDate;
private String urlPicture;
private Integer idEventoFacebook;
private String description;
private Integer places;
private Integer lottery;
private String street;
private String city;
private Integer idMainEvent;
private Set<Tag> tags = new HashSet<Tag>(0);
private Set<Presentparticipants> presentparticipantses = new HashSet<Presentparticipants>(0);
private Set<User> users = new HashSet<User>(0);
private Set<Categorytagit> categorytagit = new HashSet<Categorytagit>(0);
public Event() {
}
public Event(User user, String name, Date iniEventDate, String description, String street, String city) {
this.user = user;
this.name = name;
this.iniEventDate = iniEventDate;
this.description = description;
this.street = street;
this.city = city;
}
public Event(User user, String name, Date iniEventDate, Date iniInscDate, Date endInscDate, String urlPicture, Integer idEventoFacebook, String description, Integer places, Integer lottery, String street, String city, Integer idMainEvent, Set<Tag> tags, Set<Presentparticipants> presentparticipantses, Set<User> users, Set<Categorytagit> categorytagit) {
this.user = user;
this.name = name;
this.iniEventDate = iniEventDate;
this.iniInscDate = iniInscDate;
this.endInscDate = endInscDate;
this.urlPicture = urlPicture;
this.idEventoFacebook = idEventoFacebook;
this.description = description;
this.places = places;
this.lottery = lottery;
this.street = street;
this.city = city;
this.idMainEvent = idMainEvent;
this.tags = tags;
this.presentparticipantses = presentparticipantses;
this.users = users;
this.categorytagit = categorytagit;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "idOrganizer", nullable = false)
public User getUser() {
return this.user;
}
public void setUser(User user) {
this.user = user;
}
@Column(name = "name", nullable = false, length = 55)
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "iniEventDate", nullable = false, length = 19)
public Date getIniEventDate() {
return this.iniEventDate;
}
public void setIniEventDate(Date iniEventDate) {
this.iniEventDate = iniEventDate;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "iniInscDate", length = 19)
public Date getIniInscDate() {
return this.iniInscDate;
}
public void setIniInscDate(Date iniInscDate) {
this.iniInscDate = iniInscDate;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "endInscDate", length = 19)
public Date getEndInscDate() {
return this.endInscDate;
}
public void setEndInscDate(Date endInscDate) {
this.endInscDate = endInscDate;
}
@Column(name = "urlPicture")
public String getUrlPicture() {
return this.urlPicture;
}
public void setUrlPicture(String urlPicture) {
this.urlPicture = urlPicture;
}
@Column(name = "idEventoFacebook")
public Integer getIdEventoFacebook() {
return this.idEventoFacebook;
}
public void setIdEventoFacebook(Integer idEventoFacebook) {
this.idEventoFacebook = idEventoFacebook;
}
@Column(name = "description", nullable = false, length = 65535)
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
@Column(name = "places")
public Integer getPlaces() {
return this.places;
}
public void setPlaces(Integer places) {
this.places = places;
}
@Column(name = "lottery")
public Integer getLottery() {
return this.lottery;
}
public void setLottery(Integer lottery) {
this.lottery = lottery;
}
@Column(name = "street", nullable = false)
public String getStreet() {
return this.street;
}
public void setStreet(String street) {
this.street = street;
}
@Column(name = "city", nullable = false, length = 55)
public String getCity() {
return this.city;
}
public void setCity(String city) {
this.city = city;
}
@Column(name = "idMainEvent")
public Integer getIdMainEvent() {
return this.idMainEvent;
}
public void setIdMainEvent(Integer idMainEvent) {
this.idMainEvent = idMainEvent;
}
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "event")
public Set<Tag> getTags() {
return this.tags;
}
public void setTags(Set<Tag> tags) {
this.tags = tags;
}
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "event")
public Set<Presentparticipants> getPresentparticipantses() {
return this.presentparticipantses;
}
public void setPresentparticipantses(Set<Presentparticipants> presentparticipantses) {
this.presentparticipantses = presentparticipantses;
}
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(name = "eventuser", catalog = "tagit", joinColumns = {
@JoinColumn(name = "idEvent", nullable = false, updatable = false)}, inverseJoinColumns = {
@JoinColumn(name = "idUser", nullable = false, updatable = false)})
public Set<User> getUsers() {
return this.users;
}
public void setUsers(Set<User> users) {
this.users = users;
}
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(name = "eventcategory", catalog = "tagit", joinColumns = {
@JoinColumn(name = "idEvent", nullable = false, updatable = false)}, inverseJoinColumns = {
@JoinColumn(name = "idCategory", nullable = false, updatable = false)})
public Set<Categorytagit> getCategorytagit() {
return this.categorytagit;
}
public void setCategorytagit(Set<Categorytagit> categorytagit) {
this.categorytagit = categorytagit;
}
}
我的 hibernate.cfg:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql:xxxx</property>
<property name="hibernate.connection.username">xxxxxxxxx</property>
<property name="hibernate.connection.password">xxxxxxxxxxxx</property>
<property name="hibernate.current_session_context_class">thread</property>
<!-- Connection pool C3P0 -->
<property name="hibernate.c3p0.acquire_increment">2</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">100</property>
<property name="hibernate.c3p0.timeout">20</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">60</property>
<!-- To show sql output on the screen -->
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<!-- Mapping the entities -->
<mapping class="com.bytecode.entities.Categorytagit"/>
<mapping class="com.bytecode.entities.Likes"/>
<mapping class="com.bytecode.entities.Categoryfacebook"/>
<mapping class="com.bytecode.entities.Accountconfirmation"/>
<mapping class="com.bytecode.entities.User"/>
<mapping class="com.bytecode.entities.Tag"/>
<mapping class="com.bytecode.entities.PresentparticipantsId"/>
<mapping class="com.bytecode.entities.Company"/>
<mapping class="com.bytecode.entities.Event"/>
<mapping class="com.bytecode.entities.Presentparticipants"/>
</session-factory>
</hibernate-configuration>
更新:
package com.bytecode.entities;
// Generated 29/03/2011 12:15:48 by Hibernate Tools 3.2.1.GA
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
/**
* Categorytagit generated by hbm2java
*/
@Entity
@Table(name = "categorytagit", catalog = "tagit")
public class Categorytagit implements java.io.Serializable {
private Integer id;
private String name;
private Set<Likes> likeses = new HashSet<Likes>(0);
private Set<Categoryfacebook> categoryfacebooks = new HashSet<Categoryfacebook>(0);
private Set<Event> events = new HashSet<Event>(0);
public Categorytagit() {
}
public Categorytagit(String name) {
this.name = name;
}
public Categorytagit(String name, Set<Likes> likeses, Set<Categoryfacebook> categoryfacebooks, Set<Event> events) {
this.name = name;
this.likeses = likeses;
this.categoryfacebooks = categoryfacebooks;
this.events = events;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(name = "name", nullable = false, length = 55)
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "categorytagit")
public Set<Likes> getLikeses() {
return this.likeses;
}
public void setLikeses(Set<Likes> likeses) {
this.likeses = likeses;
}
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "categorytagit")
public Set<Categoryfacebook> getCategoryfacebooks() {
return this.categoryfacebooks;
}
public void setCategoryfacebooks(Set<Categoryfacebook> categoryfacebooks) {
this.categoryfacebooks = categoryfacebooks;
}
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(name = "eventcategory", catalog = "tagit", joinColumns = {
@JoinColumn(name = "idCategory", nullable = false, updatable = false)}, inverseJoinColumns = {
@JoinColumn(name = "idEvent", nullable = false, updatable = false)})
public Set<Event> getEvents() {
return this.events;
}
public void setEvents(Set<Event> events) {
this.events = events;
}
}
最佳答案
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "idOrganizer", nullable = false)
public User getUser() {
return this.user;
}
我认为您缺少与您的专栏匹配的目标实体类。
@ManyToOne(targetEntity = User.class)
关于java - hibernate : Use of @OneToMany or @ManyToMany targeting an unmapped class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5475463/
我有如下三个实体相关:A(一对多) B(一对多) C我如何从 C 中获取基于 A->id 的所有记录?????? 最佳答案 类似于: $entityManager = $this->getDoctri
代码之间有什么区别? @LazyCollection(LazyCollectionOption.FALSE) @OneToMany(mappedBy = "siteesTypeSite", casca
public class ClientEntity { @Id @Column(name="id", nullable = false, unique = true) @Gen
现在,我明白这是不可能的,但我无法想象这是一个从未遇到过的问题。 我在不同的 PU 中有两个实体。我想从一个外键到另一个。我想知道谁已经遇到过这个问题,他们是否找到了一个好的解决方案? 最佳答案 Ec
我有两个与 OneToMany - ManyToOne 映射关联的类。当我选择父实体时,它也会选择子实体,但是分配给它的所有子实例都是每个父实例,而不是分配相关实例。 采购入口.java @Entit
我在 OneToMany 字段的持久性方面遇到了麻烦。这是两个简化的类 我是用来做测试的。 public class User implements Serializable { ... privat
我有一个持久化实体,它有一个 @OneToMany另一个实体的列表,我需要列表顺序才能由用户编辑,这非常有效。我可以完全重新排序内存中的 java 列表,当我 save() 对象时,链接表中的链接顺序
我是 Hibernate 的新手,正在尝试一些应该很容易的事情,但我无法让它工作。 有两个表,一个人和一个地址。一个人可以有一个或多个地址,即:一个 OneToMany 映射。当我尝试将相同的地址添加
我有双向、一对多和多对一的关系。说,一个公司有很多人,一个人有一个公司,所以,在公司中, @OneToMany(mappedBy = "company", fetch = FetchType.EAGE
在JPA中设置一对多关系时如何设置外键的列名? 我想将“items_id”的名称更改为“item_id” @OneToMany private List items; 我尝试了以下注释但没有成功: @
我有2张 table : 第一个是“人”: person_id, 人名 第二个是“PersonsGraphs”: person_id1, person_id2, 关系类型 我正在寻找一种建立“家谱”的
请帮我解决这个问题。我尝试了很多组合,但似乎没有任何效果。我正在尝试使用注释实现 hibernate 映射,但在保存我的父对象及其子对象期间,我注意到正在调用更新语句而不是插入语句。 我有两个彼此具有
我是 JPA 新手。假设我有这两个实体: //Imports @Entity @Table(name="article", schema = "sch_client") public class Ar
我有使用 Hibernate 归档 @ManyToOne 关系的代码。我有两个类 Package 和 Address。在 Address 中,我希望有唯一的条目,其中每个地址都与其他地址有所不同。然后
在订单表中插入时遇到此错误 org.springframework.dao.InvalidDataAccessApiUsageException: detached entity passed to
我是 Hibernate 新手,我正在尝试在 Person 和 Vehicle 类之间建立 OneToMany/ManyToOne 双向关系。在我的示例中,一个人可以拥有许多车辆,而一辆车辆只属于一个
我们是 JPA 新手,尝试建立一个非常简单的一对多关系,其中名为 Message 的 pojo 可以具有由名为 GROUP_ASSOC 的联接表定义的整数组 id 列表。 。这是 DDL: CREAT
我在使用 JPA 时遇到了一些小问题。我有三个表(OTHER 表与此处无关,但我添加它只是为了解释为什么存在没有 PK 的表 USERS): ADDRESS id (PK) user_id (FK)
请帮我解决这个问题。我尝试了很多组合,但似乎没有任何效果。我正在尝试使用注释实现 hibernate 映射,但在保存我的父对象及其子对象期间,我注意到正在调用更新语句而不是插入语句。 我有两个彼此具有
我的 Task 实体表示为: @Entity @Getter @NoArgsConstructor public class Task { @Id @GeneratedValue(st
我是一名优秀的程序员,十分优秀!