Hibernate version:
2.1
Mapping documents:
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">COM.ibm.db2.jdbc.app.DB2Driver</property>
<property name="hibernate.connection.url">jdbc:db2:DB2T</property>
<property name="hibernate.connection.username">name removed</property>
<property name="hibernate.connection.password">pass removed</property>
<property name="hibernate.default_schema">ADMRLDDE</property>
<property name="dialect">net.sf.hibernate.dialect.DB2Dialect</property>
<property name="show_sql">true</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">10</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">20</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
</session-factory>
</hibernate-configuration>
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<!-- Contact ************************************************************ -->
<class name="Contact" table="DEXA912T">
<id column="contact_id" name="id" type="integer">
<generator class="increment"/>
</id>
<property name="emailAddress" column="email" type="string"/>
<property name="faxNumber" column="fax" type="string"/>
<property name="name" column="name" type="string"/>
<property name="phoneNumber" column="phone" type="string"/>
<property name="phoneNumberExt" column="extension" type="string"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
PersistanceManager.beginTransaction();
try{
Contact c = getContact(false);
session.save(c);
}
catch(HibernateException hbmEx){
System.err.println(hbmEx);
System.exit(-1);
}
PersistanceManager.commitTransaction();
Full stack trace of any exception that occurs:Code:
>COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL0204N "VKDB2T2.DEXA912T" is an undefined name. SQLSTATE=42704
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(SQLExceptionGenerator.java:270)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(SQLExceptionGenerator.java:207)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(SQLExceptionGenerator.java:458)
at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2(DB2PreparedStatement.java:2110)
at COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeQuery(DB2PreparedStatement.java:1596)
at com.mchange.v2.sql.filter.FilterPreparedStatement.executeQuery(FilterPreparedStatement.java:68)
at com.mchange.v2.c3p0.impl.C3P0PooledConnection$2.executeQuery(C3P0PooledConnection.java:567)
at net.sf.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:67)
at net.sf.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:42)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:765)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
at westest.WesTest.main(WesTest.java:39)
net.sf.hibernate.JDBCException: Could not save object
Name and version of the database you are using:
DB2
The generated SQL (show_sql=true):
None shown.
Debug level Hibernate log excerpt:
It appears that the incement generator doesn't use the default_schema that I am setting in hibernate.cfg.xml. If I just try to read a row, it finds the table fine, but when I insert a new row, it gets the above error.
If I put the schema in the hibernate-mapping or class entities it does work. However, I have one file for each class, and we have our database in several different schemas. Updating all the files each time we want to use a different schema would be a maintenence problem.
Is there a workaround for this?