HHH-13760 Code formatting changes & suggested logic simplification
This commit is contained in:
parent
d1b32d2b65
commit
b3ea1d67c4
|
@ -54,23 +54,15 @@ public class ToOneIdMapper extends AbstractToOneMapper {
|
|||
Object oldObj) {
|
||||
final HashMap<String, Object> newData = new HashMap<>();
|
||||
|
||||
Object oldObject = oldObj;
|
||||
Object newObject = newObj;
|
||||
if ( lazyMapping ) {
|
||||
if ( nonInsertableFake && oldObject instanceof HibernateProxy ) {
|
||||
oldObject = ( (HibernateProxy) oldObject ).getHibernateLazyInitializer().getImplementation();
|
||||
}
|
||||
|
||||
|
||||
if ( !nonInsertableFake && newObject instanceof HibernateProxy ) {
|
||||
newObject = ( (HibernateProxy) newObject ).getHibernateLazyInitializer().getImplementation();
|
||||
}
|
||||
// If this property is originally non-insertable, but made insertable because it is in a many-to-one "fake"
|
||||
// bi-directional relation, we always store the "old", unchanged data, to prevent storing changes made
|
||||
// to this field. It is the responsibility of the collection to properly update it if it really changed.
|
||||
Object entity = nonInsertableFake ? oldObj : newObj;
|
||||
if ( lazyMapping && entity instanceof HibernateProxy ) {
|
||||
entity = ( (HibernateProxy) entity ).getHibernateLazyInitializer().getImplementation();
|
||||
}
|
||||
|
||||
// If this property is originally non-insertable, but made insertable because it is in a many-to-one "fake"
|
||||
// bi-directional relation, we always store the "old", unchaged data, to prevent storing changes made
|
||||
// to this field. It is the responsibility of the collection to properly update it if it really changed.
|
||||
delegate.mapToMapFromEntity( newData, nonInsertableFake ? oldObject : newObject );
|
||||
delegate.mapToMapFromEntity( newData, entity );
|
||||
|
||||
for ( Map.Entry<String, Object> entry : newData.entrySet() ) {
|
||||
data.put( entry.getKey(), entry.getValue() );
|
||||
|
|
|
@ -39,10 +39,10 @@ public abstract class BaseDomainEntity extends BaseDomainEntityMetadata {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
if ( o == null || getClass() != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
BaseDomainEntity that = (BaseDomainEntity) o;
|
||||
|
@ -51,6 +51,6 @@ public abstract class BaseDomainEntity extends BaseDomainEntityMetadata {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
return Objects.hash( id );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public class Shipment extends BaseDomainEntity {
|
|||
Shipment(Instant when, String who, Instant dueDate, String identifier, AddressVersion origin, AddressVersion dest) {
|
||||
super( when, who );
|
||||
this.dueDate = dueDate;
|
||||
this.identifier = Objects.requireNonNull(identifier );
|
||||
this.identifier = Objects.requireNonNull( identifier );
|
||||
this.origin = origin;
|
||||
this.destination = dest;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue