-->
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.  [ 2 posts ] 
Author Message
 Post subject: HQL many-to-many query help
PostPosted: Sun Jun 25, 2006 8:58 pm 
Newbie

Joined: Sun Jun 25, 2006 8:22 pm
Posts: 2
I have been surfing for days looking for an answer, I hope you can help.

Hibernate version: 3.1.1

Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
   <class name="com.bcfireinfo.storm.entity.model.log.LogImpl" entity-name="com.bcfireinfo.storm.entity.model.log.Log" table="Log" schema="dbo" catalog="Resource_Tracking" mutable="true">
      <cache usage="read-write"/>
        <id name="logId" type="long" unsaved-value="null">
            <column name="logId" />
            <generator class="native" />
        </id>
        <property name="systemTime" type="long">
            <column name="systemTime" not-null="true" />
        </property>
        <property name="userTime" type="long">
            <column name="userTime" not-null="true" />
        </property>
       
        <property name="dispatcherUsername" type="string">
            <column name="dispatcherUsername" length="50" not-null="true" />
        </property>
        <many-to-one name="activity" fetch="select" lazy="proxy">
            <column name="activityId" />
        </many-to-one>
        <many-to-one name="resource" fetch="select" lazy="proxy">
            <column name="resourceId" />
        </many-to-one>
        <property name="currentCallSign" type="string">
           <column name="currentCallSign" not-null="false"/>
        </property>
        <property name="state" type="string">
            <column name="state" length="50" not-null="false" />
        </property>
        <property name="comment" type="boolean">
           <column name="comment" not-null="true"/>
        </property>
        <property name="highlighted" type="boolean">
           <column name="highlighted" not-null="true"/>
        </property>
        <property name="message" type="string">
            <column name="message" length="1000" not-null="true" />
        </property>
        <set name="childResources" table="LogResourceMap">
           <key column="logId"/>
           <many-to-many column="resourceId" class="com.bcfireinfo.storm.entity.model.resource.Resource"/>
   </set>
    </class>
</hibernate-mapping>


I hace a 2-part problem, the first part is that the many-to-many mapped childResources are not persisting to the database when I save the logs, but because the rest of the log is persisting correctly, I don't think it will be a difficult issue to solve.

My second problem is that I need to instantiate all the logs (HibernateTemplate.find) filtered wher the resource is the one referred to by the resourceid, or it is one of the childResources

I can figure out the SQL needed to filter for these records, but I would like to keep my code as free of SQL as possible.
Code:
SELECT Log.logid FROM [dbo].[Log] left join LogResourceMap on log.logid = LogResourceMap.logId left  where log.resourceid = ? or LogResourceMap.resourceId = ?


can anyone help with the HQL?

thanks
bhs turf


Top
 Profile  
 
 Post subject: I am a fool
PostPosted: Mon Jun 26, 2006 12:58 pm 
Newbie

Joined: Sun Jun 25, 2006 8:22 pm
Posts: 2
after looking everywhere, my question was answered in the FAQ!

http://www.hibernate.org/116.html#A29

sorry for the trouble
bhs turf


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

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.