如何解决JPA:抽象模式未知

时间:2015-12-06 01:45:49

标签: java mysql jpa

这是我的实体类

@Entity

public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int userId;
private String email;

当我查询数据库时,我得到以下例外:

The abstract schema type 'User' is unknown. The state field path 'u.email' cannot be resolved to a valid type.] with root cause

这是我的查询

TypedQuery<User> query = em.createQuery("select u from User u where u.email=:email", User.class); query.setParameter("email", email); return query.getResultList();

我是否已在persistance.xml中明确注册我的User类?

我在某个地方出错了吗?

编辑:::我正在使用eclipse链接,以下是我的persistance.xml

<persistence-unit name="Myname" transaction-type="RESOURCE_LOCAL">
<exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
        <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/mydb"/>
        <property name="javax.persistence.jdbc.user" value="smval"/>
        <property name="javax.persistence.jdbc.password" value="smval"/>
        <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>

        <property name="eclipselink.ddl-generation" value="create-and-extend-tables" />
        <property name="eclipselink.ddl-generation.output-mode" value="database" />
        <property name="eclipselink.logging.level" value="SEVERE"/>  
        <property name="hibernate.archive.autodetection" value="class, hbm"/>

        <property name="hibernate.hbm2ddl.auto" value="validate" />

    </properties>
</persistence-unit>

0 个答案:

没有答案