formula using table name with space does not work
-------------------------------------------------
Key: HHH-3754
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3754
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.3.1
Environment: hibernate 3.3.1, Microsoft SQLServer
Reporter: Rupesh Kumar
Usually when you have the table name with space in its name, you need to escape it while
using it in the hbm file and that works. But if you have a property with formula that uses
the same table, calling this code below it throws up error :
org.hibernate.exception.SQLGrammarException
Query query = session.createQuery("from tablewithspace");
List list = query.list();
tablewithspace.hbm.xml
------------------------------------
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="tablewithspace" entityname="tablewithspace"
table="[table with space]">
<id name="id" column="id" length="10"
type="int"/>
<property name="formulacol" formula="(select count(*) from
[table with space])" type="string"/>
<property name="name" column="name" length="50"
type="string"/>
</class>
</hibernate-mapping>
-----------------------------------
The stackstrace is
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2231)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
Caused by: java.sql.SQLException: [Macromedia][SQLServer JDBC Driver][SQLServer]Invalid
object name 'ctablewith0_.table with space'.
at macromedia.jdbc.base.BaseExceptions.createException(Unknown Source)
at macromedia.jdbc.base.BaseExceptions.getException(Unknown Source)
at macromedia.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
at macromedia.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
at macromedia.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
at macromedia.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
at macromedia.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
at macromedia.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
at macromedia.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
at macromedia.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Source)
at macromedia.jdbc.base.BaseStatement.commonExecute(Unknown Source)
at macromedia.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)
at macromedia.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source)
at macromedia.jdbc.base.BasePreparedStatementPoolable.executeQuery(Unknown Source)
at
coldfusion.server.j2ee.sql.JRunPreparedStatement.executeQuery(JRunPreparedStatement.java:74)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1808)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
... 40 more
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira