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>
|