@@ -488,7 +488,7 @@ public Type getSemiResolvedType(SessionFactoryImplementor factory) {
488
488
return getAssociatedEntityPersister ( factory ).getIdentifierType ();
489
489
}
490
490
491
- protected EntityPersister getAssociatedEntityPersister (final SessionFactoryImplementor factory ) {
491
+ public EntityPersister getAssociatedEntityPersister (final SessionFactoryImplementor factory ) {
492
492
final EntityPersister persister = associatedEntityPersister ;
493
493
//The following branch implements a simple lazy-initialization, but rather than the canonical
494
494
//form it returns the local variable to avoid a second volatile read: associatedEntityPersister
@@ -503,7 +503,7 @@ protected EntityPersister getAssociatedEntityPersister(final SessionFactoryImple
503
503
}
504
504
505
505
protected final Object getIdentifier (Object value , SharedSessionContractImplementor session ) throws HibernateException {
506
- if ( isReferenceToPrimaryKey () || uniqueKeyPropertyName == null ) {
506
+ if ( isReferenceToIdentifierProperty () ) {
507
507
return ForeignKeys .getEntityIdentifierIfNotUnsaved (
508
508
getAssociatedEntityName (),
509
509
value ,
@@ -639,7 +639,7 @@ Type getIdentifierType(final SharedSessionContractImplementor session) {
639
639
* or unique key property name.
640
640
*/
641
641
public final Type getIdentifierOrUniqueKeyType (Mapping factory ) throws MappingException {
642
- if ( isReferenceToPrimaryKey () || uniqueKeyPropertyName == null ) {
642
+ if ( isReferenceToIdentifierProperty () ) {
643
643
return getIdentifierType ( factory );
644
644
}
645
645
else {
@@ -663,12 +663,14 @@ public final Type getIdentifierOrUniqueKeyType(Mapping factory) throws MappingEx
663
663
*/
664
664
public final String getIdentifierOrUniqueKeyPropertyName (Mapping factory )
665
665
throws MappingException {
666
- if ( isReferenceToPrimaryKey () || uniqueKeyPropertyName == null ) {
667
- return factory .getIdentifierPropertyName ( getAssociatedEntityName () );
668
- }
669
- else {
670
- return uniqueKeyPropertyName ;
671
- }
666
+ return isReferenceToIdentifierProperty ()
667
+ ? factory .getIdentifierPropertyName ( getAssociatedEntityName () )
668
+ : uniqueKeyPropertyName ;
669
+ }
670
+
671
+ public boolean isReferenceToIdentifierProperty () {
672
+ return isReferenceToPrimaryKey ()
673
+ || uniqueKeyPropertyName == null ;
672
674
}
673
675
674
676
/**
0 commit comments