|
41 | 41 | import org.hibernate.metamodel.mapping.ManagedMappingType;
|
42 | 42 | import org.hibernate.metamodel.mapping.ModelPart;
|
43 | 43 | import org.hibernate.persister.entity.EntityPersister;
|
| 44 | +import org.hibernate.persister.entity.UniqueKeyEntry; |
44 | 45 | import org.hibernate.property.access.internal.PropertyAccessStrategyBackRefImpl;
|
45 | 46 | import org.hibernate.proxy.LazyInitializer;
|
46 | 47 | import org.hibernate.proxy.map.MapProxy;
|
@@ -1034,32 +1035,27 @@ private void putInCache(
|
1034 | 1035 | }
|
1035 | 1036 | }
|
1036 | 1037 |
|
1037 |
| - protected void registerPossibleUniqueKeyEntries(Object toInitialize, SharedSessionContractImplementor session) { |
1038 |
| - for ( Type propertyType : concreteDescriptor.getPropertyTypes() ) { |
1039 |
| - if ( propertyType instanceof AssociationType ) { |
1040 |
| - final AssociationType associationType = (AssociationType) propertyType; |
1041 |
| - final String ukName = associationType.getLHSPropertyName(); |
1042 |
| - if ( ukName != null ) { |
1043 |
| - final int index = concreteDescriptor.findAttributeMapping( ukName ).getStateArrayPosition(); |
1044 |
| - final Type type = concreteDescriptor.getPropertyTypes()[index]; |
1045 |
| - |
1046 |
| - // polymorphism not really handled completely correctly, |
1047 |
| - // perhaps...well, actually its ok, assuming that the |
1048 |
| - // entity name used in the lookup is the same as the |
1049 |
| - // one used here, which it will be |
1050 |
| - |
1051 |
| - if ( resolvedEntityState[index] != null ) { |
1052 |
| - final EntityUniqueKey euk = new EntityUniqueKey( |
1053 |
| - concreteDescriptor.getRootEntityDescriptor().getEntityName(), |
1054 |
| - //polymorphism comment above |
1055 |
| - ukName, |
1056 |
| - resolvedEntityState[index], |
1057 |
| - type, |
1058 |
| - session.getFactory() |
1059 |
| - ); |
1060 |
| - session.getPersistenceContextInternal().addEntity( euk, toInitialize ); |
1061 |
| - } |
1062 |
| - } |
| 1038 | + protected void registerPossibleUniqueKeyEntries(final Object toInitialize, final SharedSessionContractImplementor session) { |
| 1039 | + for ( UniqueKeyEntry entry : concreteDescriptor.uniqueKeyEntries() ) { |
| 1040 | + final String ukName = entry.getUniqueKeyName(); |
| 1041 | + final int index = entry.getStateArrayPosition();//concreteDescriptor.findAttributeMapping( ukName ).getStateArrayPosition(); |
| 1042 | + final Type type = entry.getPropertyType();//concreteDescriptor.getPropertyTypes()[index]; |
| 1043 | + |
| 1044 | + // polymorphism not really handled completely correctly, |
| 1045 | + // perhaps...well, actually its ok, assuming that the |
| 1046 | + // entity name used in the lookup is the same as the |
| 1047 | + // one used here, which it will be |
| 1048 | + |
| 1049 | + if ( resolvedEntityState[index] != null ) { |
| 1050 | + final EntityUniqueKey euk = new EntityUniqueKey( |
| 1051 | + concreteDescriptor.getRootEntityDescriptor().getEntityName(), |
| 1052 | + //polymorphism comment above |
| 1053 | + ukName, |
| 1054 | + resolvedEntityState[index], |
| 1055 | + type, |
| 1056 | + session.getFactory() |
| 1057 | + ); |
| 1058 | + session.getPersistenceContextInternal().addEntity( euk, toInitialize ); |
1063 | 1059 | }
|
1064 | 1060 | }
|
1065 | 1061 | }
|
|
0 commit comments