2012-06-05 34 views
0

我正在使用flex,blazeds,hibernate jpa,tomcat和mysql。 這是我面臨的問題,當我啓動項目:無法在數據庫中通過persistence.xml使用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個表將被創建。 我該怎麼辦?

+0

究竟是什麼問題?您粘貼的日誌條目只是信息條目。用戶實體如何映射? –

+0

當項目開始使用這3個類時,沒有實體會被添加到數據庫中,但是當我刪除User類時,他們會添加其他2個類。 – user1438406

+1

我認爲在mysql中已經存在用於管理帳戶的'user'表。 –

回答

0

Here是一個類似的問題。 OP正試圖創建一個「用戶」表,失敗了。 OP能夠通過註釋他的User類與@Table(name = "\"user\"")來解決問題。

我還提供了一些關於如何解決這些問題的提示。

相關問題