-->
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: a little hql help...
PostPosted: Sat Oct 11, 2003 6:52 pm 
Newbie

Joined: Tue Sep 30, 2003 12:59 pm
Posts: 8
ok, this hibernate stuff is new to me...

i need help translating a simple sql query like so:

mysql> select * from mdcontent m, mdmediachild ac where m.md_id=ac.md_id and ac.media_id=<could be multiple values here>;


to use the mappings i've setup in hibernate

(what i have so far)
sQuery.append("select");
sQuery.append(" content");
sQuery.append(" from");
sQuery.append(" com.adobe.studio.metadata.ContentItem as content");
sQuery.append(" where");
sQuery.append(" content.publishdate <= :sysdate and content.active= :active");

Query query = session.createQuery(sQuery.toString());
query.setBoolean("active", true);
query.setDate("sysdate", new java.util.Date());

example mapping:

<class name="com.adobe.studio.metadata.ContentItem" table="mdcontent">
<id name="id" column="md_id" type="long">
<generator class="native"/>
</id>
<property name="title" type="string">
<column name="title" length="254" not-null="true"/>
</property>
<property name="xmlfile" type="string">
<column name="xml_filename" length="40" not-null="true" unique="true"/>
</property>
<property name="longdesc" type="string">
<column name="l_description" sql-type="text"/>
</property>
<property name="shortdesc" type="string">
<column name="s_description" length="254" not-null="true"/>
</property>
<property name="publishdate" type="date">
<column name="publish_date" index="mdcontent_idx03" not-null="true"/>
</property>
<property name="expirationdate" type="date">
<column name="expire_date" index="mdcontent_idx04"/>
</property>
<property name="featured" type="boolean">
<column name="featured" index="mdcontent_idx01" not-null="true"/>
</property>
<property name="active" type="boolean">
<column name="active" index="mdcontent_idx02" not-null="true"/>
</property>
<many-to-one name="level" column="level_id" class="com.adobe.studio.metadata.ContentLevel" cascade="none" not-null="true"/>
<many-to-one name="type" column="type_id" class="com.adobe.studio.metadata.ContentType" cascade="none" not-null="true"/>

<set name="medias" table="mdmediachild" lazy="true">
<key>
<column name="md_id" not-null="true"/>
</key>
<many-to-many class="com.adobe.studio.metadata.Media">
<column name="media_id" not-null="true"/>
</many-to-many>
</set>

!! snip other sets !!
</class>

<class name="com.adobe.studio.metadata.Media" table="mdwfmedia">
<id name="id" column="media_id" type="long">
<generator class="native"/>
</id>
<property name="description" type="string">
<column name="description" length="40" not-null="true" unique="true"/>
</property>
<property name="active" type="boolean">
<column name="active" index="mdWFMedia_idx01" not-null="true"/>
</property>
</class>


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.