I have a table called a group that I am trying to map using hibernate for DB2 and HSQLDB . The table name group is a reserved word and must be specified in HSQLDB. However, DB2 does not like the quoted table name.
So this mapping works in HSQLDB, but not in DB2:
@Entity @Table(name="`group`") public class Group {
Showing results in the following error in DB2 (creating a query that includes a Group table):
Caused by: com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -204, SQLSTATE: 42704, SQLERRMC: SCHEMA_NAME.group
at com.ibm.db2.jcc.b.hh.c (hh.java:1662)
at com.ibm.db2.jcc.b.hh.d (hh.java:1650)
at com.ibm.db2.jcc.b.hh.a (hh.java:1219)
at com.ibm.db2.jcc.c.db.g (db.java:139)
at com.ibm.db2.jcc.c.db.a (db.java:39)
at com.ibm.db2.jcc.cta (t.java:34)
at com.ibm.db2.jcc.c.sb.f (sb.java:142)
at com.ibm.db2.jcc.b.hh.n (hh.java:1190)
at com.ibm.db2.jcc.b.ih.eb (ih.java:1997)
at com.ibm.db2.jcc.b.ih.d (ih.java:2439)
at com.ibm.db2.jcc.b.ih.V (ih.java:492)
at com.ibm.db2.jcc.b.ih.executeQuery (ih.java:475)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery (NewProxyPreparedStatement.java:76)
at org.hibernate.jdbc.AbstractBatcher.getResultSet (AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet (Loader.java:1787)
at org.hibernate.loader.Loader.doQuery (Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections (Loader.java:236)
at org.hibernate.loader.Loader.loadCollection (Loader.java:1994)
... 71 more
And this works in DB2, but not in HSQLDB:
@Entity @Table(name="group") public class Group {
Showing results in the following error in HSQLDB (creating a Group table):
WARN hibernate.ExtendedAnnotatedSessionFactoryBean - Unsuccessful schema statement: create table group (* details omitted *)
java.sql.SQLException: Unexpected token: GROUP in statement [create table group]
at org.hsqldb.jdbc.Util.sqlException (Unknown Source)
at org.hsqldb.jdbc.jdbcStatement.fetchResult (Unknown Source)
at org.hsqldb.jdbc.jdbcStatement.executeUpdate (Unknown Source)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.executeSchemaStatement (LocalSessionFactoryBean.java:1000)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.executeSchemaScript (LocalSessionFactoryBean.java:972)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean $ 2.doInHibernate (LocalSessionFactoryBean.java:912)
at org.springframework.orm.hibernate3.HibernateTemplate.execute (HibernateTemplate.javahaps73)
at org.springframework.orm.hibernate3.HibernateTemplate.execute (HibernateTemplate.javahaps38)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.createDatabaseSchema (LocalSessionFactoryBean.java:906)
...
I use org.hibernate.dialect.DB2Dialect and org.hibernate.dialect.HSQLDialect for DB2 and HSQLDB, respectively.
How can I do the same mapping job for both databases at the same time?
source share