我试图用datanucleus jdo(和neodatis作为数据存储)制作一些基本的持久类。
我有以下三个课程(从教程中复制)
库存.java
@PersistenceCapable
public class Inventory {
@PrimaryKey
String name = null;
Set<Product> products = new HashSet();
public Inventory(String name)
{
this.name = name;}
public Set<Product> getProducts() {return products;}
}
产品.java
@PersistenceCapable
public class Product {
@PrimaryKey
@Persistent(valueStrategy=IdGeneratorStrategy.INCREMENT)
long id;
String name = null;
String description = null;
double price = 0.0;
public Product(String name, String desc, double price)
{
this.name = name;
this.description = desc;
this.price = price;}
}
和 book.java
@PersistenceCapable
public class Book extends Product {
String author=null;
String isbn=null;
String publisher=null;
public Book(String name, String desc, double price, String author,
String isbn, String publisher)
{
super(name,desc,price);
this.author = author;
this.isbn = isbn;
this.publisher = publisher;
}
}
自从构建项目时,所有这些都应该得到正确的增强,我得到了这个:
(...)
gen 31, 2013 12:10:14 AM org.datanucleus.enhancer.DataNucleusEnhancer main
INFO: DataNucleus Enhancer (version 3.2.0.m2) for API "JDO" using JRE "1.7"
ENHANCED (PersistenceCapable) : minchiabbasta.Book
ENHANCED (PersistenceCapable) : minchiabbasta.Inventory
ENHANCED (PersistenceCapable) : minchiabbasta.Product
(...)
但
运行应用程序时,持久性管理器会很好地启动,但是当它尝试使某些东西持久化时,会抛出此异常
org.datanucleus.api.jdo.exceptions.ClassNotPersistenceCapableException: The class
"minchiabbasta.Inventory" is not persistable. This means that it either hasnt been
enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is
hidden by an unenhanced version), or the Meta-Data/annotations for the class are not
found.
我无法弄清楚为什么,有人可以给我一个提示吗?