-->
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: Criteria implementation in <joined-subclass>
PostPosted: Tue Dec 13, 2005 6:27 am 
Newbie

Joined: Mon Jul 25, 2005 7:38 am
Posts: 6
Location: Hyderabad
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.0
Mapping documents:
<class proxy="com.model.party.AddressIntf"
name="com.model.party.hibernate.NewAddress" table="ADDRESS" lazy="false">
<id name="addressId" column="ADDRESS_ID">
<generator class="sequence">
<param name="sequence">ADDRESS_ID_SEQ</param>
</generator>
</id>
<joined-subclass proxy="com.model.party.GeographicAddressIntf"
name="com.model.party.hibernate.GeographicAddress" lazy="false" table="GEOGRAPHIC_ADDRESS">
<key column="ADDRESS_ID"/>
<property name="addressLine1" column="LINE_1"/>
<property name="addressLine2" column="LINE_2"/>
</joined-subclass>
<joined-subclass proxy="com.model.party.TelecomAddressIntf"
name="com.model.party.hibernate.NewTelecomAddress" lazy="false" table="TELECOM_ADDRESS">
<key column="ADDRESS_ID"/>
<property name="phoneNumber" type="long">
<column name="PHONE" sql-type="number"/>
</property>
<property name="areaCode" column="AREA_CODE"/>
<property name="countryCode" column="COUNTRY_CODE"/>
</joined-subclass>
<joined-subclass proxy="com.model.party.WebAddressIntf"
name="com.model.party.hibernate.WebAddress" lazy="false" table="WEB_ADDRESS">
<key column="ADDRESS_ID"/>
<property name="emailAddress" column="EMAIL_ADDRESS_1"/>
<property name="url" column="URL_1"/>
</joined-subclass>
</class>
</hibernate-mapping>

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

Full stack trace of any exception that occurs:
No Exception
Name and version of the database you are using:
Oracle 10g
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


I want to write a Criteria to the get the respective address that is GeographicAddress or TelecomAddress or WebAddress. I right now have wrote the following :

if (address != null) {
criteria.createAlias("person.addresses", "addresses");
criteria.createAlias("addresses.address", "address");
criteria.setFetchMode("address",FetchMode.JOIN);
criteria.add(Restrictions.ilike("addresses.forUseOf","home"));
criteria.add(Restrictions.or(Restrictions.ilike("address.addressLine1", address
.getValue().toString()), Restrictions.ilike("address.addressLine2", address
.getValue().toString())));
logger.log(Level.INFO, "parameter Address value : " + address.getValue().toString());
}

if (phone != null) {
if (address == null) {
criteria.createAlias("person.addresses", "addresses");
criteria.createAlias("addresses.address", "address");
criteria.setFetchMode("address",FetchMode.JOIN);
}
logger.log(Level.INFO, "parameter Phone value : " + phone.getValue().toString());
criteria.add(Restrictions.and(
Restrictions.ilike("addresses.forUseOf","home_phone"),
Restrictions.eq("address.phoneNumber", Long.valueOf(phone.getValue()
.toString()))));
}

In the above case if I give both the address and phone number for searching then it doesnt search and give me the results.

Any quick reply is helpful.

_________________
HiberNATE


Top
 Profile  
 
 Post subject: Any answer with techies ?
PostPosted: Fri Dec 16, 2005 2:08 am 
Newbie

Joined: Mon Jul 25, 2005 7:38 am
Posts: 6
Location: Hyderabad
Any guidance on the above issue is helpful as Iam struck.

_________________
HiberNATE


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.