=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java 2015-03-05 04:09:14 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java 2015-03-06 03:20:17 +0000 @@ -201,9 +201,14 @@ private boolean manyToMany; /** - * Is collection one-to-many. - */ - private boolean oneToMany; + * The hibernate role of the owning side. + */ + private String owningRole; + + /** + * The hibernate role of the inverse side (if many-to-many). + */ + private String inverseRole; public Property() { @@ -558,14 +563,26 @@ @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public boolean isOneToMany() - { - return oneToMany; - } - - public void setOneToMany( boolean oneToMany ) - { - this.oneToMany = oneToMany; + public String getOwningRole() + { + return owningRole; + } + + public void setOwningRole( String owningRole ) + { + this.owningRole = owningRole; + } + + @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public String getInverseRole() + { + return inverseRole; + } + + public void setInverseRole( String inverseRole ) + { + this.inverseRole = inverseRole; } public String key() === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/AbstractPropertyIntrospectorService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/AbstractPropertyIntrospectorService.java 2015-03-05 04:09:14 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/AbstractPropertyIntrospectorService.java 2015-03-06 03:20:17 +0000 @@ -140,6 +140,7 @@ LocalSessionFactoryBean sessionFactoryBean = getLocalSessionFactoryBean(); PersistentClass persistentClass = sessionFactoryBean.getConfiguration().getClassMapping( klass.getName() ); + SessionFactoryImplementor sessionFactoryImplementor = (SessionFactoryImplementor) sessionFactory; Iterator propertyIterator = persistentClass.getPropertyClosureIterator(); @@ -164,14 +165,22 @@ if ( property.isCollection() ) { + CollectionType collectionType = (CollectionType) type; - Collection collection = sessionFactoryBean.getConfiguration().getCollectionMapping( collectionType.getRole() ); + CollectionPersister persister = sessionFactoryImplementor.getCollectionPersister( collection.getRole() ); + property.setOwner( !collection.isInverse() ); + property.setManyToMany( persister.isManyToMany() ); - CollectionPersister collectionPersister = ((SessionFactoryImplementor) sessionFactory).getCollectionPersister( collection.getRole() ); - property.setOneToMany( collectionPersister.isOneToMany() ); - property.setManyToMany( collectionPersister.isManyToMany() ); + if ( property.isOwner() ) + { + property.setOwningRole( collectionType.getRole() ); + } + else + { + property.setInverseRole( collectionType.getRole() ); + } } if ( SingleColumnType.class.isInstance( type ) ) === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java 2015-03-06 03:20:17 +0000 @@ -123,6 +123,9 @@ property.setCollection( hibernateProperty.isCollection() ); property.setCascade( hibernateProperty.getCascade() ); property.setOwner( hibernateProperty.isOwner() ); + property.setManyToMany( hibernateProperty.isManyToMany() ); + property.setOwningRole( hibernateProperty.getOwningRole() ); + property.setInverseRole( hibernateProperty.getInverseRole() ); property.setGetterMethod( hibernateProperty.getGetterMethod() ); property.setSetterMethod( hibernateProperty.getSetterMethod() );