Java SE上的JPA:对象:entity.Customer@5e80188f不是已知的实体类型

前端之家收集整理的这篇文章主要介绍了Java SE上的JPA:对象:entity.Customer@5e80188f不是已知的实体类型前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我跟着

https://glassfish.java.net/javaee5/persistence/persistence-example.html

在Java SE环境中测试JPA.
在Eclipse中,我:

>创建了一个新的JPA(2.1)项目;
>在options-> JPA->持久类管理中,我选择了“自动发现带注释的类”,而不是“必须在persistence.xml中列出带注释的类”.

我成功导入了zip文件(Client.java Customer.java Order.java)中的树Java类,并修改了persistence.xml文件以满足我的需要.但是在尝试执行main时我得到以下错误.

[EL Info]: 2013-10-18 17:37:54.749--ServerSession(263489307)--EclipseLink,version: Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5
[EL Info]: connection: 2013-10-18 17:37:55.34--ServerSession(263489307)--file:/home/caterpillar/workspace/JPA_Java_SE/build/classes/_JPA_Java_SE login successful
[EL Warning]: Metamodel: 2013-10-18 17:37:55.359--The collection of Metamodel types is empty. Model classes may not have been found during entity search for Java SE and some Java EE container managed persistence units.  Please verify that your entity classes are referenced in persistence.xml using either 

persistence.xml中

MysqL://localhost:3306/test?useUnicode=true&characterEncoding=utf8"/>
            MysqL.jdbc.Driver"/>
        

项目目录树:

$tree
.
├── build
│   └── classes
│       ├── client
│       │   └── Client.class
│       ├── entity
│       │   ├── Customer.class
│       │   └── Order.class
│       └── Meta-INF
│           └── persistence.xml
├── sql
│   ├── tables_derby.sql
│   └── tables_oracle.sql
└── src
    ├── client
    │   └── Client.java
    ├── entity
    │   ├── Customer.java
    │   └── Order.java
    └── Meta-INF
        └── persistence.xml

10 directories,10 files

所有clases代码http://glassfish.dev.java.net/javaee5/persistence/JPASE.zip的avaible示例文件相同

最佳答案
persistence.xml中缺少下一行:

此行的位置如下例所示:

原文链接:https://www.f2er.com/mysql/433687.html

猜你在找的MySQL相关文章