-->
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: Use Criteria for tables joined without mapped association
PostPosted: Tue May 12, 2009 7:15 am 
Newbie

Joined: Tue May 12, 2009 6:58 am
Posts: 1
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.


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.