Problem with ManyToOne to a unique key on merge when old value is null

Description

Entity 1:

1 2 3 @ManyToOne(fetch=FetchType.LAZY,cascade=CascadeType.REFRESH) @JoinColumn(name = "UPC", referencedColumnName = "CLAVE_PRO",unique=false,insertable=false,updatable=false) private RhDatosPersonales upcRrhh;

Entity 2:

1 2 3 4 5 6 @Id @Column(name = "NUM", nullable = false) private BigDecimal num; @Column(name = "CLAVE_PRO",unique=true,insertable=false,updatable=false,nullable=true) private Long clavePro;

Exception

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Caused by: java.lang.ClassCastException: org.kyrian.entity.rrhh.RhDatosPersonales cannot be cast to java.math.BigDecimal at org.hibernate.type.descriptor.java.BigDecimalTypeDescriptor.areEqual(BigDecimalTypeDescriptor.java:36) at org.hibernate.type.AbstractStandardBasicType.isEqual(AbstractStandardBasicType.java:183) at org.hibernate.type.AbstractStandardBasicType.isSame(AbstractStandardBasicType.java:168) at org.hibernate.type.AbstractStandardBasicType.isDirty(AbstractStandardBasicType.java:213) at org.hibernate.type.AbstractStandardBasicType.isDirty(AbstractStandardBasicType.java:205) at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:268) at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:277) at org.hibernate.type.TypeHelper.findDirty(TypeHelper.java:296) at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:3378) at org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:520) at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:230) at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:154) at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219) at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383) at org.hibernate.transaction.synchronization.CallbackCoordinator.beforeCompletion(CallbackCoordinator.java:117)

Environment

None

Status

Assignee

Unassigned

Reporter

Marcial AtiƩnzar Navarro

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

3.6.0

Priority

Major