Permalink
Browse files

HHH-7108 HHH-6608

  • Loading branch information...
1 parent 45118e7 commit d0e13b664ae86d16c9d7d745c5b4f137756589ea @stliu stliu committed Aug 7, 2012
Showing with 993 additions and 102 deletions.
  1. +1 −0 hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java
  2. +8 −8 hibernate-core/src/main/java/org/hibernate/cfg/BinderHelper.java
  3. +3 −1 hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
  4. +20 −19 hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java
  5. +1 −0 hibernate-core/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java
  6. +89 −52 hibernate-core/src/main/java/org/hibernate/cfg/annotations/SimpleValueBinder.java
  7. +105 −3 hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java
  8. +62 −14 hibernate-core/src/main/java/org/hibernate/type/EnumType.java
  9. +45 −0 hibernate-core/src/main/java/org/hibernate/usertype/DynamicParameterizedType.java
  10. +93 −0 hibernate-core/src/test/java/org/hibernate/test/annotations/enumerated/EntityEnum.java
  11. +335 −0 hibernate-core/src/test/java/org/hibernate/test/annotations/enumerated/EnumeratedTypeTest.java
  12. +41 −0 hibernate-core/src/test/java/org/hibernate/test/annotations/enumerated/FirstLetterType.java
  13. +42 −0 hibernate-core/src/test/java/org/hibernate/test/annotations/enumerated/LastNumberType.java
  14. +29 −0 hibernate-core/src/test/java/org/hibernate/test/annotations/referencedcolumnname/HousePlaces.java
  15. +21 −0 hibernate-core/src/test/java/org/hibernate/test/annotations/referencedcolumnname/Place.java
  16. +22 −0 hibernate-core/src/test/java/org/hibernate/test/annotations/referencedcolumnname/Places.java
  17. +66 −1 ...e/src/test/java/org/hibernate/test/annotations/referencedcolumnname/ReferencedColumnNameTest.java
  18. +10 −4 ...nate-envers/src/main/java/org/hibernate/envers/configuration/metadata/BasicMetadataGenerator.java
@@ -2496,6 +2496,7 @@ private static void bindIdClass(
value.setPersistentClassName( persistentClassName );
value.setMappings( mappings );
value.setType( inferredData.getProperty(), inferredData.getClassOrElement() );
+ value.setAccessType( propertyAccessor );
id = value.make();
}
rootClass.setIdentifier( id );
@@ -268,15 +268,15 @@ public static void createSyntheticPropertyReference(
*/
StringBuilder propertyNameBuffer = new StringBuilder( "_" );
propertyNameBuffer.append( associatedClass.getEntityName().replace( '.', '_' ) );
- propertyNameBuffer.append( "_" ).append( columns[0].getPropertyName() );
+ propertyNameBuffer.append( "_" ).append( columns[0].getPropertyName().replace( '.', '_' ) );
String syntheticPropertyName = propertyNameBuffer.toString();
//find properties associated to a certain column
Object columnOwner = findColumnOwner( ownerEntity, columns[0].getReferencedColumn(), mappings );
List<Property> properties = findPropertiesByColumns( columnOwner, columns, mappings );
//create an embeddable component
- Property synthProp = null;
+ Property synthProp = null;
if ( properties != null ) {
- //todo how about properties.size() == 1, this should be much simpler
+ //todo how about properties.size() == 1, this should be much simpler
Component embeddedComp = columnOwner instanceof PersistentClass ?
new Component( mappings, (PersistentClass) columnOwner ) :
new Component( mappings, (Join) columnOwner );
@@ -290,8 +290,8 @@ public static void createSyntheticPropertyReference(
clone.setNaturalIdentifier( false );
clone.setGeneration( property.getGeneration() );
embeddedComp.addProperty( clone );
- }
- synthProp = new SyntheticProperty();
+ }
+ synthProp = new SyntheticProperty();
synthProp.setName( syntheticPropertyName );
synthProp.setNodeName( syntheticPropertyName );
synthProp.setPersistentClass( ownerEntity );
@@ -300,9 +300,9 @@ public static void createSyntheticPropertyReference(
synthProp.setValue( embeddedComp );
synthProp.setPropertyAccessorName( "embedded" );
ownerEntity.addProperty( synthProp );
- //make it unique
+ //make it unique
TableBinder.createUniqueConstraint( embeddedComp );
- }
+ }
else {
//TODO use a ToOne type doing a second select
StringBuilder columnsList = new StringBuilder();
@@ -830,7 +830,7 @@ static PropertyData getPropertyOverriddenByMapperOrMapsId(
for (int i = 0; i < aliases.length; i++){
if (StringHelper.isNotEmpty(aliases[i].table())){
ret.put(aliases[i].alias(), aliases[i].table());
- }
+}
}
return ret;
}
@@ -1289,6 +1289,8 @@ else if ( owner.getIdentifierMapper() != null && owner.getIdentifierMapper().get
}
elementBinder.setColumns( elementColumns );
elementBinder.setType( property, elementClass );
+ elementBinder.setPersistentClassName( propertyHolder.getEntityName() );
+ elementBinder.setAccessType( accessType );
collValue.setElement( elementBinder.make() );
String orderBy = adjustUserSuppliedValueCollectionOrderingFragment( hqlOrderBy );
if ( orderBy != null ) {
@@ -1439,4 +1441,4 @@ public void setMapKeyManyToManyColumns(Ejb3JoinColumn[] mapJoinColumns) {
public void setLocalGenerators(HashMap<String, IdGenerator> localGenerators) {
this.localGenerators = localGenerators;
}
-}
+}
@@ -210,26 +210,25 @@ private void bindKeyFromAssociationTable(
}
}
+ PersistentClass owner = mapValue.getOwner();
+ AccessType accessType;
+ // FIXME support @Access for collection of elements
+ // String accessType = access != null ? access.value() : null;
+ if ( owner.getIdentifierProperty() != null ) {
+ accessType = owner.getIdentifierProperty().getPropertyAccessorName().equals( "property" ) ? AccessType.PROPERTY
+ : AccessType.FIELD;
+ }
+ else if ( owner.getIdentifierMapper() != null && owner.getIdentifierMapper().getPropertySpan() > 0 ) {
+ Property prop = (Property) owner.getIdentifierMapper().getPropertyIterator().next();
+ accessType = prop.getPropertyAccessorName().equals( "property" ) ? AccessType.PROPERTY
+ : AccessType.FIELD;
+ }
+ else {
+ throw new AssertionFailure( "Unable to guess collection property accessor name" );
+ }
+
if ( AnnotatedClassType.EMBEDDABLE.equals( classType ) ) {
EntityBinder entityBinder = new EntityBinder();
- PersistentClass owner = mapValue.getOwner();
- boolean isPropertyAnnotated;
- //FIXME support @Access for collection of elements
- //String accessType = access != null ? access.value() : null;
- if ( owner.getIdentifierProperty() != null ) {
- isPropertyAnnotated = owner.getIdentifierProperty()
- .getPropertyAccessorName()
- .equals( "property" );
- }
- else
- if ( owner.getIdentifierMapper() != null && owner.getIdentifierMapper().getPropertySpan() > 0 ) {
- Property prop = (Property) owner.getIdentifierMapper().getPropertyIterator().next();
- isPropertyAnnotated = prop.getPropertyAccessorName().equals( "property" );
- }
- else {
- throw new AssertionFailure( "Unable to guess collection property accessor name" );
- }
-
PropertyData inferredData;
if ( isHibernateExtensionMapping() ) {
@@ -242,7 +241,7 @@ private void bindKeyFromAssociationTable(
//TODO be smart with isNullable
Component component = AnnotationBinder.fillComponent(
- holder, inferredData, isPropertyAnnotated ? AccessType.PROPERTY : AccessType.FIELD, true,
+ holder, inferredData, accessType, true,
entityBinder, false, false,
true, mappings, inheritanceStatePerClass
);
@@ -285,6 +284,8 @@ private void bindKeyFromAssociationTable(
else {
elementBinder.setType( property, elementClass );
}
+ elementBinder.setPersistentClassName( propertyHolder.getEntityName() );
+ elementBinder.setAccessType( accessType );
mapValue.setIndex( elementBinder.make() );
}
}
@@ -188,6 +188,7 @@ private Property makePropertyAndValue() {
simpleValueBinder.setType( property, returnedClass );
simpleValueBinder.setMappings( mappings );
simpleValueBinder.setReferencedEntityName( referencedEntityName );
+ simpleValueBinder.setAccessType( accessType );
SimpleValue propertyValue = simpleValueBinder.make();
setValue( propertyValue );
return makeProperty();
Oops, something went wrong.

0 comments on commit d0e13b6

Please sign in to comment.