All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.type.descriptor.converter.AttributeConverterMutabilityPlanImpl Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha1
Show newest version
/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or .
 */
package org.hibernate.type.descriptor.converter;

import org.hibernate.metamodel.model.convert.spi.JpaAttributeConverter;
import org.hibernate.type.descriptor.java.MutableMutabilityPlan;

/**
 * The standard aproach for defining a MutabilityPlan for converted (AttributeConverter)
 * values is to always assume that they are immutable to make sure that dirty checking,
 * deep copying and second-level caching all work properly no matter what.  That was work
 * done under https://hibernate.atlassian.net/browse/HHH-10111
 *
 * However a series of approaches to tell Hibernate that the values are immutable were
 * documented as part of https://hibernate.atlassian.net/browse/HHH-10127
 *
 * @author Steve Ebersole
 */
public class AttributeConverterMutabilityPlanImpl extends MutableMutabilityPlan {
	private final JpaAttributeConverter converter;

	public AttributeConverterMutabilityPlanImpl(JpaAttributeConverter converter) {
		this.converter = converter;
	}

	@Override
	@SuppressWarnings("unchecked")
	protected T deepCopyNotNull(T value) {
		return (T) converter.toDomainValue( converter.toRelationalValue( value ) );
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy