Hi,
I have the following mapping:
Code:
Occurrence class:
-------------------------------
<class name="Occurrence" table="occurrence" mutable="false">
<id name="id">
<generator class="native"/>
</id>
<property name="startFrame"/>
<property name="channelPatternId"/>
...
</class>
ChannelPattern class:
----------------------------------
<class name="ChannelPattern" table="channel_pattern">
<id name="id">
<generator class="assigned"/>
</id>
<many-to-one name="pattern" class="Pattern" lazy="proxy" fetch="select" not-null="false"/>
<many-to-one name="signature" class="Signature" lazy="proxy" fetch="select" not-null="false"/>
...
</class>
My question is: how (if it's possible) can I use Criteria to achieve the equivalent query:
Code:
String queryStr = "SELECT DATE(startFrame), COUNT(occ.id) FROM Occurrence occ, ChannelPattern cp " +
"WHERE cp.id=occ.channelPatternId " +
"AND (cp.pattern.id='id1' OR cp.signature.id='sig1') GROUP BY DATE(startFrame)";
Query query2 = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery(queryStr);
Basically, I would like to use Criteria on a table join without having a mapped association between Occurrence and ChannelPattern classes (in Occurrence I only have a property representing channelPatternId).
Is it possible?
Thank you very much.