-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: map same column as discriminator and propery
PostPosted: Mon Jul 21, 2008 4:00 am 
Newbie

Joined: Thu Feb 21, 2008 8:39 am
Posts: 15
Does anybody know if it is possible to map a column as a discriminator and a property in the same object, like:

Code:
   <class name="licenceBeans.LicenceTypeBean" table="LICENCE_TYPE">
        <id name="id" type="long" column="ID" unsaved-value="-1">
            <generator class="identity"/>
        </id>      
       <discriminator>
         <column name="LICENCE_TYPE"/>
       </discriminator>      
      <!--Properties-->
      <property name="licenceType" type="string" column="LICENCE_TYPE"/>
      
      <!--discriminator classes-->      
       <subclass name="licenceBeans.licenceTypes.GmCaptureLicenceBean" discriminator-value="..."/>
   </class>


Using this mapping definition, when I do some query using that field it says that licenceType could not be resolved. The strange thing is that if I query elements of this class using other fields the "licenceType" field is correctly initialized.

this is the exception:
Code:
org.hibernate.QueryException: could not resolve property: licenceType of: licenceBeans.LicenceTypeBean [from licenceBeans.LicenceTypeBean currLicenceType where currLicenceType.product = ? and currLicenceType.licenceType = ?]
   at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:44)
   at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:38)
   at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1362)
   at org.hibernate.hql.ast.tree.FromElementType.getPropertyType(FromElementType.java:279)
   at org.hibernate.hql.ast.tree.FromElement.getPropertyType(FromElement.java:386)
   at org.hibernate.hql.ast.tree.DotNode.getDataType(DotNode.java:567)
   at org.hibernate.hql.ast.tree.DotNode.prepareLhs(DotNode.java:241)
   at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:188)
   at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:94)
   at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:90)
   at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:728)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1216)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4041)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3525)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1762)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1690)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
   at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
   at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
   at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
   at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
   at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
   at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
   at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
   at licenceDaos.LicenceDao.activateLicence(LicenceDao.java:281)
   at licenceDaos.LicenceDao.main(LicenceDao.java:59)
Exception in thread "main" org.hibernate.TransactionException: Transaction not successfully started
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:100)
   at licenceDaos.LicenceDao.activateLicence(LicenceDao.java:307)
   at licenceDaos.LicenceDao.main(LicenceDao.java:59)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.