-->
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: Querying across joined-subclasses
PostPosted: Wed Dec 28, 2005 8:42 am 
Newbie

Joined: Sun Oct 02, 2005 12:49 am
Posts: 15
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

3.0

Mapping documents:

<class name="Party">
.....
<set name="addresses" table="PARTY_ADDRESS" >
<key column="PARTY_ID" not-null="true"/>
<one-to-many class="PartyAddress"/>
</set>
</class>

<class name="PartyAddress" table="PARTY_ADDRESS" >
.....
<many-to-one name="address" class="Address"
column="ADDRESS_ID" />
</class>

<class name="Address" table="ADDRESS">
<id name="addressId" column="ADDRESS_ID">
<generator class="sequence">
<param name="sequence">PARTY_ADDRESS_ID_SEQ</param>
</generator>
</id>

<property name="addressType" type="string">
<column name="ADDRESS_TYPE" sql-type="VARCHAR2"/>
</property>

<joined-subclass name="GeographicAddress"
table="GEOGRAPHIC_ADDRESS">
<key column="ADDRESS_ID"/>
......
<property name="city" column="CITY"/>
<property name="zipCode" column="ZIP_1"/>
</joined-subclass>

<joined-subclass name="TelecomAddress"
table="TELECOM_ADDRESS">
<key column="ADDRESS_ID"/>
<property name="phoneNumber" type="long">
<column name="PHONE" sql-type="number"/>
</property>
</joined-subclass>

</class>

Code between sessionFactory.openSession() and session.close():

Session session = HibernateUtil.currentSession();
Criteria criteria =
session.createCriteria(PartyAssociation.class)
.createCriteria("party")
.createCriteria("addresses")
.createCriteria("address")
.add(Restrictions.and(Restrictions.eq("city", "Albany"),
Restrictions.eq("phoneNumber", "989898")));
System.out.println(criteria.list().size());

Full stack trace of any exception that occurs:
N/A
Name and version of the database you are using:
Oracle 10g



I would like to retrieve all party objects which have a specified Geographic Address city property (e.g. albany) AND a specified phone number. Is this possible with HQL or Criteria querying? Or do i have to go for native SQL and intersects? The above criteria query returns Zero records as expected.

Have been stuck on this issue for quite sometime now.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 02, 2006 12:58 am 
Newbie

Joined: Sun Oct 02, 2005 12:49 am
Posts: 15
Have been trying to crack this one for quite sometime now. Haven't received any response on this. Is the question too trivial or is it something we cannot achieve using hibernate? Please help!


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.