-->
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: Newbie - HQL query
PostPosted: Mon Mar 13, 2006 9:18 pm 
Beginner
Beginner

Joined: Thu Sep 23, 2004 6:03 am
Posts: 27
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0

Mapping documents:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping

>

<class
name="au.edu.tlf.crisp2.model.AgentType"
table="agent_type"
>

<id
name="id"
column="agent_type_id"
unsaved-value="null"
>

<!-- The generator-class attribute of @hibernate.id is deprecated, use the @hibernate.generator tag instead -->
<generator class="native">

</generator>

</id>

<property
name="description"
column="description"
not-null="false"
>

</property>

<property
name="type"
column="type"
not-null="false"
>

</property>

<set
name="agents"
lazy="true"
inverse="true"
cascade="save-update"
>

<!-- @hibernate.collection-key tag is deprecated, use @hibernate.key instead -->
<key
column="fk_agent_type_id"
>

</key>

<!-- @hibernate.collection-one-to-many tag is deprecated, use @hibernate.one-to-many instead -->
<one-to-many
class="au.edu.tlf.crisp2.model.LicenceParty"
/>

</set>

</class>

</hibernate-mapping>

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping

>

<class
name="au.edu.tlf.crisp2.model.Agent"
table="agent"
discriminator-value="a"
>

<id
name="id"
column="id"
unsaved-value="null"
>

<!-- The generator-class attribute of @hibernate.id is deprecated, use the @hibernate.generator tag instead -->
<generator class="native">

</generator>

</id>

<discriminator
column="agent_disc"
type="char"
/>

<property
name="title"
column="title"
not-null="false"
>

</property>

<property
name="firstName"
column="first_name"
not-null="false"
>

</property>

<property
name="lastName"
column="last_name"
not-null="false"
>

</property>

<property
name="businessName"
column="business_name"
not-null="false"
>

</property>

<property
name="abn"
column="abn"
not-null="false"
>

</property>

<property
name="poBox"
column="po_box"
not-null="false"
>

</property>

<property
name="buildingLevelFlat"
column="buildingLevelFlat"
not-null="false"
>

</property>

<property
name="street"
column="street"
not-null="false"
>

</property>

<property
name="city"
column="city"
not-null="false"
>

</property>

<property
name="state"
column="state"
>

</property>

<property
name="postalCode"
column="postal_code"
length="10"
not-null="false"
>

</property>

<many-to-one
name="country"
column="country"
>

</many-to-one>

<property
name="email"
column="email"
length="100"
not-null="false"
>

</property>

<property
name="phoneNumber"
column="phone_number"
not-null="false"
>

</property>

<property
name="faxNumber"
column="fax_number"
not-null="false"
>

</property>

<property
name="mobileNumber"
column="mobile_number"
not-null="false"
>

</property>

<property
name="website"
column="website"
not-null="false"
>

</property>

<many-to-one
name="agentType"
column="fk_agent_type_id"
>

</many-to-one>

<set
name="contacts"
lazy="true"
cascade="all"
>

<!-- @hibernate.collection-key tag is deprecated, use @hibernate.key instead -->
<key
column="agent_contact_id"
>

</key>

<!-- @hibernate.collection-one-to-many tag is deprecated, use @hibernate.one-to-many instead -->
<one-to-many
class="au.edu.tlf.crisp2.model.Contact"
/>

</set>

<set
name="licenseeLicences"
table="table_join_licences_licensees"
lazy="true"
inverse="true"
cascade="save-update"
>

<!-- @hibernate.collection-key tag is deprecated, use @hibernate.key instead -->
<key
column="fk_lincensee_id"
>

</key>

<!-- @hibernate.collection-many-to-many tag is deprecated, use @hibernate.many-to-many instead -->
<many-to-many
class="au.edu.tlf.crisp2.model.Licence"
column="fk_licence_id"
outer-join="auto"
/>

</set>

<set
name="licensorLicences"
table="table_join_licences_licensors"
lazy="true"
inverse="true"
cascade="save-update"
>

<!-- @hibernate.collection-key tag is deprecated, use @hibernate.key instead -->
<key
column="fk_lincensor_id"
>

</key>

<!-- @hibernate.collection-many-to-many tag is deprecated, use @hibernate.many-to-many instead -->
<many-to-many
class="au.edu.tlf.crisp2.model.Licence"
column="fk_licence_id"
outer-join="auto"
/>

</set>

<subclass
name="au.edu.tlf.crisp2.model.LicenceParty"
discriminator-value="l"
>

<set
name="roleType"
table="table_agent_roles"
lazy="true"
cascade="save-update"
>

<!-- @hibernate.collection-key tag is deprecated, use @hibernate.key instead -->
<key
column="fk_agent_id"
>

</key>

<!-- @hibernate.collection-many-to-many tag is deprecated, use @hibernate.many-to-many instead -->
<many-to-many
class="au.edu.tlf.crisp2.model.RoleType"
column="fk_role_type_id"
outer-join="auto"
/>

</set>

<property
name="externalSystemID"
column="external_system_id"
>

</property>

</subclass>

<subclass
name="au.edu.tlf.crisp2.model.Contributor"
discriminator-value="c"
>

<property
name="comments"
column="comments"
>

</property>

<property
name="dateDescription"
column="date_description"
>

</property>

<property
name="day"
column="day"
>

</property>

<property
name="month"
column="month"
>

</property>

<property
name="year"
column="year"
>

</property>

<property
name="lomRole"
column="lom_role_id"
>

</property>

<property
name="vcardRole"
column="vcard_role_id"
>

</property>

<many-to-one
name="intellectualProperty"
column="ip_contributor_id"
>

</many-to-one>

</subclass>

</class>

</hibernate-mapping>



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

Name and version of the database you are using:MySQL 4.1.17

Simple query to others that I'm unsure of. I want to return a list of all Agents in the system name between A - K and another query to return those between L - Z. I need to classify them by AgentType

So far this is my effort. Some pointers would really help. LicenceParty is a child of Agent

AgentType has
id
name
description

Values for AgentType.name are:
Individual
Organisation
Code:
/* (non-Javadoc)
    * @see au.edu.tlf.crisp2.dao.LicencePartyDAO#getLicencePartyIndividualsAToK()
    */
   public List getLicencePartyIndividualsAToK() {
      return getHibernateTemplate().find("from LicenceParty lp, AgentType at where lp.agentType = 'Individual' and lp.lastName < 'l' ");      
   }



Top
 Profile  
 
 Post subject: HQL query - case sensitivity
PostPosted: Tue Mar 14, 2006 1:04 pm 
Beginner
Beginner

Joined: Wed Nov 30, 2005 2:41 pm
Posts: 29
one guess is that you'll have problems with case-sensitivity. In ASCII, all capital letters are less than 'a'. So this might work:
Code:
(lp.lastName >= 'A' and lp.lastName < 'L') or (lp.lastName >= 'a' and lp.lastName < 'l')

------
please rate reply if this helps!


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.