dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08821
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2203: Fix bug: Cannot search patients by PatientAttributeValue.
------------------------------------------------------------
revno: 2203
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2010-11-29 14:01:42 +0700
message:
Fix bug: Cannot search patients by PatientAttributeValue.
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java 2010-10-29 05:24:41 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java 2010-11-29 07:01:42 +0000
@@ -131,14 +131,22 @@
public Collection<Patient> searchPatients( PatientAttribute patientAttribute,
String searchText, int min, int max )
{
- return getCriteria( Restrictions.eq( "patientAttribute", patientAttribute ),
- Restrictions.ilike( "value", "'%" + searchText + "%'" ) ).setProjection( Projections.property( "patient" ) ).setFirstResult( min ).setMaxResults( max ).list();
+ String hql = "select pav.patient from PatientAttributeValue pav where pav.patientAttribute = :patientAttribute and pav.value like '%" + searchText + "%'";
+
+ Query query = getQuery( hql );
+ query.setEntity( "patientAttribute", patientAttribute );
+
+ return query.setFirstResult( min ).setMaxResults( max ).list();
}
@SuppressWarnings( "unchecked" )
public Collection<Patient> searchPatients( PatientAttribute patientAttribute, String searchText )
{
- return getCriteria( Restrictions.eq( "patientAttribute", patientAttribute ),
- Restrictions.ilike( "value", "'%" + searchText + "%'" ) ).setProjection( Projections.property( "patient" ) ).list();
+ String hql = "select pav.patient from PatientAttributeValue pav where pav.patientAttribute = :patientAttribute and pav.value like '%" + searchText + "%'";
+
+ Query query = getQuery( hql );
+ query.setEntity( "patientAttribute", patientAttribute );
+
+ return query.list();
}
}