Hibernate and Dollar Sign in Table Names

194 views
Skip to first unread message

Backslash

unread,
Jun 25, 2008, 11:55:11 AM6/25/08
to H2 Database
Hello,

I recently downloaded the 2008-06-21 build of H2 for use with
Hibernate. However, when the tables are being constructed, statements
such as the following are being sent.

create table Poller$PolleeTime (id bigint generated by default as
identity, date binary(255), expired bit not null, nextDate timestamp,
primary key (id))

This causes an exception to occur as bellow. I tried to search for a
way to have hibernate not use "$" for subclasses as an alternative,
but didn't find anything obvious, and not using subclasses is not an
option either. Does anyone know of a work around for this so I can
get hibernate working? I also examined the Parser class in H2 but
found...

// $ is not supported at this time (compatibility
for
// PostgreSQL: $1 )

org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement CREATE
TABLE POLLER$[*]POLLEETIME (ID BIGINT GENERATED BY DEFAULT AS
IDENTITY, DATE BINARY(255), EXPIRED BIT NOT NULL, NEXTDATE TIMESTAMP,
PRIMARY KEY (ID)) ; expected (; SQL statement:
create table Poller$PolleeTime (id bigint generated by default as
identity, date binary(255), expired bit not null, nextDate timestamp,
primary key (id)) [42001-74]
at org.h2.message.Message.getSQLException(Message.java:103)
at org.h2.message.Message.getSQLException(Message.java:114)
at org.h2.message.Message.getSyntaxError(Message.java:139)
at org.h2.command.Parser.read(Parser.java:2396)
at org.h2.command.Parser.parseCreateTable(Parser.java:4417)
at org.h2.command.Parser.parseCreate(Parser.java:3285)
at org.h2.command.Parser.parsePrepared(Parser.java:323)
at org.h2.command.Parser.parse(Parser.java:290)
at org.h2.command.Parser.parse(Parser.java:262)
at org.h2.command.Parser.prepareCommand(Parser.java:234)
at org.h2.engine.Session.prepareLocal(Session.java:285)
at org.h2.engine.Session.prepareCommand(Session.java:246)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:
1030)
at org.h2.jdbc.JdbcStatement.executeUpdate(JdbcStatement.java:113)
at
org.apache.commons.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:
228)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:
150)
at
org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
323)
at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:
1304)
at
org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:
854)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:
669)
at
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:
126)
at
com.ncompass_inc.persistence.factory.hibernate.HibernateEntityManagerFactoryFactory.getEntityManagerFactory(HibernateEntityManagerFactoryFactory.java:
50)
at
com.ncompass_inc.persistence.EntityUtils.getEntityManager(EntityUtils.java:
30)
at
com.ncompass_inc.poll.XmlStorePollerTest.testXmlStorePoller(XmlStorePollerTest.java:
22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:
130)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:
38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:
386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:
196)

Thomas Mueller

unread,
Jun 25, 2008, 5:17:41 PM6/25/08
to h2-da...@googlegroups.com
Hi,

Thanks for your mail. Unfortunately this is a bug, introduced by the
'Dollar Quoting' feature introduced in version 1.0.72 (2008-05-10).
For more information about this feature see
http://www.h2database.com/html/grammar.html#dollarquotedstring and
http://www.h2database.com/html/changelog.html and
http://www.h2database.com/javadoc/org/h2/constant/SysProperties.html#h2.dollarQuoting
- I will fix this for the next release and add test cases. The bug is
in Parser.initialize(..), case '$' ... else { type = CHAR_SPECIAL_1
instead of CHAR_NAME.

A workaround is to disable dollar quoting by setting the system
property h2.dollarQuoting to false in the command line or by calling
System.setProperty("h2.dollarQuoting", "false") before loading the H2
JDBC driver.

Regards,
Thomas

Backslash

unread,
Jun 25, 2008, 6:26:01 PM6/25/08
to H2 Database
Thank you! I very much appreciate the amount of effort put into H2
and the great documentation that is available.

On Jun 25, 4:17 pm, "Thomas Mueller" <thomas.tom.muel...@gmail.com>
wrote:
> Hi,
>
> Thanks for your mail. Unfortunately this is a bug, introduced by the
> 'Dollar Quoting' feature introduced in version 1.0.72 (2008-05-10).
> For more information about this feature seehttp://www.h2database.com/html/grammar.html#dollarquotedstringandhttp://www.h2database.com/html/changelog.htmlandhttp://www.h2database.com/javadoc/org/h2/constant/SysProperties.html#...
> - I will fix this for the next release and add test cases. The bug is
> in Parser.initialize(..), case '$' ... else { type = CHAR_SPECIAL_1
> instead of CHAR_NAME.
>
> A workaround is to disable dollar quoting by setting the system
> property h2.dollarQuoting to false in the command line or by calling
> System.setProperty("h2.dollarQuoting", "false") before loading the H2
> JDBC driver.
>
> Regards,
> Thomas
>
Reply all
Reply to author
Forward
0 new messages