-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: persistence.xml and creating tables
PostPosted: Thu Sep 21, 2006 12:45 pm 
Regular
Regular

Joined: Fri Jul 30, 2004 4:02 pm
Posts: 50
Hibernate version:
jboss-embed-ejb3-alpha9

None of these properties seems to create tables when populated into the persistence.xml. Any recommendations?

<property name="hibernate.hbm2ddl.auto" value="create"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>

Code:
<persistence>
   <persistence-unit name="testdb">
  <class>com.test.domain.Testtable</class>
   <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
       <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
       <property name="hibernate.connection.username" value="user"/>
       <property name="hibernate.connection.password" value="password"/>
       <property name="hibernate.connection.url" value="jdbc:mysql://myserver/mydatabase"/>
       <property name="hibernate.max_fetch_depth" value="3"/>
       <property name="hibernate.hbm2ddl.auto" value="create"/>
       
   </properties>
   </persistence-unit>
</persistence>



The table is never created, and when calling the entitymanager.merge(x) method this happens:
ERROR:
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not insert: [com.test.domain.Testtable]
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:567)
at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:210)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 21, 2006 1:03 pm 
Regular
Regular

Joined: Fri Jul 30, 2004 4:02 pm
Posts: 50
nvm,

doesn't work with dashes in table name:

@javax.persistence.Table(name = "TEST-TABLE")

changed to "TESTTABLE" and works fine.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 22, 2006 3:48 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
this is then a limitation of your DB

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.