HHH-18060 - HbXmlTransformer work
* <map-key type/> * <element type/>
This commit is contained in:
parent
875e84b930
commit
bcf8d7bee8
|
@ -61,6 +61,7 @@ import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmListType;
|
||||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmManyToAnyCollectionElementType;
|
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmManyToAnyCollectionElementType;
|
||||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmManyToManyCollectionElementType;
|
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmManyToManyCollectionElementType;
|
||||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmManyToOneType;
|
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmManyToOneType;
|
||||||
|
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmMapKeyBasicType;
|
||||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmMapType;
|
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmMapType;
|
||||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmNamedNativeQueryType;
|
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmNamedNativeQueryType;
|
||||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmNamedQueryType;
|
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmNamedQueryType;
|
||||||
|
@ -129,7 +130,6 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbHbmFilterImpl;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbHqlImportImpl;
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbHqlImportImpl;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbIdClassImpl;
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbIdClassImpl;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbIdImpl;
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbIdImpl;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbInheritanceImpl;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbJoinColumnImpl;
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbJoinColumnImpl;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbManyToManyImpl;
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbManyToManyImpl;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbManyToOneImpl;
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbManyToOneImpl;
|
||||||
|
@ -164,7 +164,6 @@ import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import jakarta.persistence.ConstraintMode;
|
import jakarta.persistence.ConstraintMode;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.InheritanceType;
|
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
import jakarta.xml.bind.JAXBContext;
|
import jakarta.xml.bind.JAXBContext;
|
||||||
import jakarta.xml.bind.JAXBElement;
|
import jakarta.xml.bind.JAXBElement;
|
||||||
|
@ -1834,18 +1833,55 @@ public class HbmXmlTransformer {
|
||||||
else if ( source.getMapKey() != null ) {
|
else if ( source.getMapKey() != null ) {
|
||||||
if ( ! StringHelper.isEmpty( source.getMapKey().getFormulaAttribute() ) ) {
|
if ( ! StringHelper.isEmpty( source.getMapKey().getFormulaAttribute() ) ) {
|
||||||
handleUnsupported(
|
handleUnsupported(
|
||||||
"Transformation of formulas within map-keys are not supported - `%s`",
|
"Transformation of formula attribute within map-keys is not supported - `%s`",
|
||||||
origin
|
origin
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final JaxbMapKeyColumnImpl mapKey = new JaxbMapKeyColumnImpl();
|
if ( CollectionHelper.isNotEmpty( source.getMapKey().getColumnOrFormula() ) ) {
|
||||||
mapKey.setName( source.getMapKey().getColumnAttribute() );
|
handleUnsupported(
|
||||||
target.setMapKeyColumn( mapKey );
|
"Transformation of column/formula elements within map-keys is not supported - `%s`",
|
||||||
|
origin
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( StringHelper.isNotEmpty( source.getMapKey().getNode() ) ) {
|
||||||
|
handleUnsupported(
|
||||||
|
"Transformation of `node` attribute is not supported - %s",
|
||||||
|
origin
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String mapKeyType = resolveMapKeyType( source.getMapKey() );
|
||||||
|
if ( mapKeyType != null ) {
|
||||||
|
final JaxbUserTypeImpl jaxbMapKeyType = new JaxbUserTypeImpl();
|
||||||
|
target.setMapKeyType( jaxbMapKeyType );
|
||||||
|
jaxbMapKeyType.setValue( mapKeyType );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( StringHelper.isNotEmpty( source.getMapKey().getColumnAttribute() ) ) {
|
||||||
|
final JaxbMapKeyColumnImpl mapKeyColumn = new JaxbMapKeyColumnImpl();
|
||||||
|
mapKeyColumn.setName( source.getMapKey().getColumnAttribute() );
|
||||||
|
target.setMapKeyColumn( mapKeyColumn );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String resolveMapKeyType(JaxbHbmMapKeyBasicType mapKey) {
|
||||||
|
if ( StringHelper.isNotEmpty( mapKey.getTypeAttribute() ) ) {
|
||||||
|
return mapKey.getTypeAttribute();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( mapKey.getType() != null ) {
|
||||||
|
return StringHelper.nullIfEmpty( mapKey.getType().getName() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private Boolean invert(Boolean value) {
|
private Boolean invert(Boolean value) {
|
||||||
return invert( value, null );
|
return invert( value, null );
|
||||||
}
|
}
|
||||||
|
@ -1877,6 +1913,8 @@ public class HbmXmlTransformer {
|
||||||
transferCollectionBasicInfo( hbmCollection, target );
|
transferCollectionBasicInfo( hbmCollection, target );
|
||||||
transferCollectionTable( hbmCollection, target );
|
transferCollectionTable( hbmCollection, target );
|
||||||
|
|
||||||
|
transferElementTypeInfo( hbmCollection, element, target );
|
||||||
|
|
||||||
transferColumnsAndFormulas(
|
transferColumnsAndFormulas(
|
||||||
new ColumnAndFormulaSource() {
|
new ColumnAndFormulaSource() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1920,6 +1958,29 @@ public class HbmXmlTransformer {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void transferElementTypeInfo(
|
||||||
|
PluralAttributeInfo hbmCollection,
|
||||||
|
JaxbHbmBasicCollectionElementType element,
|
||||||
|
JaxbElementCollectionImpl target) {
|
||||||
|
if ( StringHelper.isNotEmpty( element.getTypeAttribute() ) ) {
|
||||||
|
final JaxbUserTypeImpl jaxbUserType = new JaxbUserTypeImpl();
|
||||||
|
target.setType( jaxbUserType );
|
||||||
|
jaxbUserType.setValue( element.getTypeAttribute() );
|
||||||
|
}
|
||||||
|
else if ( element.getType() != null && StringHelper.isNotEmpty( element.getType().getName() ) ) {
|
||||||
|
final JaxbUserTypeImpl jaxbUserType = new JaxbUserTypeImpl();
|
||||||
|
target.setType( jaxbUserType );
|
||||||
|
|
||||||
|
jaxbUserType.setValue( element.getType().getName() );
|
||||||
|
for ( JaxbHbmConfigParameterType hbmParam : element.getType().getConfigParameters() ) {
|
||||||
|
final JaxbConfigurationParameterImpl param = new JaxbConfigurationParameterImpl();
|
||||||
|
param.setName( hbmParam.getName() );
|
||||||
|
param.setValue( hbmParam.getValue() );
|
||||||
|
jaxbUserType.getParameters().add( param );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void transferElementInfo(
|
private void transferElementInfo(
|
||||||
PluralAttributeInfo hbmCollection,
|
PluralAttributeInfo hbmCollection,
|
||||||
JaxbHbmCompositeCollectionElementType compositeElement,
|
JaxbHbmCompositeCollectionElementType compositeElement,
|
||||||
|
|
|
@ -66,6 +66,10 @@ public interface JaxbPluralAttribute extends JaxbPersistentAttribute, JaxbLockab
|
||||||
|
|
||||||
void setMapKeyColumn(JaxbMapKeyColumnImpl value);
|
void setMapKeyColumn(JaxbMapKeyColumnImpl value);
|
||||||
|
|
||||||
|
JaxbUserTypeImpl getMapKeyType();
|
||||||
|
|
||||||
|
void setMapKeyType(JaxbUserTypeImpl value);
|
||||||
|
|
||||||
List<JaxbMapKeyJoinColumnImpl> getMapKeyJoinColumns();
|
List<JaxbMapKeyJoinColumnImpl> getMapKeyJoinColumns();
|
||||||
|
|
||||||
JaxbForeignKeyImpl getMapKeyForeignKey();
|
JaxbForeignKeyImpl getMapKeyForeignKey();
|
||||||
|
|
|
@ -0,0 +1,364 @@
|
||||||
|
/*
|
||||||
|
* 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.boot.models.xml.internal;
|
||||||
|
|
||||||
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbUserTypeImpl;
|
||||||
|
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||||
|
import org.hibernate.models.spi.MutableMemberDetails;
|
||||||
|
import org.hibernate.type.descriptor.java.BasicJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.BigDecimalJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.BigIntegerJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.BlobJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.BooleanJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.ByteJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.CalendarJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.CharacterJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.ClassJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.ClobJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.CurrencyJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.DateJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.DoubleJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.DurationJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.FloatJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.InetAddressJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.InstantJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.IntegerJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.LocalDateJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.LocalDateTimeJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.LocalTimeJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.LocaleJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.LongJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.NClobJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.OffsetDateTimeJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.OffsetTimeJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.ShortJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.StringJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.TimeZoneJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.UUIDJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.UrlJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.YearJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.ZoneIdJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.ZoneOffsetJavaType;
|
||||||
|
import org.hibernate.type.descriptor.java.ZonedDateTimeJavaType;
|
||||||
|
|
||||||
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public abstract class AbstractUserTypeCases implements UserTypeCases {
|
||||||
|
protected abstract void applyJavaTypeAnnotation(
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
Class<? extends BasicJavaType<?>> descriptor,
|
||||||
|
XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
protected abstract void applyTemporalPrecision(
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
@SuppressWarnings("deprecation") TemporalType temporalType,
|
||||||
|
XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleNone(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleCharacter(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, CharacterJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleString(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, StringJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleByte(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, ByteJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleBoolean(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, BooleanJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleShort(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, ShortJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleInteger(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, IntegerJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleLong(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, LongJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleDouble(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, DoubleJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleFloat(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, FloatJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleBigInteger(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, BigIntegerJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleBigDecimal(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, BigDecimalJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleUuid(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, UUIDJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleUrl(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, UrlJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleInetAddress(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, InetAddressJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleCurrency(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, CurrencyJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleLocale(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, LocaleJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleClass(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, ClassJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleBlob(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, BlobJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleClob(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, ClobJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleNClob(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, NClobJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleInstant(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, InstantJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleDuration(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, DurationJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleYear(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, YearJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleLocalDateTime(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, LocalDateTimeJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleLocalDate(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, LocalDateJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleLocalTime(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, LocalTimeJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleZonedDateTime(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, ZonedDateTimeJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleOffsetDateTime(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, OffsetDateTimeJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleOffsetTime(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, OffsetTimeJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleZoneId(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, ZoneIdJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleZoneOffset(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, ZoneOffsetJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleTimestamp(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, DateJavaType.class, xmlDocumentContext );
|
||||||
|
//noinspection deprecation
|
||||||
|
applyTemporalPrecision( memberDetails, TemporalType.TIMESTAMP, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleDate(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, DateJavaType.class, xmlDocumentContext );
|
||||||
|
//noinspection deprecation
|
||||||
|
applyTemporalPrecision( memberDetails, TemporalType.DATE, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleTime(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, DateJavaType.class, xmlDocumentContext );
|
||||||
|
//noinspection deprecation
|
||||||
|
applyTemporalPrecision( memberDetails, TemporalType.TIME, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleCalendar(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, CalendarJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleTimeZone(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotation( memberDetails, TimeZoneJavaType.class, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,92 @@
|
||||||
|
/*
|
||||||
|
* 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.boot.models.xml.internal;
|
||||||
|
|
||||||
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbUserTypeImpl;
|
||||||
|
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||||
|
import org.hibernate.models.spi.MutableMemberDetails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public interface UserTypeCases {
|
||||||
|
void handleNone(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleCharacter(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleString(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleByte(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleBoolean(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleShort(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleInteger(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleLong(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleDouble(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleFloat(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleBigInteger(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleBigDecimal(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleUuid(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleUrl(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleInetAddress(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleCurrency(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleLocale(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleClass(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleBlob(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleClob(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleNClob(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleInstant(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleDuration(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleYear(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleLocalDateTime(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleLocalDate(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleLocalTime(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleZonedDateTime(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleOffsetDateTime(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleOffsetTime(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleZoneId(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleZoneOffset(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleTimestamp(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleDate(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleTime(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleCalendar(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleTimeZone(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
|
||||||
|
void handleGeneral(JaxbUserTypeImpl jaxbType, MutableMemberDetails memberDetails, XmlDocumentContext xmlDocumentContext);
|
||||||
|
}
|
|
@ -0,0 +1,94 @@
|
||||||
|
/*
|
||||||
|
* 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.boot.models.xml.internal;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbUserTypeImpl;
|
||||||
|
import org.hibernate.boot.models.HibernateAnnotations;
|
||||||
|
import org.hibernate.boot.models.JpaAnnotations;
|
||||||
|
import org.hibernate.boot.models.annotations.internal.JavaTypeAnnotation;
|
||||||
|
import org.hibernate.boot.models.annotations.internal.MapKeyJavaTypeAnnotation;
|
||||||
|
import org.hibernate.boot.models.annotations.internal.MapKeyTemporalJpaAnnotation;
|
||||||
|
import org.hibernate.boot.models.annotations.internal.MapKeyTypeAnnotation;
|
||||||
|
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||||
|
import org.hibernate.models.spi.ClassDetails;
|
||||||
|
import org.hibernate.models.spi.MutableMemberDetails;
|
||||||
|
import org.hibernate.type.descriptor.java.BasicJavaType;
|
||||||
|
import org.hibernate.usertype.UserType;
|
||||||
|
|
||||||
|
import jakarta.persistence.MapKeyTemporal;
|
||||||
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class UserTypeCasesMapKey extends AbstractUserTypeCases {
|
||||||
|
public static final UserTypeCasesMapKey MAP_KEY_USER_TYPE_CASES = new UserTypeCasesMapKey();
|
||||||
|
|
||||||
|
public static void applyJavaTypeAnnotationStatic(
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
Class<? extends BasicJavaType<?>> descriptor,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
final MapKeyJavaTypeAnnotation javaTypeAnnotation = (MapKeyJavaTypeAnnotation) memberDetails.applyAnnotationUsage(
|
||||||
|
HibernateAnnotations.MAP_KEY_JAVA_TYPE,
|
||||||
|
xmlDocumentContext.getModelBuildingContext()
|
||||||
|
);
|
||||||
|
javaTypeAnnotation.value( descriptor );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void applyJavaTypeAnnotation(
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
Class<? extends BasicJavaType<?>> descriptor,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotationStatic( memberDetails, descriptor, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
protected void applyTemporalPrecision(
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
TemporalType temporalType,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
final MapKeyTemporal directUsage = memberDetails.getDirectAnnotationUsage( MapKeyTemporal.class );
|
||||||
|
if ( directUsage != null ) {
|
||||||
|
// make sure they match
|
||||||
|
if ( directUsage.value() != temporalType ) {
|
||||||
|
throw new org.hibernate.MappingException( String.format(
|
||||||
|
Locale.ROOT,
|
||||||
|
"Mismatch in expected TemporalType on %s; found %s and %s",
|
||||||
|
memberDetails,
|
||||||
|
directUsage.value(),
|
||||||
|
temporalType
|
||||||
|
) );
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final MapKeyTemporalJpaAnnotation temporalAnnotation = (MapKeyTemporalJpaAnnotation) memberDetails.applyAnnotationUsage(
|
||||||
|
JpaAnnotations.MAP_KEY_TEMPORAL,
|
||||||
|
xmlDocumentContext.getModelBuildingContext()
|
||||||
|
);
|
||||||
|
temporalAnnotation.value( temporalType );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleGeneral(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
final ClassDetails userTypeImpl = XmlAnnotationHelper.resolveJavaType( jaxbType.getValue(), xmlDocumentContext );
|
||||||
|
assert userTypeImpl.isImplementor( UserType.class );
|
||||||
|
final MapKeyTypeAnnotation typeAnn = (MapKeyTypeAnnotation) memberDetails.applyAnnotationUsage(
|
||||||
|
HibernateAnnotations.MAP_KEY_TYPE,
|
||||||
|
xmlDocumentContext.getModelBuildingContext()
|
||||||
|
);
|
||||||
|
typeAnn.value( userTypeImpl.toJavaClass() );
|
||||||
|
typeAnn.parameters( XmlAnnotationHelper.collectParameters( jaxbType.getParameters(), xmlDocumentContext ) );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
/*
|
||||||
|
* 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.boot.models.xml.internal;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.hibernate.boot.jaxb.mapping.spi.JaxbUserTypeImpl;
|
||||||
|
import org.hibernate.boot.models.HibernateAnnotations;
|
||||||
|
import org.hibernate.boot.models.JpaAnnotations;
|
||||||
|
import org.hibernate.boot.models.annotations.internal.JavaTypeAnnotation;
|
||||||
|
import org.hibernate.boot.models.annotations.internal.TemporalJpaAnnotation;
|
||||||
|
import org.hibernate.boot.models.annotations.internal.TypeAnnotation;
|
||||||
|
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
|
||||||
|
import org.hibernate.models.spi.ClassDetails;
|
||||||
|
import org.hibernate.models.spi.MutableMemberDetails;
|
||||||
|
import org.hibernate.type.descriptor.java.BasicJavaType;
|
||||||
|
import org.hibernate.usertype.UserType;
|
||||||
|
|
||||||
|
import jakarta.persistence.Temporal;
|
||||||
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class UserTypeCasesStandard extends AbstractUserTypeCases {
|
||||||
|
public static final UserTypeCasesStandard STANDARD_USER_TYPE_CASES = new UserTypeCasesStandard();
|
||||||
|
|
||||||
|
public static void applyJavaTypeAnnotationStatic(
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
Class<? extends BasicJavaType<?>> descriptor,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
final JavaTypeAnnotation javaTypeAnnotation = (JavaTypeAnnotation) memberDetails.applyAnnotationUsage(
|
||||||
|
HibernateAnnotations.JAVA_TYPE,
|
||||||
|
xmlDocumentContext.getModelBuildingContext()
|
||||||
|
);
|
||||||
|
javaTypeAnnotation.value( descriptor );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void applyJavaTypeAnnotation(
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
Class<? extends BasicJavaType<?>> descriptor,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
applyJavaTypeAnnotationStatic( memberDetails, descriptor, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
protected void applyTemporalPrecision(
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
TemporalType temporalType,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
final Temporal directUsage = memberDetails.getDirectAnnotationUsage( Temporal.class );
|
||||||
|
if ( directUsage != null ) {
|
||||||
|
// make sure they match
|
||||||
|
if ( directUsage.value() != temporalType ) {
|
||||||
|
throw new org.hibernate.MappingException( String.format(
|
||||||
|
Locale.ROOT,
|
||||||
|
"Mismatch in expected TemporalType on %s; found %s and %s",
|
||||||
|
memberDetails,
|
||||||
|
directUsage.value(),
|
||||||
|
temporalType
|
||||||
|
) );
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final TemporalJpaAnnotation temporalAnnotation = (TemporalJpaAnnotation) memberDetails.applyAnnotationUsage(
|
||||||
|
JpaAnnotations.TEMPORAL,
|
||||||
|
xmlDocumentContext.getModelBuildingContext()
|
||||||
|
);
|
||||||
|
temporalAnnotation.value( temporalType );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleGeneral(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
final ClassDetails userTypeImpl = XmlAnnotationHelper.resolveJavaType( jaxbType.getValue(), xmlDocumentContext );
|
||||||
|
assert userTypeImpl.isImplementor( UserType.class );
|
||||||
|
final TypeAnnotation typeAnn = (TypeAnnotation) memberDetails.applyAnnotationUsage(
|
||||||
|
HibernateAnnotations.TYPE,
|
||||||
|
xmlDocumentContext.getModelBuildingContext()
|
||||||
|
);
|
||||||
|
typeAnn.value( userTypeImpl.toJavaClass() );
|
||||||
|
typeAnn.parameters( XmlAnnotationHelper.collectParameters( jaxbType.getParameters(), xmlDocumentContext ) );
|
||||||
|
}
|
||||||
|
}
|
|
@ -133,7 +133,6 @@ import org.hibernate.boot.models.annotations.internal.TableGeneratorJpaAnnotatio
|
||||||
import org.hibernate.boot.models.annotations.internal.TableJpaAnnotation;
|
import org.hibernate.boot.models.annotations.internal.TableJpaAnnotation;
|
||||||
import org.hibernate.boot.models.annotations.internal.TargetXmlAnnotation;
|
import org.hibernate.boot.models.annotations.internal.TargetXmlAnnotation;
|
||||||
import org.hibernate.boot.models.annotations.internal.TemporalJpaAnnotation;
|
import org.hibernate.boot.models.annotations.internal.TemporalJpaAnnotation;
|
||||||
import org.hibernate.boot.models.annotations.internal.TypeAnnotation;
|
|
||||||
import org.hibernate.boot.models.annotations.internal.UniqueConstraintJpaAnnotation;
|
import org.hibernate.boot.models.annotations.internal.UniqueConstraintJpaAnnotation;
|
||||||
import org.hibernate.boot.models.annotations.internal.UuidGeneratorAnnotation;
|
import org.hibernate.boot.models.annotations.internal.UuidGeneratorAnnotation;
|
||||||
import org.hibernate.boot.models.annotations.spi.CustomSqlDetails;
|
import org.hibernate.boot.models.annotations.spi.CustomSqlDetails;
|
||||||
|
@ -158,41 +157,6 @@ import org.hibernate.models.spi.MutableClassDetails;
|
||||||
import org.hibernate.models.spi.MutableMemberDetails;
|
import org.hibernate.models.spi.MutableMemberDetails;
|
||||||
import org.hibernate.models.spi.SourceModelBuildingContext;
|
import org.hibernate.models.spi.SourceModelBuildingContext;
|
||||||
import org.hibernate.type.SqlTypes;
|
import org.hibernate.type.SqlTypes;
|
||||||
import org.hibernate.type.descriptor.java.BasicJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.BigDecimalJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.BigIntegerJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.BlobJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.BooleanJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.ByteJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.CalendarJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.CharacterJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.ClassJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.ClobJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.CurrencyJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.DateJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.DoubleJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.DurationJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.InetAddressJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.InstantJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.IntegerJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.LocalDateJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.LocalDateTimeJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.LocalTimeJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.LocaleJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.LongJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.NClobJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.OffsetDateTimeJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.OffsetTimeJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.ShortJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.StringJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.TimeZoneJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.UUIDJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.UrlJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.YearJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.ZoneIdJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.ZoneOffsetJavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.ZonedDateTimeJavaType;
|
|
||||||
import org.hibernate.usertype.UserType;
|
|
||||||
|
|
||||||
import jakarta.persistence.AssociationOverride;
|
import jakarta.persistence.AssociationOverride;
|
||||||
import jakarta.persistence.AttributeOverride;
|
import jakarta.persistence.AttributeOverride;
|
||||||
|
@ -203,7 +167,6 @@ import jakarta.persistence.EnumType;
|
||||||
import jakarta.persistence.Index;
|
import jakarta.persistence.Index;
|
||||||
import jakarta.persistence.PrimaryKeyJoinColumn;
|
import jakarta.persistence.PrimaryKeyJoinColumn;
|
||||||
import jakarta.persistence.SecondaryTable;
|
import jakarta.persistence.SecondaryTable;
|
||||||
import jakarta.persistence.Temporal;
|
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
import jakarta.persistence.UniqueConstraint;
|
import jakarta.persistence.UniqueConstraint;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
@ -226,6 +189,8 @@ import static org.hibernate.boot.models.JpaAnnotations.EXCLUDE_SUPERCLASS_LISTEN
|
||||||
import static org.hibernate.boot.models.JpaAnnotations.INDEX;
|
import static org.hibernate.boot.models.JpaAnnotations.INDEX;
|
||||||
import static org.hibernate.boot.models.JpaAnnotations.SECONDARY_TABLE;
|
import static org.hibernate.boot.models.JpaAnnotations.SECONDARY_TABLE;
|
||||||
import static org.hibernate.boot.models.JpaAnnotations.UNIQUE_CONSTRAINT;
|
import static org.hibernate.boot.models.JpaAnnotations.UNIQUE_CONSTRAINT;
|
||||||
|
import static org.hibernate.boot.models.xml.internal.UserTypeCasesMapKey.MAP_KEY_USER_TYPE_CASES;
|
||||||
|
import static org.hibernate.boot.models.xml.internal.UserTypeCasesStandard.STANDARD_USER_TYPE_CASES;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper for creating annotation from equivalent JAXB
|
* Helper for creating annotation from equivalent JAXB
|
||||||
|
@ -302,303 +267,191 @@ public class XmlAnnotationHelper {
|
||||||
JaxbUserTypeImpl jaxbType,
|
JaxbUserTypeImpl jaxbType,
|
||||||
MutableMemberDetails memberDetails,
|
MutableMemberDetails memberDetails,
|
||||||
XmlDocumentContext xmlDocumentContext) {
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
if ( jaxbType == null || StringHelper.isEmpty( jaxbType.getValue() ) ) {
|
applyUserType( jaxbType, memberDetails, STANDARD_USER_TYPE_CASES, xmlDocumentContext );
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final boolean wasSpecialCase = handleSpecialBasicTypeCases( jaxbType, memberDetails, xmlDocumentContext );
|
|
||||||
if ( wasSpecialCase ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final ClassDetails userTypeImpl = resolveJavaType( jaxbType.getValue(), xmlDocumentContext );
|
|
||||||
assert userTypeImpl.isImplementor( UserType.class );
|
|
||||||
final TypeAnnotation typeAnn = (TypeAnnotation) memberDetails.applyAnnotationUsage(
|
|
||||||
HibernateAnnotations.TYPE,
|
|
||||||
xmlDocumentContext.getModelBuildingContext()
|
|
||||||
);
|
|
||||||
typeAnn.value( userTypeImpl.toJavaClass() );
|
|
||||||
typeAnn.parameters( collectParameters( jaxbType.getParameters(), xmlDocumentContext ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean handleSpecialBasicTypeCases(
|
public static void applyMapKeyUserType(
|
||||||
JaxbUserTypeImpl jaxbType,
|
JaxbUserTypeImpl jaxbType,
|
||||||
MutableMemberDetails memberDetails,
|
MutableMemberDetails memberDetails,
|
||||||
XmlDocumentContext xmlDocumentContext) {
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "char" )
|
applyUserType( jaxbType, memberDetails, MAP_KEY_USER_TYPE_CASES, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void applyUserType(
|
||||||
|
JaxbUserTypeImpl jaxbType,
|
||||||
|
MutableMemberDetails memberDetails,
|
||||||
|
UserTypeCases cases,
|
||||||
|
XmlDocumentContext xmlDocumentContext) {
|
||||||
|
if ( jaxbType == null || StringHelper.isEmpty( jaxbType.getValue() ) ) {
|
||||||
|
cases.handleNone( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "char" )
|
||||||
|| jaxbType.getValue().equalsIgnoreCase( "character" )
|
|| jaxbType.getValue().equalsIgnoreCase( "character" )
|
||||||
|| Character.class.getName().equalsIgnoreCase( jaxbType.getValue() ) ) {
|
|| Character.class.getName().equalsIgnoreCase( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, CharacterJavaType.class, xmlDocumentContext );
|
cases.handleCharacter( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "string" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "string" )
|
|
||||||
|| String.class.getName().equalsIgnoreCase( jaxbType.getValue() ) ) {
|
|| String.class.getName().equalsIgnoreCase( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, StringJavaType.class, xmlDocumentContext );
|
cases.handleString( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "byte" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "byte" )
|
|
||||||
|| Byte.class.getName().equals( jaxbType.getValue() ) ) {
|
|| Byte.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, ByteJavaType.class, xmlDocumentContext );
|
cases.handleByte( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "boolean" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "boolean" )
|
|
||||||
|| Boolean.class.getName().equals( jaxbType.getValue() ) ) {
|
|| Boolean.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, BooleanJavaType.class, xmlDocumentContext );
|
cases.handleBoolean( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "short" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "short" )
|
|
||||||
|| Short.class.getName().equals( jaxbType.getValue() ) ) {
|
|| Short.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, ShortJavaType.class, xmlDocumentContext );
|
cases.handleShort( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "int" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "int" )
|
|
||||||
|| jaxbType.getValue().equalsIgnoreCase( "integer" )
|
|| jaxbType.getValue().equalsIgnoreCase( "integer" )
|
||||||
|| Integer.class.getName().equals( jaxbType.getValue() ) ) {
|
|| Integer.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, IntegerJavaType.class, xmlDocumentContext );
|
cases.handleInteger( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "long" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "long" )
|
|
||||||
|| Long.class.getName().equals( jaxbType.getValue() ) ) {
|
|| Long.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, LongJavaType.class, xmlDocumentContext );
|
cases.handleLong( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "double" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "double" )
|
|
||||||
|| Double.class.getName().equals( jaxbType.getValue() ) ) {
|
|| Double.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, DoubleJavaType.class, xmlDocumentContext );
|
cases.handleDouble( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "float" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "float" )
|
|
||||||
|| Float.class.getName().equals( jaxbType.getValue() ) ) {
|
|| Float.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, DoubleJavaType.class, xmlDocumentContext );
|
cases.handleFloat( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "biginteger" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "biginteger" )
|
|
||||||
|| jaxbType.getValue().equalsIgnoreCase( "big_integer" )
|
|| jaxbType.getValue().equalsIgnoreCase( "big_integer" )
|
||||||
|| BigInteger.class.getName().equals( jaxbType.getValue() ) ) {
|
|| BigInteger.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, BigIntegerJavaType.class, xmlDocumentContext );
|
cases.handleBigInteger( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "bigdecimal" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "bigdecimal" )
|
|
||||||
|| jaxbType.getValue().equalsIgnoreCase( "big_decimal" )
|
|| jaxbType.getValue().equalsIgnoreCase( "big_decimal" )
|
||||||
|| BigDecimal.class.getName().equals( jaxbType.getValue() ) ) {
|
|| BigDecimal.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, BigDecimalJavaType.class, xmlDocumentContext );
|
cases.handleBigDecimal( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "uuid" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "uuid" )
|
|
||||||
|| UUID.class.getName().equals( jaxbType.getValue() ) ) {
|
|| UUID.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, UUIDJavaType.class, xmlDocumentContext );
|
cases.handleUuid( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "url" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "url" )
|
|
||||||
|| URL.class.getName().equals( jaxbType.getValue() ) ) {
|
|| URL.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, UrlJavaType.class, xmlDocumentContext );
|
cases.handleUrl( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "inet" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "inet" )
|
|
||||||
|| jaxbType.getValue().equalsIgnoreCase( "inetaddress" )
|
|| jaxbType.getValue().equalsIgnoreCase( "inetaddress" )
|
||||||
|| jaxbType.getValue().equalsIgnoreCase( "inet_address" )
|
|| jaxbType.getValue().equalsIgnoreCase( "inet_address" )
|
||||||
|| InetAddress.class.getName().equals( jaxbType.getValue() ) ) {
|
|| InetAddress.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, InetAddressJavaType.class, xmlDocumentContext );
|
cases.handleInetAddress( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "currency" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "currency" )
|
|
||||||
|| Currency.class.getName().equals( jaxbType.getValue() ) ) {
|
|| Currency.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, CurrencyJavaType.class, xmlDocumentContext );
|
cases.handleCurrency( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "locale" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "locale" )
|
|
||||||
|| Locale.class.getName().equals( jaxbType.getValue() ) ) {
|
|| Locale.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, LocaleJavaType.class, xmlDocumentContext );
|
cases.handleLocale( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "class" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "class" )
|
|
||||||
|| Class.class.getName().equals( jaxbType.getValue() ) ) {
|
|| Class.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, ClassJavaType.class, xmlDocumentContext );
|
cases.handleClass( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "blob" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "blob" )
|
|
||||||
|| Blob.class.getName().equals( jaxbType.getValue() ) ) {
|
|| Blob.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, BlobJavaType.class, xmlDocumentContext );
|
cases.handleBlob( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "clob" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "clob" )
|
|
||||||
|| Clob.class.getName().equals( jaxbType.getValue() ) ) {
|
|| Clob.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, ClobJavaType.class, xmlDocumentContext );
|
cases.handleClob( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "nclob" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "nclob" )
|
|
||||||
|| NClob.class.getName().equals( jaxbType.getValue() ) ) {
|
|| NClob.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, NClobJavaType.class, xmlDocumentContext );
|
cases.handleNClob( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "instant" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "instant" )
|
|
||||||
|| Instant.class.getName().equals( jaxbType.getValue() ) ) {
|
|| Instant.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, InstantJavaType.class, xmlDocumentContext );
|
cases.handleInstant( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "duration" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "duration" )
|
|
||||||
|| Duration.class.getName().equals( jaxbType.getValue() ) ) {
|
|| Duration.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, DurationJavaType.class, xmlDocumentContext );
|
cases.handleDuration( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "year" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "year" )
|
|
||||||
|| Year.class.getName().equals( jaxbType.getValue() ) ) {
|
|| Year.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, YearJavaType.class, xmlDocumentContext );
|
cases.handleYear( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "localdatetime" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "localdatetime" )
|
|
||||||
|| jaxbType.getValue().equalsIgnoreCase( "local_date_time" )
|
|| jaxbType.getValue().equalsIgnoreCase( "local_date_time" )
|
||||||
|| LocalDateTime.class.getName().equals( jaxbType.getValue() ) ) {
|
|| LocalDateTime.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, LocalDateTimeJavaType.class, xmlDocumentContext );
|
cases.handleLocalDateTime( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "localdate" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "localdate" )
|
|
||||||
|| jaxbType.getValue().equalsIgnoreCase( "local_date" )
|
|| jaxbType.getValue().equalsIgnoreCase( "local_date" )
|
||||||
|| LocalDate.class.getName().equals( jaxbType.getValue() ) ) {
|
|| LocalDate.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, LocalDateJavaType.class, xmlDocumentContext );
|
cases.handleLocalDate( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "localtime" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "localtime" )
|
|
||||||
|| jaxbType.getValue().equalsIgnoreCase( "local_time" )
|
|| jaxbType.getValue().equalsIgnoreCase( "local_time" )
|
||||||
|| LocalTime.class.getName().equals( jaxbType.getValue() ) ) {
|
|| LocalTime.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, LocalTimeJavaType.class, xmlDocumentContext );
|
cases.handleLocalTime( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "zoneddatetime" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "zoneddatetime" )
|
|
||||||
|| jaxbType.getValue().equalsIgnoreCase( "zoned_date_time" )
|
|| jaxbType.getValue().equalsIgnoreCase( "zoned_date_time" )
|
||||||
|| ZonedDateTime.class.getName().equals( jaxbType.getValue() ) ) {
|
|| ZonedDateTime.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, ZonedDateTimeJavaType.class, xmlDocumentContext );
|
cases.handleZonedDateTime( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "offsetdatetime" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "offsetdatetime" )
|
|
||||||
|| jaxbType.getValue().equalsIgnoreCase( "offset_date_time" )
|
|| jaxbType.getValue().equalsIgnoreCase( "offset_date_time" )
|
||||||
|| OffsetDateTime.class.getName().equals( jaxbType.getValue() ) ) {
|
|| OffsetDateTime.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, OffsetDateTimeJavaType.class, xmlDocumentContext );
|
cases.handleOffsetDateTime( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "offsettime" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "offsettime" )
|
|
||||||
|| jaxbType.getValue().equalsIgnoreCase( "offset_time" )
|
|| jaxbType.getValue().equalsIgnoreCase( "offset_time" )
|
||||||
|| OffsetTime.class.getName().equals( jaxbType.getValue() ) ) {
|
|| OffsetTime.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, OffsetTimeJavaType.class, xmlDocumentContext );
|
cases.handleOffsetTime( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "zoneid" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "zoneid" )
|
|
||||||
|| jaxbType.getValue().equalsIgnoreCase( "zone_id" )
|
|| jaxbType.getValue().equalsIgnoreCase( "zone_id" )
|
||||||
|| ZoneId.class.getName().equals( jaxbType.getValue() ) ) {
|
|| ZoneId.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, ZoneIdJavaType.class, xmlDocumentContext );
|
cases.handleZoneId( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "zoneoffset" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "zoneoffset" )
|
|
||||||
|| jaxbType.getValue().equalsIgnoreCase( "zone_offset" )
|
|| jaxbType.getValue().equalsIgnoreCase( "zone_offset" )
|
||||||
|| ZoneOffset.class.getName().equals( jaxbType.getValue() ) ) {
|
|| ZoneOffset.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, ZoneOffsetJavaType.class, xmlDocumentContext );
|
cases.handleZoneOffset( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "timestamp" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "timestamp" )
|
|
||||||
|| jaxbType.getValue().equalsIgnoreCase( "time_stamp" )
|
|| jaxbType.getValue().equalsIgnoreCase( "time_stamp" )
|
||||||
|| java.util.Date.class.getName().equals( jaxbType.getValue() )
|
|| java.util.Date.class.getName().equals( jaxbType.getValue() )
|
||||||
|| Timestamp.class.getName().equals( jaxbType.getValue() ) ) {
|
|| Timestamp.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, DateJavaType.class, xmlDocumentContext );
|
cases.handleTimestamp( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
applyTemporalPrecision( memberDetails, TemporalType.TIMESTAMP, xmlDocumentContext );
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "date" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "date" )
|
|
||||||
|| java.sql.Date.class.getName().equals( jaxbType.getValue() ) ) {
|
|| java.sql.Date.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, DateJavaType.class, xmlDocumentContext );
|
cases.handleDate( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
applyTemporalPrecision( memberDetails, TemporalType.DATE, xmlDocumentContext );
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "time" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "time" )
|
|
||||||
|| java.sql.Time.class.getName().equals( jaxbType.getValue() ) ) {
|
|| java.sql.Time.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, DateJavaType.class, xmlDocumentContext );
|
cases.handleTime( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
applyTemporalPrecision( memberDetails, TemporalType.TIME, xmlDocumentContext );
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "calendar" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "calendar" )
|
|
||||||
|| jaxbType.getValue().equalsIgnoreCase( "gregoriancalendar" )
|
|| jaxbType.getValue().equalsIgnoreCase( "gregoriancalendar" )
|
||||||
|| jaxbType.getValue().equalsIgnoreCase( "gregorian_calendar" )
|
|| jaxbType.getValue().equalsIgnoreCase( "gregorian_calendar" )
|
||||||
|| Calendar.class.getName().equals( jaxbType.getValue() )
|
|| Calendar.class.getName().equals( jaxbType.getValue() )
|
||||||
|| GregorianCalendar.class.getName().equals( jaxbType.getValue() ) ) {
|
|| GregorianCalendar.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, CalendarJavaType.class, xmlDocumentContext );
|
cases.handleCalendar( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else if ( jaxbType.getValue().equalsIgnoreCase( "timezone" )
|
||||||
if ( jaxbType.getValue().equalsIgnoreCase( "timezone" )
|
|
||||||
|| jaxbType.getValue().equalsIgnoreCase( "time_zone" )
|
|| jaxbType.getValue().equalsIgnoreCase( "time_zone" )
|
||||||
|| TimeZone.class.getName().equals( jaxbType.getValue() ) ) {
|
|| TimeZone.class.getName().equals( jaxbType.getValue() ) ) {
|
||||||
applyJavaTypeAnnotation( memberDetails, TimeZoneJavaType.class, xmlDocumentContext );
|
cases.handleTimeZone( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
return false;
|
cases.handleGeneral( jaxbType, memberDetails, xmlDocumentContext );
|
||||||
}
|
|
||||||
|
|
||||||
private static void applyJavaTypeAnnotation(
|
|
||||||
MutableMemberDetails memberDetails,
|
|
||||||
Class<? extends BasicJavaType<?>> descriptor,
|
|
||||||
XmlDocumentContext xmlDocumentContext) {
|
|
||||||
final JavaTypeAnnotation javaTypeAnnotation = (JavaTypeAnnotation) memberDetails.applyAnnotationUsage(
|
|
||||||
HibernateAnnotations.JAVA_TYPE,
|
|
||||||
xmlDocumentContext.getModelBuildingContext()
|
|
||||||
);
|
|
||||||
javaTypeAnnotation.value( descriptor );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void applyTemporalPrecision(MutableMemberDetails memberDetails, TemporalType temporalType, XmlDocumentContext xmlDocumentContext) {
|
|
||||||
final Temporal directUsage = memberDetails.getDirectAnnotationUsage( Temporal.class );
|
|
||||||
if ( directUsage != null ) {
|
|
||||||
// make sure they match
|
|
||||||
if ( directUsage.value() != temporalType ) {
|
|
||||||
throw new org.hibernate.MappingException( String.format(
|
|
||||||
Locale.ROOT,
|
|
||||||
"Mismatch in expected TemporalType on %s; found %s and %s",
|
|
||||||
memberDetails,
|
|
||||||
directUsage.value(),
|
|
||||||
temporalType
|
|
||||||
) );
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final TemporalJpaAnnotation temporalAnnotation = (TemporalJpaAnnotation) memberDetails.applyAnnotationUsage(
|
|
||||||
JpaAnnotations.TEMPORAL,
|
|
||||||
xmlDocumentContext.getModelBuildingContext()
|
|
||||||
);
|
|
||||||
temporalAnnotation.value( temporalType );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Parameter[] NO_PARAMETERS = new Parameter[0];
|
private static final Parameter[] NO_PARAMETERS = new Parameter[0];
|
||||||
|
|
|
@ -150,6 +150,10 @@ public class CommonPluralAttributeProcessing {
|
||||||
columnAnn.apply( jaxbPluralAttribute.getMapKeyColumn(), xmlDocumentContext );
|
columnAnn.apply( jaxbPluralAttribute.getMapKeyColumn(), xmlDocumentContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( jaxbPluralAttribute.getMapKeyType() != null ) {
|
||||||
|
XmlAnnotationHelper.applyMapKeyUserType( jaxbPluralAttribute.getMapKeyType(), memberDetails, xmlDocumentContext );
|
||||||
|
}
|
||||||
|
|
||||||
JoinColumnProcessing.applyMapKeyJoinColumns(
|
JoinColumnProcessing.applyMapKeyJoinColumns(
|
||||||
jaxbPluralAttribute.getMapKeyJoinColumns(),
|
jaxbPluralAttribute.getMapKeyJoinColumns(),
|
||||||
memberDetails,
|
memberDetails,
|
||||||
|
|
|
@ -3290,7 +3290,10 @@
|
||||||
</xsd:sequence>
|
</xsd:sequence>
|
||||||
</xsd:choice>
|
</xsd:choice>
|
||||||
<xsd:choice>
|
<xsd:choice>
|
||||||
<xsd:element name="map-key-column" type="orm:map-key-column" minOccurs="0"/>
|
<xsd:sequence>
|
||||||
|
<xsd:element name="map-key-column" type="orm:map-key-column" minOccurs="0"/>
|
||||||
|
<xsd:element name="map-key-type" type="orm:user-type" minOccurs="0"/>
|
||||||
|
</xsd:sequence>
|
||||||
<xsd:sequence>
|
<xsd:sequence>
|
||||||
<xsd:element name="map-key-join-column" type="orm:map-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
|
<xsd:element name="map-key-join-column" type="orm:map-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
|
||||||
<xsd:element name="map-key-foreign-key" type="orm:foreign-key" minOccurs="0"/>
|
<xsd:element name="map-key-foreign-key" type="orm:foreign-key" minOccurs="0"/>
|
||||||
|
|
Loading…
Reference in New Issue