您的位置:首页 > 编程语言 > Java开发

解决JPA 注解开发 Myeclipse 2017 C9 出现没有发现持久化单元中定义的名为 问题

2017-12-17 00:00 387 查看
摘要: Description Resource Path Location Type
No generator named "ordersTime" is defined in the persistence unit Orders.java /hibernate_maven_JPQL/src/main/java/cn/leelei/hibernate/entity line 27 JPA Problem
描述资源路径位置类型
没有发电机持久化单元中定义的名为“”命令。

目录结构:



注解 @GeneratedValue(generator = "xxxxx"):虽然有叉叉 但不影响结果



解决方法:



代码示例如下 orm.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"> 
<entity class="cn.leelei.web.entity.Users">
<table name="users">
</table>
<attributes>
<id name="id">
<generated-value strategy="TABLE" />
</id>
<basic name="userName">
<column name="uname" length="100" />
</basic>
<basic name="passWord">
<column length="100" />
</basic>
</attributes>
</entity>

代码示例如下 persistence.xml 文件:

<?xml version="1.0" encoding="UTF-8" ?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> 
<persistence-unit name="jpa" transaction-type="RESOURCE_LOCAL">
<mapping-file>META-INF/orm.xml</mapping-file>
<!-- 添加实体对象 -->
<!-- <class>cn.leelei.web.entity.Users</class>
<class>cn.leelei.web.entity.Students</class>
<class>cn.leelei.web.entity.Orders</class> -->

<properties>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.username" value="xxxx" />
<property name="hibernate.connection.password" value="xxxx" />
<property name="hibernate.connection.url" value="jdbc:mysql://xxxxxx:3306/xxxx" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
<!-- 连接池 -->
<property name="hibernate.c3p0.acquire_increment" value="2"></property>
<property name="hibernate.c3p0.max_size" value="10"></property>
<property name="hibernate.c3p0.min_size" value="5"></property>
<property name="hibernate.c3p0.idle_test_period" value="3000"></property>

</properties>
</persistence-unit>
</persistence>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐