dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #43745
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22180: Reverted r 22178
------------------------------------------------------------
revno: 22180
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2016-03-08 10:02:13 +0100
message:
Reverted r 22178
modified:
dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.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-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2016-03-08 08:34:43 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2016-03-08 09:02:13 +0000
@@ -54,6 +54,8 @@
import org.hisp.dhis.hibernate.exception.ReadAccessDeniedException;
import org.hisp.dhis.hibernate.exception.UpdateAccessDeniedException;
import org.hisp.dhis.interpretation.Interpretation;
+import org.hisp.dhis.schema.Schema;
+import org.hisp.dhis.schema.SchemaService;
import org.hisp.dhis.security.acl.AccessStringHelper;
import org.hisp.dhis.security.acl.AclService;
import org.hisp.dhis.user.CurrentUserService;
@@ -91,6 +93,9 @@
@Autowired
protected CurrentUserService currentUserService;
+ @Autowired
+ protected SchemaService schemaService;
+
/**
* Allows injection (e.g. by a unit test)
*/
@@ -559,6 +564,13 @@
@SuppressWarnings( "unchecked" )
public T getByAttribute( Attribute attribute )
{
+ Schema schema = schemaService.getDynamicSchema( getClazz() );
+
+ if ( schema == null || !schema.havePersistedProperty( "attributeValues" ) )
+ {
+ return null;
+ }
+
Criteria criteria = getCriteria();
criteria.createAlias( "attributeValues", "av" );
criteria.add( Restrictions.eq( "av.attribute", attribute ) );
@@ -570,6 +582,13 @@
@SuppressWarnings( "unchecked" )
public List<AttributeValue> getAttributeValueByAttribute( Attribute attribute )
{
+ Schema schema = schemaService.getDynamicSchema( getClazz() );
+
+ if ( schema == null || !schema.havePersistedProperty( "attributeValues" ) )
+ {
+ return null;
+ }
+
String hql = "select av from " + getClazz().getSimpleName() + " as e " +
"inner join e.attributeValues av inner join av.attribute at where at = :attribute )";
@@ -580,6 +599,13 @@
@SuppressWarnings( "unchecked" )
public List<AttributeValue> getAttributeValueByAttributeAndValue( Attribute attribute, String value )
{
+ Schema schema = schemaService.getDynamicSchema( getClazz() );
+
+ if ( schema == null || !schema.havePersistedProperty( "attributeValues" ) )
+ {
+ return null;
+ }
+
String hql = "select av from " + getClazz().getSimpleName() + " as e " +
"inner join e.attributeValues av inner join av.attribute at where at = :attribute and av.value = :value)";