Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0.3
Mapping documents:
<properties name="ttblKey" unique="true">
<property name="ucVcmpId" type="java.lang.String" column="U##CMP_ID" length="2"/>
<property name="ttblId" type="java.math.BigDecimal" column="TTBL_ID" length="22"/>
</properties>
...
<query name="getNextTimetableNo"><![CDATA[
select max(t.ttableNo) from Ttbl as t
where t.ucVcmpId = 'TA'
and t.ucVempId = :pempId
]]>
</query>
...
Code between sessionFactory.openSession() and session.close():
session obtained from jndi lookup
Full stack trace of any exception that occurs:
10 Aug 2005 16:12:38,119 ERROR [impl.SessionFactoryImpl] - Error in named query: getNextTimetableNo
org.hibernate.QueryException: could not resolve property: ucVcmpId of: com.Ttbl [
select max(t.ttableNo) from com.Ttbl as t
where t.ucVcmpId = 'TA'
and t.ucVempId = :pempId
]
at org.hibernate.persister.entity.AbstractPropertyMapping.throwPropertyException(AbstractPropertyMapping.java:43)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:37)
at org.hibernate.persister.entity.BasicEntityPersister.toType(BasicEntityPersister.java:1094)
at org.hibernate.hql.ast.FromElementType.getPropertyType(FromElementType.java:230)
at org.hibernate.hql.ast.FromElement.getPropertyType(FromElement.java:342)
at org.hibernate.hql.ast.DotNode.getDataType(DotNode.java:474)
at org.hibernate.hql.ast.DotNode.prepareLhs(DotNode.java:207)
at org.hibernate.hql.ast.DotNode.resolve(DotNode.java:166)
at org.hibernate.hql.ast.FromReferenceNode.resolve(FromReferenceNode.java:88)
at org.hibernate.hql.ast.FromReferenceNode.resolve(FromReferenceNode.java:84)
at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:463)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:863)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:3713)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3190)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1405)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1330)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1330)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1330)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1330)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1330)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1330)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1330)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1330)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:599)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:404)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:84)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:425)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:386)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:289)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1055)
Name and version of the database you are using:
Oracle 9i
The generated SQL (show_sql=true):
none
Debug level Hibernate log excerpt:
will post if necessary
The problems seems to be hibernate doesn't register the property inside the <properties> tag. If I add the property outside the <properties> tag then the query parses but I get a new exception that theres a duplicate column.
Does anyone know a proper solution how I can use this property in my named query? I'm not sure what I'm supposed to do in this case.