Eclipselink:从实体生成表失败
我在从实体生成JPA表方面遇到了一些问题(在Eclipse4.3上使用Dali和eclipselink 2.5.0)。 我有一本实体书,它有几个属性,其中有一个Eclipselink:从实体生成表失败,eclipse,jpa,dali,Eclipse,Jpa,Dali,我在从实体生成JPA表方面遇到了一些问题(在Eclipse4.3上使用Dali和eclipselink 2.5.0)。 我有一本实体书,它有几个属性,其中有一个Category属性。 类别也是一个实体,具有名称、描述和自动生成的id。关系为 图书M:1分类 以下是相关的代码片段 这本书 @Entity public class Book implements Serializable { // bi-directional many-to-one association to Cate
Category
属性。
类别也是一个实体,具有名称、描述和自动生成的id。关系为
图书M:1分类
以下是相关的代码片段
这本书
@Entity
public class Book implements Serializable {
// bi-directional many-to-one association to Category
@ManyToOne
@JoinColumn(name = "CATEGORY_ID", nullable = false)
private Category category;
// other attributes, constructors and methods...
}
类别
@Entity
public class Category implements Serializable {
// bi-directional one-to-many association to Book
@OneToMany(mappedBy = "category", cascade = { CascadeType.PERSIST }, fetch = FetchType.LAZY)
private Set<Book> books;
// other attributes, constructors and methods...
}
类别被注释为@Entity
,它也包含在persistence.xml文件中。
我的问题是,是什么导致了这个问题?我忘了什么?因为就我所知,类别是一个实体
@StaticMetamodel(Book.class)
public class Book_ {
public static volatile SingularAttribute<Book, Category> category;
// ....
}
@StaticMetamodel(Category.class)
public class Category_ {
public static volatile SetAttribute<Category, Book> books;
// ....
}
Exception in thread "main" Local Exception Stack:
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b):
org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader:
org.eclipse.persistence.dynamic.DynamicClassLoader@154e92c
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018]
(Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [bookstore] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b):
org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class name.kipchumba.obby.bookstore.entities.Book]
uses a non-entity [class name.kipchumba.obby.bookstore.entities.Category] as target entity in the relationship attribute [field category].
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:107)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.buildEntityManagerFactory(Main.java:94)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.execute(Main.java:80)
at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.main(Main.java:68)