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.  [ 8 posts ] 
Author Message
 Post subject: Error: "Table commerce._contact doesn't exist."
PostPosted: Thu Jan 08, 2004 7:05 pm 
Newbie

Joined: Thu Jan 08, 2004 6:54 pm
Posts: 8
For some reason, Hibernate2.1 is putting an underscore ('_') in front of the table name when it generates the SQL for an insert. This results in a "Table commerce._contact doesn't exist" error.

My mapping file looks fine and I only have one set of mapping files in the classpath, so Hibernate must be using this one.

<class
name="com.commerce.model.contact.ContactBO"
table="Contact"
dynamic-update="false"
dynamic-insert="false"
>

Any ideas on how to solve this problem apart from changing my DDL each time to add underscores!?

tia
[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 08, 2004 7:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
eh?! Are you sure?


Top
 Profile  
 
 Post subject: Error: "Table commerce._contact does'nt exist."
PostPosted: Thu Jan 08, 2004 7:27 pm 
Newbie

Joined: Thu Jan 08, 2004 6:54 pm
Posts: 8
Here's the error. I also get it on another mapping file for my ProductBO class.

2004-01-08 15:45:15,926 ERROR hibernate.util.JDBCExceptionReporter -> could not insert: [com.commerce.model.inventory.ProductBO]
java.sql.SQLException: General error, message from server: "Table 'commerce._contact' doesn't exist"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1825)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1020)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1109)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2030)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1750)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1596)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:233)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:233)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:502)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:433)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:876)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:817)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:737)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:717)
at com.test.commerce.HibernateDemoOneToMany.run(HibernateDemoOneToMany.java:93)
at com.test.commerce.HibernateDemoOneToMany.main(HibernateDemoOneToMany.java:31)
net.sf.hibernate.JDBCException: could not insert: [com.commerce.model.inventory.ProductBO]
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:541)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:433)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:876)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:817)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:737)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:717)
at com.test.commerce.HibernateDemoOneToMany.run(HibernateDemoOneToMany.java:93)
at com.test.commerce.HibernateDemoOneToMany.main(HibernateDemoOneToMany.java:31)
Caused by: java.sql.SQLException: General error, message from server: "Table 'commerce._contact' doesn't exist"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1825)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1020)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1109)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2030)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1750)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1596)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:233)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:233)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:502)
... 7 more


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 08, 2004 7:31 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Do you specify a schema somewhere? note that MySQL does not have any support for schemas.


Top
 Profile  
 
 Post subject: Error: "Table commerce._contact doesn't exist."
PostPosted: Thu Jan 08, 2004 10:08 pm 
Newbie

Joined: Thu Jan 08, 2004 6:54 pm
Posts: 8
Thanks! I had the property there, but empty... After I removed it, the code worked fine.

###################################
### MySQL Database
###################################
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://localhost/commerce
hibernate.connection.username=cuser
hibernate.connection.password=password
hibernate.default_schema= <-- NOT GOOD!
hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect
hibernate.show_sql=true


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 08, 2004 10:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
hmmmm that is probably suboptimal behavior on the part of Hibernate....


Top
 Profile  
 
 Post subject: Similar problem with Hibernate 3
PostPosted: Tue Jul 12, 2005 11:43 am 
Newbie

Joined: Tue Jul 12, 2005 11:31 am
Posts: 1
Just for your information:

I have just finished struggling with a similar problem: an underscore was systematically added in front of my table names.

The mapping files were generated using the Artifact generation tool (from the Hibernate Tools) used as Eclipse plugin.

Apparently by default an empty catalog attribute is added to the class-tag (in the mapping xml files) and this then caused hibernate to add the extra underscore.

I hope this will save some time for other people starting to work with Hibernate and Eclipse.

Greetings,

Gert


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 27, 2005 7:11 am 
Newbie

Joined: Thu Jun 16, 2005 8:01 pm
Posts: 14
I had the same problem

Using the hibernate tool (hibern8) and generating the mapping files there was an extra catalog flag added to the hbm.xml class tag.

AFter removing this it worked fine.

I am using MySQL 4 and it's weird. But hey... its working fine now :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.