【发布时间】:2012-06-09 22:52:31
【问题描述】:
我正在使用 flex、blazeds、hibernate jpa、tomcat 和 mysql。 这是我开始项目时面临的问题:
05.06.2012 22:33:29.459 INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.4.0.GA
05.06.2012 22:33:29.479 INFO org.hibernate.cfg.Environment - Hibernate 3.3.2.GA
05.06.2012 22:33:29.482 INFO org.hibernate.cfg.Environment - hibernate.properties not found
05.06.2012 22:33:29.487 INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
05.06.2012 22:33:29.493 INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
05.06.2012 22:33:29.645 INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.1.0.GA
05.06.2012 22:33:29.650 INFO org.hibernate.ejb.Version - Hibernate EntityManager 3.4.0.GA
这是我在 src/META-INF 下的 persistence.xml 文件:
<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="consultant_db">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.adobe.demo.domain.Permission</class>
<class>com.adobe.demo.domain.Role</class>
<class>com.adobe.demo.domain.User</class>
<properties>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost/consultant_db" />
<property name="hibernate.connection.username" value="root" />
<property name="hibernate.connection.password" value="" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
<property name="hibernate.connection.pool_size" value="6" />
<property name="hibernate.connection.autoReconnect" value="true" />
<property name="hibernate.generate_statistics" value="false" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.use_sql_comments" value="false" />
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
但如果我删除该行:<class>com.adobe.demo.domain.User</class>
将创建其他 2 个表。
我该怎么办?
【问题讨论】:
-
到底是什么问题?您粘贴的日志条目只是信息条目。以及 User 实体是如何映射的?
-
当项目开始使用这 3 个类时,不会将实体添加到数据库中,但是当我删除 User 类时,会添加其他 2 个类。
-
我认为mysql中已经存在
user表用于管理账户。 -
嘿 Nayan,我不这么认为,因为我已经创建了另一个数据库进行测试,但总是同样的问题。
-
@NayanWadekar 应该没关系,因为它是一个不同的数据库,这应该只给出警告,因为 user 是一个 sql 保留关键字。另外,OP,您可以发布带有注释的用户类吗?
标签: mysql hibernate tomcat jpa persistence