我试图用datanucleus jdo(和neodatis作为数据存储区)制作一些基本的持久类。
我有以下三个类(从教程中复制)
inventory.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;}
}
Product.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
(...)
BUT
运行应用程序时,Persistence管理器启动很好,但是当它试图使某些东西持久化时会抛出此异常
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.
我无法弄明白为什么,有人可以给我一个暗示吗?
答案 0 :(得分:0)
多年后,症状相同。在我的情况下,我得到了相同的错误和堆栈跟踪3个建议。然而对我来说,实际问题不是那些,而是我在Eclipse和Google上运行App Engine设置未检查&#34;启用本地HRD支持&#34;和&#34;用户数据核心JDO / JPA访问数据存储区&#34;。一旦我检查了这些项目,我就可以坚持使用与以前相同的代码,并且没有得到上述错误。
答案 1 :(得分:0)
如果您的增强器在Eclipse中保存文件时运行,请注意它是否在Eclipse控制台中得到增强。我注意到我的Eclipse安装忘记每隔一段时间增强一次类。如果它忘了,它会将类部署到未增强的GAE。只需重新启动Eclipse即可。
答案 2 :(得分:-1)
试一试:
@Entity // use this annotation
public class MyClass
{
@Id
long id;
@Basic
@Convert(converter=URLStringConverter.class)
URL url;