-->
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.  [ 5 posts ] 
Author Message
 Post subject: query format in HQL
PostPosted: Wed Dec 20, 2006 7:42 am 
Newbie

Joined: Fri Nov 24, 2006 6:33 am
Posts: 11
I've this hibernate mapping:

<class
name="Sante.PAT.CPatient, Sante">
<id
name="no"
access="field"
column="patientId"
length="10">
<generator
class="guid" />
</id>
<property
name="dateNaissance"
access="field" />
<property
name="dateDeces"
access="field" />
<property
name="estDecede"
access="field"
column="IndicateurDeces" />
<bag
name="noms"
access="field">
<key
column="patientID"
foreign-key="patientDeNom" />
<one-to-many
class="Sante.PAT.CNom, Sante" />
</bag>
</class>
name="Sante.PAT.CNom, Sante">
<id
name="nomFamille"
access="field"
length="50">
<generator
class="assigned" />
</id>
<property
name="prenom1"
access="field"
length="50" />
<property
name="prenom2"
access="field"
length="50" />
</class>

with the corresponding C# classes:

public class CNom:CEntite, INom
{
private string nomFamille;

public string NomFamille
{
get { return nomFamille; }
set { nomFamille = value; }
}

private string prenom1;

public string Prenom1
{
get { return prenom1; }
set { prenom1 = value; }
}

private string prenom2;

public string Prenom2
{
get { return prenom2; }
set { prenom2 = value; }
}

}

[Class]
public class CPatient
{
private DateTime dateNaissance;

public DateTime DateNaissance
{
get { return dateNaissance; }
set { dateNaissance = value; }
}

private DateTime dateDeces;

public DateTime DateDeces
{
get { return dateDeces; }
set { dateDeces = value; }
}

private bool estDecede;

public bool EstDecede
{
get { return estDecede; }
set { estDecede = value; }
}

private ISet<INom> noms;

public virtual ISet<INom> Noms
{
get {
return noms;
}
}
}

when i try this HQL request, i've got an error:

from CPatient where CPatient.noms.nomFamille like 'Mor%'

"The multi-part identifier "CPatient.noms.nomFamille" could not be bound."

I need to write this:

from CPatient as patient join patient.noms as noms where noms.nomFamille like 'Mor%'


So apparently, you can't really used pointed notation to traverse the model?
does it exist another method more "intuitive"? How can i wrote this request using Criteria object?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 20, 2006 5:25 pm 
Beginner
Beginner

Joined: Thu Oct 12, 2006 6:19 pm
Posts: 34
Location: Guatemala
Hi xavos, can you post the query your statement is generating, please.
I believe the sql query is incorrect of course your proposite.

_________________
God is Love


Top
 Profile  
 
 Post subject: new Request
PostPosted: Thu Dec 21, 2006 7:09 am 
Newbie

Joined: Fri Nov 24, 2006 6:33 am
Posts: 11
I remark that i've forgot to add CNom in From clause, so i wrote:

from CPatient,CNom where CPatient.noms.nomFamille like 'Mor%'

and the SQL request is:

select cpatient0_.patient_id as patient1_14_,cnom1_.nom_famille as nom1_3_1_, cpatient0_.date_naissance as date4_14_0_, cpatient0_.date_deces
as date5_14_0_, cpatient0_.indicateur_deces as indicateur6_14_0_, cnom1_.prenom1 as prenom3_3_1_, cnom1_.prenom2 as prenom4_3_1_ from cpatient cpatient0_, cnom cnom1_ where (CPatient.noms.nomFamille like 'Mor%')

(In my class model, i forget CEntite class inheritance for CPatient, CEntite implementing "no" object attribute (mapped to patient_id in mapping file))

which doesn't work too


Top
 Profile  
 
 Post subject: Re: query format in HQL
PostPosted: Mon Aug 03, 2009 1:51 pm 
Newbie

Joined: Mon Aug 03, 2009 1:36 pm
Posts: 1
im having same troubles here.


devis mutuelle assurance complementaire sante maladie - Faut-il recourir à une mutuelle ou une assurance complémentaire santé ? A cette question, 90% des françaisdevis mutuelle assurance complementaire sante maladie


Top
 Profile  
 
 Post subject: Re: query format in HQL
PostPosted: Tue Aug 04, 2009 3:27 am 
Beginner
Beginner

Joined: Fri Feb 27, 2009 6:07 am
Posts: 38
Location: Moscow,Russia
as an example
Code:
from CPatient as cp join cp.noms as nom where nom.nomFamille like 'Mor%'


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.