简体   繁体   中英

Cannot adding a table in Database via persistence.xml using Hibernate Jpa , Tomcat and Mysql

I'm working in flex, blazeds,hibernate jpa, tomcat and mysql. This is the problem that I face when I start the project:

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

And this is my persistence.xml file under src/META-INF:

<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>

But if I delete the line: <class>com.adobe.demo.domain.User</class> the other 2 tables will be created. What should I do?

Here is a similar question. The OP was trying to create a "User" table, which failed. The OP was able to resolve the issue by annotation his User class with @Table(name = "\\"user\\"") .

I also gave some tips on how to troubleshoot such problems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM