-->
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: SQLQuery and Components
PostPosted: Wed Mar 24, 2004 3:13 pm 
Beginner
Beginner

Joined: Mon Dec 01, 2003 8:48 pm
Posts: 47
Location: Texas, United States
I would like to select an attribute(applicationName) from a component object of a mapped class. Here is my mapping...

<class name="CommonLogEvent" mutable="false" table="UL_COMMON_LOG_EVENT" dynamic-update="false" dynamic-insert="false">
<cache usage="read-only"/>
<id name="id" column="cle_id" type="long">
<generator class="native"/>
</id>
<property name="observedTime" type="java.util.Date" update="true" insert="true" column="observed_time" not-null="false"/>
<property name="version" type="java.lang.String" update="true" insert="true" column="version"/>
<property name="situation" type="java.lang.String" update="true" insert="true" column="situation"/>
<property name="message" type="java.lang.String" update="true" insert="true" column="message"/>
<property name="status" type="java.lang.String" update="true" insert="true" column="status"/>
<property name="severity" type="java.lang.String" update="true" insert="true" column="severity"/>
<property name="logLevel" type="int" update="true" insert="true" column="log_level"/>
<component name="componentIdentification">
<property name="addressType" type="java.lang.String" update="true" insert="true" column="address_type"/>
<property name="addressName" type="java.lang.String" update="true" insert="true" column="address_name"/>
<property name="componentName" type="java.lang.String" update="true" insert="true" column="component_name"/>
<property name="applicationName" type="java.lang.String" update="true" insert="true" column="application_name"/>
<property name="instanceName" type="java.lang.String" update="true" insert="true" column="instance_name"/>
<property name="threadName" type="java.lang.String" update="true" insert="true" column="thread_name"/>
<property name="environmentName" type="java.lang.String" update="true" insert="true" column="environment_name"/>
</component>

I am trying this in my mapping file...
<sql-query name="selectDistinctAppNames">
<return alias="cle" class="CommonLogEvent"/>
select distinct {cle}.APPLICATION_NAME {cle.applicationName} from UL_COMMON_LOG_EVENT {cle}
</sql-query>


I get the following error because applicationName is not in CommonLogEvent, it is in ComponentIdentification, which is contained by CommonLogEvent.
net.sf.hibernate.QueryException: No column name found for property [applicationName] [

select distinct {cle}.APPLICATION_NAME {cle.applicationName} from UL_COMMON_LOG_EVENT {cle}
]
at net.sf.hibernate.loader.SQLLoader.substituteBrackets(SQLLoader.java:172)
at net.sf.hibernate.loader.SQLLoader.renderStatement(SQLLoader.java:85)
at net.sf.hibernate.loader.SQLLoader.<init>(SQLLoader.java:71)
at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3622)
at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)

How do I reference a component within my mapped class? I tried this but got an error as well.
<sql-query name="selectDistinctAppNames">
<return alias="cle" class="CommonLogEvent"/>
select distinct {cle}.APPLICATION_NAME {cle.componentIdentification.applicationName} from UL_COMMON_LOG_EVENT {cle}
</sql-query>


I saw a post about this earlier, however no resolution was posted.
http://forum.hibernate.org/viewtopic.ph ... t=sqlquery


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.