title: Mapping a table called "group" in Hibernate for DB2 and HSQLDB
body: <p>I have a table called <em>group</em>, that I am trying to map using hibernate for DB2 and <a href="http://hsqldb.org/" rel="nofollow noreferrer">HSQLDB</a>. Table name <em>group</em> is a reserved word and it must be quoted in HSQLDB. However DB2 does not like quoted table name.</p>
  
  <p>So this mapping works in HSQLDB but not in DB2:</p>
  
  <pre><code>@Entity
  @Table(name="`group`")
  public class Group {
  </code></pre>
  
  <p>Mapping results in following error in DB2 (making a query that involves Group table):</p>
  
  <pre>
  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.c.t.a(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
  </pre>
  
  <p>And this works in DB2 but not in HSQLDB:</p>
  
  <pre><code>@Entity
  @Table(name="group")
  public class Group {
  </code></pre>
  
  <p>Mapping results in following error in HSQLDB (creating the Group table):</p>
  
  <pre>
  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.java:373)
      at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:338)
      at org.springframework.orm.hibernate3.LocalSessionFactoryBean.createDatabaseSchema(LocalSessionFactoryBean.java:906)
    ...
  </pre>
  
  <p>I am using <a href="https://www.hibernate.org/hib_docs/v3/api/org/hibernate/dialect/DB2Dialect.html" rel="nofollow noreferrer">org.hibernate.dialect.DB2Dialect</a> and <a href="https://www.hibernate.org/hib_docs/v3/api/org/hibernate/dialect/HSQLDialect.html" rel="nofollow noreferrer">org.hibernate.dialect.HSQLDialect</a> for DB2 and HSQLDB, respectively.</p>
  
  <p>How can I make the same mapping work for the both databases simultaneously?</p>