problems w/ column names beginning with '_' (underscore) w/ apache derby database
---------------------------------------------------------------------------------
Key: HIBERNATE-54
URL:
http://jira.jboss.com/jira/browse/HIBERNATE-54
Project: Hibernate
Issue Type: Bug
Environment: windows xp, java 1.5.0_09, eclispe 3.2.1, hibernate 3.2.1, derby
10.2.2.0, hibernate tools 3.2 beta8
Reporter: bugra uytun
Assigned To: Steve Ebersole
derby has problems with column names beginning with underscore, see also
http://db.apache.org/derby/docs/10.1/ref/crefsqlj1003454.html
therefore such column names should be between double quotation marks (notice that double
quotation marks also sets the case sensitivity on column names.)
but hibernate translates a HQL statement like this "from table1 t where t.id =
'1'" to something like:
select table1_.id as id4, table1_._colname1 as column27_4_ schema1.table1 table1_ where
table1_.id = '1'
but because of the columns that are beginning with an underscore the translation should
be:
select table1_."id" as id4, table1_."_colname1" as column27_4_
schema1."table1" table1_ where table1_."id" = '1'
the errors i got are:
DEBUG [JDBCExceptionReporter]: could not execute query [<translated sql statement>]
ERROR 42X01: Syntax error: Encountered "_" at line 1, column 987.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
at
org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.<init>(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.<init>(Unknown Source)
at org.apache.derby.jdbc.Driver30.newEmbedPreparedStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown Source)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:497)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:415)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1538)
at org.hibernate.loader.Loader.doQuery(Loader.java:661)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2211)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095)
at org.hibernate.loader.Loader.list(Loader.java:2090)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:388)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at <mypackage>.MyHibernate.main(MyHibernate.java:13)
WARN main org.hibernate.util.JDBCExceptionReporter - SQL Error: 20000, SQLState: 42X01
ERROR main org.hibernate.util.JDBCExceptionReporter - Syntax error: Encountered
"_" at line 1, column 987.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira