2

我试图用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.

我无法弄清楚为什么,有人可以给我一个提示吗?

4

3 回答 3

0

多年后,同样的症状。就我而言,我在堆栈跟踪上遇到了同样的错误和 3 条建议。然而对我来说,真正的问题不是这些,而是​​我在 Eclipse 和 Google | 上运行的。App Engine 设置未选中“启用本地 HRD 支持”和“用户数据核 JDO/JPA 以访问数据存储区”。一旦我检查了这些项目,我就能够使用与以前相同的代码进行持久化,并且没有收到上述错误。

于 2015-04-20T02:14:26.820 回答
0

如果您的增强器在 Eclipse 中保存文件时运行,请注意查看它是否在 Eclipse 控制台中进行了增强。我注意到我安装的 Eclipse 偶尔会忘记增强类。如果它忘记了,它会将类部署到未增强的 GAE。只需重新启动 Eclipse 即可。

于 2015-08-06T02:34:46.437 回答
-1

试试看:

@Entity // use this annotation 
public class MyClass
{
@Id
long id;

@Basic
@Convert(converter=URLStringConverter.class)
URL url;
于 2013-01-30T23:44:14.753 回答