-->
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.  [ 4 posts ] 
Author Message
 Post subject: Criteria Query o n multilpe tables
PostPosted: Mon Dec 11, 2006 6:17 pm 
Newbie

Joined: Fri Nov 17, 2006 12:18 pm
Posts: 6
Hibernate version:
3.0.2

Hello I have the following mapping documents:

Mapping documents:

Entity Name: Angioescanografia
<?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 catalog="carotida"
name="uniandes.carotida.db.hibernate.generation.java.Angioescanografia" table="angioescanografia">
<id name="idAngioescanografia" type="int">
<column name="id_angioescanografia"/>
<generator class="native"/>
</id>
<set inverse="true" name="Placa_angioescanografias">
<key>
<column name="idAngioescanografia" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Placa_angioescanografia"/>
</set>
<many-to-one
class="uniandes.carotida.db.hibernate.generation.java.Informacionpaciente"
fetch="select" name="Informacionpaciente">
<column name="idInformacionpaciente" not-null="true"/>
</many-to-one>
<many-to-one
class="uniandes.carotida.db.hibernate.generation.java.Informacionserie"
fetch="select" name="Informacionserie">
<column name="idInformacionserie" not-null="true"/>
</many-to-one>
<property name="reporte" type="string">
<column length="200" name="reporte" not-null="true"/>
</property>
</class>
</hibernate-mapping>

Entity Name: Iacid

<?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 catalog="carotida"
name="uniandes.carotida.db.hibernate.generation.java.Iacid" table="iacid">
<id name="idIacid" type="int">
<column name="id_iacid"/>
<generator class="native"/>
</id>
<set inverse="true" name="Placa_iacids">
<key>
<column name="idIacid" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Placa_iacid"/>
</set>
<many-to-one
class="uniandes.carotida.db.hibernate.generation.java.Informacionpaciente"
fetch="select" name="Informacionpaciente">
<column name="idInformacionpaciente" not-null="true"/>
</many-to-one>
<many-to-one
class="uniandes.carotida.db.hibernate.generation.java.Informacionserie"
fetch="select" name="Informacionserie">
<column name="idInformacionserie" not-null="true"/>
</many-to-one>
<property name="descripcion" type="string">
<column length="200" name="descripcion" not-null="true"/>
</property>
<property name="prueba" type="string">
<column length="200" name="prueba" not-null="true"/>
</property>
<property name="fecharealizacion" type="timestamp">
<column length="19" name="fecharealizacion" not-null="true"/>
</property>
<property name="fechaingreso" type="timestamp">
<column length="19" name="fechaingreso" not-null="true"/>
</property>
<property name="modelogeometrico" type="string">
<column length="200" name="modelogeometrico" not-null="true"/>
</property>
</class>
</hibernate-mapping>


Entity Name: Informacionpaciente
<?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 catalog="carotida"
name="uniandes.carotida.db.hibernate.generation.java.Informacionpaciente" table="informacionpaciente">
<id name="cedula" type="int">
<column name="cedula"/>
<generator class="assigned"/>
</id>
<set inverse="true" name="Analisisclinicos">
<key>
<column name="idInformacionpaciente" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Analisisclinico"/>
</set>
<set inverse="true" name="Angioescanografias">
<key>
<column name="idInformacionpaciente" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Angioescanografia"/>
</set>
<set inverse="true" name="Angioresonancias">
<key>
<column name="idInformacionpaciente" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Angioresonancia"/>
</set>
<set inverse="true" name="Asds">
<key>
<column name="idInformacionpaciente" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Asd"/>
</set>
<set inverse="true" name="Ecodopplers">
<key>
<column name="idInformacionpaciente" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Ecodoppler"/>
</set>
<set inverse="true" name="Ecomodobs">
<key>
<column name="idInformacionpaciente" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Ecomodob"/>
</set>
<set inverse="true" name="Procesamientohemodinamicos">
<key>
<column name="idInformacionpaciente" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Procesamientohemodinamico"/>
</set>
<set inverse="true" name="Prephemodinamicos">
<key>
<column name="idInformacionpaciente" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Prephemodinamico"/>
</set>
<set inverse="true" name="Prepestructurals">
<key>
<column name="idInformacionpaciente" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Prepestructural"/>
</set>
<set inverse="true" name="Reportehemodinamicos">
<key>
<column name="idInformacionpaciente" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Reportehemodinamico"/>
</set>
<set inverse="true" name="Iacids">
<key>
<column name="idInformacionpaciente" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Iacid"/>
</set>
<set inverse="true" name="Resultadoslaboratorios">
<key>
<column name="idInformacionpaciente" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Resultadoslaboratorio"/>
</set>
<set inverse="true" name="Informacionseries">
<key>
<column name="idInformacionpaciente" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Informacionserie"/>
</set>
<property name="fechanacimiento" type="timestamp">
<column length="19" name="fechanacimiento" not-null="true"/>
</property>
<property name="genero" type="boolean">
<column name="genero" not-null="true"/>
</property>
<property name="nombre" type="string">
<column length="200" name="nombre" not-null="true"/>
</property>
</class>
</hibernate-mapping>


Entity Name: Placa_angioescanografia

<?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 catalog="carotida"
name="uniandes.carotida.db.hibernate.generation.java.Placa_angioescanografia" table="placa_angioescanografia">
<id name="idPlaca_angioescanografia" type="int">
<column name="id_placa_angioescanografia"/>
<generator class="native"/>
</id>
<many-to-one
class="uniandes.carotida.db.hibernate.generation.java.Angioescanografia"
fetch="select" name="Angioescanografia">
<column name="idAngioescanografia" not-null="true"/>
</many-to-one>
<property name="composicion" type="int">
<column
check="Composicion = 0 OR Composicion = 1 OR Composicion = 2"
name="composicion" not-null="true"/>
</property>
<property name="gradoestenosis" type="int">
<column name="gradoestenosis" not-null="true"/>
</property>
<property name="ubicacion" type="int">
<column
check="Ubicacion = 0 OR Ubicacion = 1 OR Ubicacion = 2"
name="ubicacion" not-null="true"/>
</property>
<property name="situacion" type="int">
<column check="Situacion = 0 OR Situacion = 1"
name="situacion" not-null="true"/>
</property>
<property name="localizacion" type="int">
<column
check="Localizacion >= 100 AND Localizacion &lt;= null"
name="localizacion" not-null="true"/>
</property>
<property name="longitud" type="float">
<column check="Longitud >= 100.0 AND Longitud &lt;= null"
name="longitud" not-null="true" precision="12" scale="0"/>
</property>
<property name="superficie" type="int">
<column
check="Superficie = 0 OR Superficie = 1 OR Superficie = 2"
name="superficie" not-null="true"/>
</property>
</class>
</hibernate-mapping>


Entity Name: Placa_iacid
<?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 catalog="carotida"
name="uniandes.carotida.db.hibernate.generation.java.Placa_iacid" table="placa_iacid">
<id name="idPlaca_iacid" type="int">
<column name="id_placa_iacid"/>
<generator class="native"/>
</id>
<many-to-one
class="uniandes.carotida.db.hibernate.generation.java.Iacid"
fetch="select" name="Iacid">
<column name="idIacid" not-null="true"/>
</many-to-one>
<property name="gradoestenosis" type="int">
<column name="gradoestenosis" not-null="true"/>
</property>
<property name="composicion" type="int">
<column
check="Composicion = 0 OR Composicion = 1 OR Composicion = 2"
name="composicion" not-null="true"/>
</property>
<property name="ubicacion" type="int">
<column
check="Ubicacion = 0 OR Ubicacion = 1 OR Ubicacion = 2"
name="ubicacion" not-null="true"/>
</property>
<property name="situacion" type="int">
<column check="Situacion = 0 OR Situacion = 1"
name="situacion" not-null="true"/>
</property>
<property name="localizacion" type="float">
<column
check="Localizacion >= 10.0 AND Localizacion &lt;= null"
name="localizacion" not-null="true" precision="12" scale="0"/>
</property>
</class>
</hibernate-mapping>


Entity Name: Informacionserie

<?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 catalog="carotida"
name="uniandes.carotida.db.hibernate.generation.java.Informacionserie" table="informacionserie">
<id name="idInformacionserie" type="int">
<column name="id_informacionserie"/>
<generator class="native"/>
</id>
<set inverse="true" name="Angioescanografias">
<key>
<column name="idInformacionserie" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Angioescanografia"/>
</set>
<set inverse="true" name="Angioresonancias">
<key>
<column name="idInformacionserie" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Angioresonancia"/>
</set>
<set inverse="true" name="Asds">
<key>
<column name="idInformacionserie" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Asd"/>
</set>
<set inverse="true" name="Ecodopplers">
<key>
<column name="idInformacionserie" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Ecodoppler"/>
</set>
<set inverse="true" name="Ecomodobs">
<key>
<column name="idInformacionserie" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Ecomodob"/>
</set>
<set inverse="true" name="Iacids">
<key>
<column name="idInformacionserie" not-null="true"/>
</key>
<one-to-many class="uniandes.carotida.db.hibernate.generation.java.Iacid"/>
</set>
<many-to-one
class="uniandes.carotida.db.hibernate.generation.java.Informacionpaciente"
fetch="select" name="Informacionpaciente">
<column name="idInformacionpaciente" not-null="true"/>
</many-to-one>
<property name="descripcion" type="string">
<column length="200" name="descripcion" not-null="true"/>
</property>
<property name="fecharealizacion" type="timestamp">
<column length="19" name="fecharealizacion" not-null="true"/>
</property>
<property name="fechaingreso" type="timestamp">
<column length="19" name="fechaingreso" not-null="true"/>
</property>
<property name="ubicacion" type="string">
<column length="200" name="ubicacion" not-null="true"/>
</property>
<property name="tipo" type="string">
<column
check="Tipo = '0' OR Tipo = '1' OR Tipo = '2' OR Tipo = '3' OR Tipo = '4'"
length="200" name="tipo" not-null="true"/>
</property>
</class>
</hibernate-mapping>


and I am trying to create this query:

select InformacionPaciente.cedula, APlaca.*

from InformacionPaciente IP, informacionSerie IS, IACID I, IACID_PLACA IPLACA,
Angioescanografia A, placa_Angeioescanografia APlaca

where IPlaca.ubicacion = APlaca.ubicacion
AND IPlaca.localizacion = APlaca.localizacion
AND IPlaca.gradoEstenosis > APlaca.gradoEstenosis
AND InformacionPaciente.cedula = IS.idInformacionPaciente
AND informacionSerie.idSerie = IACID.idSerie
AND informacionSerie.idSerie = A.idSerie
AND IACID .idIACID = IPlaca.idIACID
AND A.idAngio = APlaca.idIAngio

Using criteria queries, and I haven't been able to get arround it, i always get a
[STDERR] org.hibernate.QueryException: could not resolve property: exception, has anyone some clue of how to get this done?


Top
 Profile  
 
 Post subject: Query - case sensitive
PostPosted: Mon Dec 11, 2006 9:14 pm 
Beginner
Beginner

Joined: Thu Apr 27, 2006 12:19 pm
Posts: 33
Location: Seattle, WA
The query you give as an example is an HQL query? It doesn't look like it respects case sensitivity.

You say you are trying to use "criteria queries," which means you are trying to use the Hibernate Criteria API? I don't see any Criteria API code; are you actually trying to write an HQL query?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 2:00 pm 
Newbie

Joined: Fri Nov 17, 2006 12:18 pm
Posts: 6
the query is an SQL query on the other hand I am trying to use the Criteria API to do the query.
All the code ive written, well it doesn't work and i've gone through the forums and documentations and i haven't been able to find anything. That's basically why I am posting. I'd be very thankful if anyone could help me out on this one!i
Cheers
Sergio


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 5:46 pm 
Newbie

Joined: Fri Nov 17, 2006 12:18 pm
Posts: 6
Hey I've been working and I found out a way to do it.
So here's the code snippet that does it, it works for me so thnx!


Code:
crit = sessions.getCurrentSession( ).createCriteria( Informacionpaciente.class );
        crit.createAlias( "Informacionseries", "Informacionseries" );
        crit.createAlias( "Informacionseries.Iacids", "Informacionseries.Iacids" );
        crit.createAlias( "Informacionseries.Angioescanografias", "Informacionseries.Angioescanografias" );
        crit.createAlias( "Informacionseries.Iacids.Placa_iacids", "Informacionseries.Iacids.Placa_iacids");
        crit.createAlias( "Informacionseries.Angioescanografias.Placa_angioescanografias", "Informacionseries.Angioescanografias.Placa_angioescanografias");
       List l=crit.list( );
       


I hope this is useful to anyone!
Cheers


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