org.hibernate.metamodel.model.convert.internal.JpaAttributeConverterImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
JPMS Module-Info's for a few of the Jakarta Libraries just until they add them in themselves
/*
* 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 http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.metamodel.model.convert.internal;
import javax.persistence.AttributeConverter;
import org.hibernate.metamodel.model.convert.spi.JpaAttributeConverter;
import org.hibernate.resource.beans.spi.ManagedBean;
import org.hibernate.type.descriptor.java.BasicJavaDescriptor;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
/**
* Standard implementation of JpaAttributeConverter
*
* @author Steve Ebersole
*/
public class JpaAttributeConverterImpl implements JpaAttributeConverter {
private final ManagedBean> attributeConverterBean;
private final JavaTypeDescriptor> converterJavaTypeDescriptor;
private final BasicJavaDescriptor domainJavaTypeDescriptor;
private final BasicJavaDescriptor relationalJavaTypeDescriptor;
public JpaAttributeConverterImpl(
ManagedBean> attributeConverterBean,
JavaTypeDescriptor> converterJavaTypeDescriptor,
JavaTypeDescriptor domainJavaTypeDescriptor,
JavaTypeDescriptor relationalJavaTypeDescriptor) {
this.attributeConverterBean = attributeConverterBean;
this.converterJavaTypeDescriptor = converterJavaTypeDescriptor;
this.domainJavaTypeDescriptor = (BasicJavaDescriptor) domainJavaTypeDescriptor;
this.relationalJavaTypeDescriptor = (BasicJavaDescriptor) relationalJavaTypeDescriptor;
}
@Override
public ManagedBean> getConverterBean() {
return attributeConverterBean;
}
@Override
public O toDomainValue(R relationalForm) {
return attributeConverterBean.getBeanInstance().convertToEntityAttribute( relationalForm );
}
@Override
public R toRelationalValue(O domainForm) {
return attributeConverterBean.getBeanInstance().convertToDatabaseColumn( domainForm );
}
@Override
public JavaTypeDescriptor> getConverterJavaTypeDescriptor() {
return converterJavaTypeDescriptor;
}
@Override
public BasicJavaDescriptor getDomainJavaTypeDescriptor() {
return domainJavaTypeDescriptor;
}
@Override
public BasicJavaDescriptor getRelationalJavaTypeDescriptor() {
return relationalJavaTypeDescriptor;
}
}