Set correct key type if !referenceToPrimaryKey
This commit is contained in:
parent
3ea5a066ed
commit
91a720772f
|
@ -29,6 +29,7 @@ import org.hibernate.sql.results.graph.entity.AbstractEntityInitializer;
|
|||
import org.hibernate.sql.results.graph.entity.EntityInitializer;
|
||||
import org.hibernate.sql.results.graph.entity.LoadingEntityEntry;
|
||||
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
|
@ -113,11 +114,19 @@ public class EntityDelayedFetchInitializer extends AbstractFetchParentAccess imp
|
|||
else {
|
||||
if ( selectByUniqueKey ) {
|
||||
final String uniqueKeyPropertyName = referencedModelPart.getBidirectionalAttributeName();
|
||||
final Type uniqueKeyPropertyType = ( referencedModelPart.getReferencedPropertyName() == null ) ?
|
||||
concreteDescriptor.getIdentifierType() :
|
||||
session.getFactory()
|
||||
.getReferencedPropertyType(
|
||||
concreteDescriptor.getEntityName(),
|
||||
uniqueKeyPropertyName
|
||||
);
|
||||
|
||||
final EntityUniqueKey euk = new EntityUniqueKey(
|
||||
concreteDescriptor.getEntityName(),
|
||||
uniqueKeyPropertyName,
|
||||
identifier,
|
||||
concreteDescriptor.getIdentifierType(),
|
||||
uniqueKeyPropertyType,
|
||||
session.getFactory()
|
||||
);
|
||||
final PersistenceContext persistenceContext = session.getPersistenceContextInternal();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.uniquekey;
|
||||
package org.hibernate.orm.test.uniquekey;
|
||||
|
||||
import java.io.Serializable;
|
||||
import jakarta.persistence.Entity;
|
Loading…
Reference in New Issue