HHH-17377 - Migrate to JPA 3.2
https://hibernate.atlassian.net/browse/HHH-17377 XJB changes (JAXB "binding model")
This commit is contained in:
parent
11d83b5af9
commit
33c68b93ab
|
@ -80,7 +80,6 @@ import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmSetType;
|
|||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmSimpleIdType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmSynchronizeType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmTimestampAttributeType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmTypeDefinitionType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmUnionSubclassEntityType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmVersionAttributeType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.PluralAttributeInfo;
|
||||
|
@ -1482,8 +1481,8 @@ public class HbmXmlTransformer {
|
|||
final JaxbManyToOneImpl m2o = new JaxbManyToOneImpl();
|
||||
m2o.setAttributeAccessor( hbmNode.getAccess() );
|
||||
m2o.setCascade( convertCascadeType( hbmNode.getCascade() ) );
|
||||
m2o.setForeignKey( new JaxbForeignKeyImpl() );
|
||||
m2o.getForeignKey().setName( hbmNode.getForeignKey() );
|
||||
m2o.setForeignKeys( new JaxbForeignKeyImpl() );
|
||||
m2o.getForeignKeys().setName( hbmNode.getForeignKey() );
|
||||
|
||||
transferColumnsAndFormulas(
|
||||
new ColumnAndFormulaSource() {
|
||||
|
@ -1515,7 +1514,7 @@ public class HbmXmlTransformer {
|
|||
|
||||
@Override
|
||||
public void addColumn(TargetColumnAdapter column) {
|
||||
m2o.getJoinColumn().add( ( (TargetColumnAdapterJaxbJoinColumn) column ).getTargetColumn() );
|
||||
m2o.getJoinColumns().add( ( (TargetColumnAdapterJaxbJoinColumn) column ).getTargetColumn() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2294,15 +2293,15 @@ public class HbmXmlTransformer {
|
|||
m2o.setName( hbmM2O.getName() );
|
||||
m2o.setAttributeAccessor( hbmM2O.getAccess() );
|
||||
m2o.setFetch( convert( hbmM2O.getLazy() ) );
|
||||
m2o.setForeignKey( new JaxbForeignKeyImpl() );
|
||||
m2o.getForeignKey().setName( hbmM2O.getForeignKey() );
|
||||
m2o.setForeignKeys( new JaxbForeignKeyImpl() );
|
||||
m2o.getForeignKeys().setName( hbmM2O.getForeignKey() );
|
||||
if ( !hbmM2O.getColumn().isEmpty() ) {
|
||||
for ( JaxbHbmColumnType hbmColumn : hbmM2O.getColumn() ) {
|
||||
final JaxbJoinColumnImpl joinColumn = new JaxbJoinColumnImpl();
|
||||
joinColumn.setName( hbmColumn.getName() );
|
||||
joinColumn.setNullable( hbmColumn.isNotNull() == null ? null : !hbmColumn.isNotNull() );
|
||||
joinColumn.setUnique( hbmColumn.isUnique() );
|
||||
m2o.getJoinColumn().add( joinColumn );
|
||||
m2o.getJoinColumns().add( joinColumn );
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -2314,7 +2313,7 @@ public class HbmXmlTransformer {
|
|||
else {
|
||||
joinColumn.setName( hbmM2O.getColumnAttribute() );
|
||||
}
|
||||
m2o.getJoinColumn().add( joinColumn );
|
||||
m2o.getJoinColumns().add( joinColumn );
|
||||
}
|
||||
|
||||
if ( isNotEmpty( hbmM2O.getEntityName() ) ) {
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* 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.jaxb.mapping.internal;
|
||||
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class NotFoundActionMarshalling {
|
||||
public static NotFoundAction fromXml(String name) {
|
||||
return name == null ? null : NotFoundAction.valueOf( name );
|
||||
}
|
||||
|
||||
public static String toXml(NotFoundAction action) {
|
||||
return action == null ? null : action.name();
|
||||
}
|
||||
}
|
|
@ -92,13 +92,11 @@ public interface JaxbEntity extends JaxbEntityOrMappedSuperclass {
|
|||
String getDiscriminatorFormula();
|
||||
void setDiscriminatorFormula(String value);
|
||||
|
||||
JaxbSequenceGeneratorImpl getSequenceGenerator();
|
||||
void setSequenceGenerator(JaxbSequenceGeneratorImpl value);
|
||||
JaxbSequenceGeneratorImpl getSequenceGenerators();
|
||||
|
||||
JaxbTableGeneratorImpl getTableGenerator();
|
||||
void setTableGenerator(JaxbTableGeneratorImpl value);
|
||||
JaxbTableGeneratorImpl getTableGenerators();
|
||||
|
||||
List<JaxbGenericIdGeneratorImpl> getIdentifierGenerator();
|
||||
List<JaxbGenericIdGeneratorImpl> getIdentifierGenerators();
|
||||
|
||||
List<JaxbNamedQueryImpl> getNamedQueries();
|
||||
List<JaxbNamedNativeQueryImpl> getNamedNativeQueries();
|
||||
|
|
|
@ -24,7 +24,7 @@ public interface JaxbEntityOrMappedSuperclass extends JaxbManagedType, JaxbLifec
|
|||
|
||||
void setExcludeSuperclassListeners(JaxbEmptyTypeImpl value);
|
||||
|
||||
JaxbEntityListenersImpl getEntityListeners();
|
||||
JaxbEntityListenerContainerImpl getEntityListenerContainer();
|
||||
|
||||
void setEntityListeners(JaxbEntityListenersImpl value);
|
||||
void setEntityListenerContainer(JaxbEntityListenerContainerImpl value);
|
||||
}
|
||||
|
|
|
@ -6,10 +6,12 @@
|
|||
*/
|
||||
package org.hibernate.boot.jaxb.mapping.spi;
|
||||
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface JaxbNotFoundCapable extends JaxbPersistentAttribute {
|
||||
JaxbNotFoundEnumImpl getNotFound();
|
||||
void setNotFound(JaxbNotFoundEnumImpl value);
|
||||
NotFoundAction getNotFound();
|
||||
void setNotFound(NotFoundAction value);
|
||||
}
|
||||
|
|
|
@ -52,15 +52,15 @@ public interface JaxbPluralAttribute extends JaxbPersistentAttribute, JaxbLockab
|
|||
|
||||
void setMapKeyEnumerated(EnumType value);
|
||||
|
||||
List<JaxbAttributeOverrideImpl> getMapKeyAttributeOverride();
|
||||
List<JaxbAttributeOverrideImpl> getMapKeyAttributeOverrides();
|
||||
|
||||
List<JaxbConvertImpl> getMapKeyConvert();
|
||||
List<JaxbConvertImpl> getMapKeyConverts();
|
||||
|
||||
JaxbMapKeyColumnImpl getMapKeyColumn();
|
||||
|
||||
void setMapKeyColumn(JaxbMapKeyColumnImpl value);
|
||||
|
||||
List<JaxbMapKeyJoinColumnImpl> getMapKeyJoinColumn();
|
||||
List<JaxbMapKeyJoinColumnImpl> getMapKeyJoinColumns();
|
||||
|
||||
JaxbForeignKeyImpl getMapKeyForeignKey();
|
||||
|
||||
|
|
|
@ -60,8 +60,8 @@ import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddedImpl;
|
|||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEmptyTypeImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntity;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityListenerContainerImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityListenerImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityListenersImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityOrMappedSuperclass;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityResultImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbFieldResultImpl;
|
||||
|
@ -341,14 +341,12 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
this.xmlContext = xmlContext;
|
||||
this.classLoaderAccess = classLoaderAccess;
|
||||
|
||||
if ( el instanceof Class ) {
|
||||
Class clazz = (Class) el;
|
||||
if ( el instanceof Class clazz ) {
|
||||
className = clazz.getName();
|
||||
propertyName = null;
|
||||
propertyType = null;
|
||||
}
|
||||
else if ( el instanceof Field ) {
|
||||
Field field = (Field) el;
|
||||
else if ( el instanceof Field field ) {
|
||||
className = field.getDeclaringClass().getName();
|
||||
propertyName = field.getName();
|
||||
propertyType = PropertyType.FIELD;
|
||||
|
@ -362,8 +360,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
//no method
|
||||
}
|
||||
}
|
||||
else if ( el instanceof Method ) {
|
||||
Method method = (Method) el;
|
||||
else if ( el instanceof Method method ) {
|
||||
className = method.getDeclaringClass().getName();
|
||||
String methodName = method.getName();
|
||||
|
||||
|
@ -541,10 +538,10 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
}
|
||||
}
|
||||
for ( JaxbEmbeddedImpl element : elementsForProperty.getEmbedded() ) {
|
||||
applyXmlDefinedConverts( element.getConvert(), defaults, propertyName, convertAnnotationsMap );
|
||||
applyXmlDefinedConverts( element.getConverts(), defaults, propertyName, convertAnnotationsMap );
|
||||
}
|
||||
for ( JaxbElementCollectionImpl element : elementsForProperty.getElementCollection() ) {
|
||||
applyXmlDefinedConverts( element.getConvert(), defaults, propertyName, convertAnnotationsMap );
|
||||
applyXmlDefinedConverts( element.getConverts(), defaults, propertyName, convertAnnotationsMap );
|
||||
}
|
||||
|
||||
// NOTE : per section 12.2.3.16 of the spec <convert/> is additive, although only if "metadata-complete" is not
|
||||
|
@ -832,11 +829,13 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
}
|
||||
|
||||
private EntityListeners getEntityListeners(JaxbManagedType root, XMLContext.Default defaults) {
|
||||
JaxbEntityListenersImpl element = root instanceof JaxbEntityOrMappedSuperclass ? ( (JaxbEntityOrMappedSuperclass) root ).getEntityListeners() : null;
|
||||
if ( element != null ) {
|
||||
JaxbEntityListenerContainerImpl container = root instanceof JaxbEntityOrMappedSuperclass
|
||||
? ( (JaxbEntityOrMappedSuperclass) root ).getEntityListenerContainer()
|
||||
: null;
|
||||
if ( container != null ) {
|
||||
final List<Class<?>> entityListenerClasses = new ArrayList<>();
|
||||
for ( JaxbEntityListenerImpl subelement : element.getEntityListener() ) {
|
||||
String className = subelement.getClazz();
|
||||
for ( JaxbEntityListenerImpl entityListener : container.getEntityListeners() ) {
|
||||
String className = entityListener.getClazz();
|
||||
try {
|
||||
entityListenerClasses.add(
|
||||
classLoaderAccess.classForName(
|
||||
|
@ -1008,9 +1007,9 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
getOrderColumn( annotationList, element.getOrderColumn() );
|
||||
getMapKeyTemporal( annotationList, element.getMapKeyTemporal() );
|
||||
getMapKeyEnumerated( annotationList, element.getMapKeyEnumerated() );
|
||||
Annotation annotation = getMapKeyAttributeOverrides( element.getMapKeyAttributeOverride(), defaults );
|
||||
Annotation annotation = getMapKeyAttributeOverrides( element.getMapKeyAttributeOverrides(), defaults );
|
||||
addIfNotNull( annotationList, annotation );
|
||||
getMapKeyJoinColumns( annotationList, element.getMapKeyJoinColumn() );
|
||||
getMapKeyJoinColumns( annotationList, element.getMapKeyJoinColumns() );
|
||||
getAccessType( annotationList, element.getAccess() );
|
||||
}
|
||||
afterGetAssociation( annotationType, annotationList, defaults );
|
||||
|
@ -1062,7 +1061,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
getFetchType( ad, element.getFetch() );
|
||||
getCascades( ad, element.getCascade(), defaults );
|
||||
getJoinTable( annotationList, element, defaults );
|
||||
buildJoinColumns( annotationList, element.getJoinColumn() );
|
||||
buildJoinColumns( annotationList, element.getJoinColumns() );
|
||||
copyAttribute( ad, "optional", element.isOptional(), false );
|
||||
annotationList.add( AnnotationFactory.create( ad ) );
|
||||
|
||||
|
@ -1096,9 +1095,9 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
getOrderColumn( annotationList, element.getOrderColumn() );
|
||||
getMapKeyTemporal( annotationList, element.getMapKeyTemporal() );
|
||||
getMapKeyEnumerated( annotationList, element.getMapKeyEnumerated() );
|
||||
Annotation annotation = getMapKeyAttributeOverrides( element.getMapKeyAttributeOverride(), defaults );
|
||||
Annotation annotation = getMapKeyAttributeOverrides( element.getMapKeyAttributeOverrides(), defaults );
|
||||
addIfNotNull( annotationList, annotation );
|
||||
getMapKeyJoinColumns( annotationList, element.getMapKeyJoinColumn() );
|
||||
getMapKeyJoinColumns( annotationList, element.getMapKeyJoinColumns() );
|
||||
getAccessType( annotationList, element.getAccess() );
|
||||
}
|
||||
afterGetAssociation( annotationType, annotationList, defaults );
|
||||
|
@ -1387,7 +1386,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
getMapKeyTemporal( annotationList, element.getMapKeyTemporal() );
|
||||
getMapKeyEnumerated( annotationList, element.getMapKeyEnumerated() );
|
||||
getMapKeyColumn( annotationList, element.getMapKeyColumn() );
|
||||
getMapKeyJoinColumns( annotationList, element.getMapKeyJoinColumn() );
|
||||
getMapKeyJoinColumns( annotationList, element.getMapKeyJoinColumns() );
|
||||
Annotation annotation = getColumn( element.getColumn(), false, "element-collection" );
|
||||
addIfNotNull( annotationList, annotation );
|
||||
getTemporal( annotationList, element.getTemporal() );
|
||||
|
@ -1397,11 +1396,11 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
//translate into AttributeOverride annotations, which need
|
||||
//need to be wrapped in the same AttributeOverrides annotation.
|
||||
List<AttributeOverride> attributes = new ArrayList<>();
|
||||
attributes.addAll( buildAttributeOverrides( element.getMapKeyAttributeOverride(), "map-key-attribute-override" ) );
|
||||
attributes.addAll( buildAttributeOverrides( element.getAttributeOverride(), "attribute-override" ) );
|
||||
attributes.addAll( buildAttributeOverrides( element.getMapKeyAttributeOverrides(), "map-key-attribute-override" ) );
|
||||
attributes.addAll( buildAttributeOverrides( element.getAttributeOverrides(), "attribute-override" ) );
|
||||
annotation = mergeAttributeOverrides( defaults, attributes, false );
|
||||
addIfNotNull( annotationList, annotation );
|
||||
annotation = getAssociationOverrides( element.getAssociationOverride(), defaults, false );
|
||||
annotation = getAssociationOverrides( element.getAssociationOverrides(), defaults, false );
|
||||
addIfNotNull( annotationList, annotation );
|
||||
getCollectionTable( annotationList, element.getCollectionTable(), defaults );
|
||||
annotationList.add( AnnotationFactory.create( ad ) );
|
||||
|
@ -1479,12 +1478,12 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
&& isEmpty( (String) annotation.valueOf( "schema" ) ) ) {
|
||||
annotation.setValue( "schema", defaults.getSchema() );
|
||||
}
|
||||
JoinColumn[] joinColumns = getJoinColumns( element.getJoinColumn(), false );
|
||||
JoinColumn[] joinColumns = getJoinColumns( element.getJoinColumns(), false );
|
||||
if ( joinColumns.length > 0 ) {
|
||||
annotation.setValue( "joinColumns", joinColumns );
|
||||
}
|
||||
buildUniqueConstraints( annotation, element.getUniqueConstraint() );
|
||||
buildIndex( annotation, element.getIndex() );
|
||||
buildUniqueConstraints( annotation, element.getUniqueConstraints() );
|
||||
buildIndex( annotation, element.getIndexes() );
|
||||
annotationList.add( AnnotationFactory.create( annotation ) );
|
||||
}
|
||||
}
|
||||
|
@ -1524,7 +1523,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
&& !cascades.contains( CascadeType.ALL ) && !cascades.contains( CascadeType.PERSIST ) ) {
|
||||
cascades.add( CascadeType.PERSIST );
|
||||
}
|
||||
if ( cascades.size() > 0 ) {
|
||||
if ( !cascades.isEmpty() ) {
|
||||
ad.setValue( "cascade", cascades.toArray( new CascadeType[0] ) );
|
||||
}
|
||||
}
|
||||
|
@ -1533,9 +1532,9 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
for ( JaxbEmbeddedImpl element : elementsForProperty.getEmbedded() ) {
|
||||
AnnotationDescriptor ad = new AnnotationDescriptor( Embedded.class );
|
||||
annotationList.add( AnnotationFactory.create( ad ) );
|
||||
Annotation annotation = getAttributeOverrides( element.getAttributeOverride(), defaults, false );
|
||||
Annotation annotation = getAttributeOverrides( element.getAttributeOverrides(), defaults, false );
|
||||
addIfNotNull( annotationList, annotation );
|
||||
annotation = getAssociationOverrides( element.getAssociationOverride(), defaults, false );
|
||||
annotation = getAssociationOverrides( element.getAssociationOverrides(), defaults, false );
|
||||
addIfNotNull( annotationList, annotation );
|
||||
getAccessType( annotationList, element.getAccess() );
|
||||
}
|
||||
|
@ -1701,7 +1700,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
private void getEmbeddedId(List<Annotation> annotationList, XMLContext.Default defaults) {
|
||||
for ( JaxbEmbeddedIdImpl element : elementsForProperty.getEmbeddedId() ) {
|
||||
if ( isProcessingId( defaults ) ) {
|
||||
Annotation annotation = getAttributeOverrides( element.getAttributeOverride(), defaults, false );
|
||||
Annotation annotation = getAttributeOverrides( element.getAttributeOverrides(), defaults, false );
|
||||
addIfNotNull( annotationList, annotation );
|
||||
// TODO HHH-10176 We should allow association overrides here, but the JPA XSD doesn't allow that. We would need our own XSD.
|
||||
AnnotationDescriptor ad = new AnnotationDescriptor( EmbeddedId.class );
|
||||
|
@ -1833,7 +1832,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
for ( JaxbColumnImpl element : elements ) {
|
||||
columns.add( getColumn( element, false, nodeName ) );
|
||||
}
|
||||
if ( columns.size() > 0 ) {
|
||||
if ( !columns.isEmpty() ) {
|
||||
AnnotationDescriptor columnsDescr = new AnnotationDescriptor( Columns.class );
|
||||
columnsDescr.setValue( "columns", columns.toArray( new Column[ columns.size() ] ) );
|
||||
return AnnotationFactory.create( columnsDescr );
|
||||
|
@ -1910,7 +1909,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ( attributes.size() > 0 ) {
|
||||
if ( !attributes.isEmpty() ) {
|
||||
AnnotationDescriptor ad = new AnnotationDescriptor( AssociationOverrides.class );
|
||||
ad.setValue( "value", attributes.toArray( new AssociationOverride[0] ) );
|
||||
return AnnotationFactory.create( ad );
|
||||
|
@ -1922,11 +1921,11 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
|
||||
private List<AssociationOverride> buildAssociationOverrides(List<JaxbAssociationOverrideImpl> elements, XMLContext.Default defaults) {
|
||||
List<AssociationOverride> overrides = new ArrayList<>();
|
||||
if ( elements != null && elements.size() > 0 ) {
|
||||
if ( elements != null && !elements.isEmpty() ) {
|
||||
for ( JaxbAssociationOverrideImpl current : elements ) {
|
||||
AnnotationDescriptor override = new AnnotationDescriptor( AssociationOverride.class );
|
||||
copyAttribute( override, "name", current.getName(), true );
|
||||
override.setValue( "joinColumns", getJoinColumns( current.getJoinColumn(), false ) );
|
||||
override.setValue( "joinColumns", getJoinColumns( current.getJoinColumns(), false ) );
|
||||
JoinTable joinTable = buildJoinTable( current.getJoinTable(), defaults );
|
||||
if ( joinTable != null ) {
|
||||
override.setValue( "joinTable", joinTable );
|
||||
|
@ -2010,7 +2009,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ( attributes.size() > 0 ) {
|
||||
if ( !attributes.isEmpty() ) {
|
||||
AnnotationDescriptor ad = new AnnotationDescriptor( AttributeOverrides.class );
|
||||
ad.setValue( "value", attributes.toArray( new AttributeOverride[ attributes.size() ] ) );
|
||||
return AnnotationFactory.create( ad );
|
||||
|
@ -2022,7 +2021,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
|
||||
private List<AttributeOverride> buildAttributeOverrides(List<JaxbAttributeOverrideImpl> subelements, String nodeName) {
|
||||
List<AttributeOverride> overrides = new ArrayList<>();
|
||||
if ( subelements != null && subelements.size() > 0 ) {
|
||||
if ( subelements != null && !subelements.isEmpty() ) {
|
||||
for ( JaxbAttributeOverrideImpl current : subelements ) {
|
||||
AnnotationDescriptor override = new AnnotationDescriptor( AttributeOverride.class );
|
||||
copyAttribute( override, "name", current.getName(), true );
|
||||
|
@ -2143,7 +2142,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ( results.size() > 0 ) {
|
||||
if ( !results.isEmpty() ) {
|
||||
AnnotationDescriptor ad = new AnnotationDescriptor( SqlResultSetMappings.class );
|
||||
ad.setValue( "value", results.toArray( new SqlResultSetMapping[ results.size() ] ) );
|
||||
return AnnotationFactory.create( ad );
|
||||
|
@ -2407,7 +2406,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
constructorResultDescriptor.setValue( "targetClass", entityClass );
|
||||
|
||||
List<ColumnResult> columnResultAnnotations = new ArrayList<>();
|
||||
for ( JaxbColumnResultImpl columnResultElement : constructorResultElement.getColumn() ) {
|
||||
for ( JaxbColumnResultImpl columnResultElement : constructorResultElement.getColumns() ) {
|
||||
columnResultAnnotations.add( buildColumnResult( columnResultElement, defaults, classLoaderAccess ) );
|
||||
}
|
||||
constructorResultDescriptor.setValue(
|
||||
|
@ -2449,7 +2448,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ( queries.size() > 0 ) {
|
||||
if ( !queries.isEmpty() ) {
|
||||
AnnotationDescriptor ad = new AnnotationDescriptor( NamedQueries.class );
|
||||
ad.setValue( "value", queries.toArray( new NamedQuery[queries.size()] ) );
|
||||
return AnnotationFactory.create( ad );
|
||||
|
@ -2489,7 +2488,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ( queries.size() > 0 ) {
|
||||
if ( !queries.isEmpty() ) {
|
||||
AnnotationDescriptor ad = new AnnotationDescriptor( NamedEntityGraphs.class );
|
||||
ad.setValue( "value", queries.toArray( new NamedEntityGraph[queries.size()] ) );
|
||||
return AnnotationFactory.create( ad );
|
||||
|
@ -2530,7 +2529,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ( queries.size() > 0 ) {
|
||||
if ( !queries.isEmpty() ) {
|
||||
AnnotationDescriptor ad = new AnnotationDescriptor( NamedStoredProcedureQueries.class );
|
||||
ad.setValue( "value", queries.toArray( new NamedStoredProcedureQuery[queries.size()] ) );
|
||||
return AnnotationFactory.create( ad );
|
||||
|
@ -2573,7 +2572,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ( queries.size() > 0 ) {
|
||||
if ( !queries.isEmpty() ) {
|
||||
AnnotationDescriptor ad = new AnnotationDescriptor( NamedNativeQueries.class );
|
||||
ad.setValue( "value", queries.toArray( new NamedNativeQuery[queries.size()] ) );
|
||||
return AnnotationFactory.create( ad );
|
||||
|
@ -2715,7 +2714,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
|
||||
private TableGenerator getTableGenerator(JaxbManagedType root, XMLContext.Default defaults) {
|
||||
return getTableGenerator(
|
||||
root instanceof JaxbEntityImpl ? ( (JaxbEntityImpl) root ).getTableGenerator() : null,
|
||||
root instanceof JaxbEntityImpl ? ( (JaxbEntityImpl) root ).getTableGenerators() : null,
|
||||
defaults
|
||||
);
|
||||
}
|
||||
|
@ -2783,7 +2782,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
|
||||
private SequenceGenerator getSequenceGenerator(JaxbManagedType root, XMLContext.Default defaults) {
|
||||
return getSequenceGenerator(
|
||||
root instanceof JaxbEntityImpl ? ( (JaxbEntityImpl) root ).getSequenceGenerator() : null,
|
||||
root instanceof JaxbEntityImpl ? ( (JaxbEntityImpl) root ).getSequenceGenerators() : null,
|
||||
defaults
|
||||
);
|
||||
}
|
||||
|
@ -2944,8 +2943,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
return defaults.canUseJavaAnnotations() ? getPhysicalAnnotation( Entity.class ) : null;
|
||||
}
|
||||
else {
|
||||
if ( element instanceof JaxbEntityImpl ) {
|
||||
JaxbEntityImpl entityElement = (JaxbEntityImpl) element;
|
||||
if ( element instanceof JaxbEntityImpl entityElement ) {
|
||||
AnnotationDescriptor entity = new AnnotationDescriptor( Entity.class );
|
||||
copyAttribute( entity, "name", entityElement.getName(), false );
|
||||
if ( defaults.canUseJavaAnnotations()
|
||||
|
@ -3087,7 +3085,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
* You can't have both secondary tables in XML and Java,
|
||||
* since there would be no way to "remove" a secondary table
|
||||
*/
|
||||
if ( secondaryTables.size() == 0 && defaults.canUseJavaAnnotations() ) {
|
||||
if ( secondaryTables.isEmpty() && defaults.canUseJavaAnnotations() ) {
|
||||
SecondaryTable secTableAnn = getPhysicalAnnotation( SecondaryTable.class );
|
||||
overridesDefaultInSecondaryTable( secTableAnn, defaults, secondaryTables );
|
||||
SecondaryTables secTablesAnn = getPhysicalAnnotation( SecondaryTables.class );
|
||||
|
@ -3097,7 +3095,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ( secondaryTables.size() > 0 ) {
|
||||
if ( !secondaryTables.isEmpty() ) {
|
||||
AnnotationDescriptor descriptor = new AnnotationDescriptor( SecondaryTables.class );
|
||||
descriptor.setValue( "value", secondaryTables.toArray( new SecondaryTable[secondaryTables.size()] ) );
|
||||
return AnnotationFactory.create( descriptor );
|
||||
|
|
|
@ -16,8 +16,8 @@ import org.hibernate.AnnotationException;
|
|||
import org.hibernate.boot.internal.ClassmateContext;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbConverterImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityListenerContainerImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityListenerImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityListenersImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbManagedType;
|
||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbMappedSuperclassImpl;
|
||||
|
@ -91,7 +91,7 @@ public class XMLContext implements Serializable {
|
|||
globalDefaults.setAccess( defaultElement.getAccess() );
|
||||
globalDefaults.setCascadePersist( defaultElement.getCascadePersist() != null ? Boolean.TRUE : null );
|
||||
globalDefaults.setDelimitedIdentifiers( defaultElement.getDelimitedIdentifiers() != null ? Boolean.TRUE : null );
|
||||
defaultEntityListeners.addAll( addEntityListenerClasses( defaultElement.getEntityListeners(), null, addedClasses ) );
|
||||
defaultEntityListeners.addAll( addEntityListenerClasses( defaultElement.getEntityListenerContainer(), null, addedClasses ) );
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -141,18 +141,18 @@ public class XMLContext implements Serializable {
|
|||
|
||||
LOG.debugf( "Adding XML overriding information for %s", className );
|
||||
if ( element instanceof JaxbEntityImpl ) {
|
||||
addEntityListenerClasses( ( (JaxbEntityImpl) element ).getEntityListeners(), packageName, addedClasses );
|
||||
addEntityListenerClasses( ( (JaxbEntityImpl) element ).getEntityListenerContainer(), packageName, addedClasses );
|
||||
}
|
||||
else if ( element instanceof JaxbMappedSuperclassImpl ) {
|
||||
addEntityListenerClasses( ( (JaxbMappedSuperclassImpl) element ).getEntityListeners(), packageName, addedClasses );
|
||||
addEntityListenerClasses( ( (JaxbMappedSuperclassImpl) element ).getEntityListenerContainer(), packageName, addedClasses );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> addEntityListenerClasses(JaxbEntityListenersImpl listeners, String packageName, List<String> addedClasses) {
|
||||
private List<String> addEntityListenerClasses(JaxbEntityListenerContainerImpl listeners, String packageName, List<String> addedClasses) {
|
||||
List<String> localAddedClasses = new ArrayList<>();
|
||||
if ( listeners != null ) {
|
||||
List<JaxbEntityListenerImpl> elements = listeners.getEntityListener();
|
||||
List<JaxbEntityListenerImpl> elements = listeners.getEntityListeners();
|
||||
for ( JaxbEntityListenerImpl listener : elements ) {
|
||||
String listenerClassName = buildSafeClassName( listener.getClazz(), packageName );
|
||||
if ( entityListenerOverride.containsKey( listenerClassName ) ) {
|
||||
|
|
|
@ -88,6 +88,12 @@
|
|||
</bindings>
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:complexType[@name='persistence-unit-defaults']">
|
||||
<bindings node=".//xsd:element[@name='entity-listeners']">
|
||||
<property name="entityListenerContainer"/>
|
||||
</bindings>
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:complexType[@name='collection-user-type-registration']">
|
||||
<bindings node=".//xsd:element[@name='param']">
|
||||
<property name="parameters"/>
|
||||
|
@ -97,6 +103,22 @@
|
|||
<bindings node="//xsd:complexType[@name='entity']">
|
||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbEntity</inheritance:implements>
|
||||
|
||||
<bindings node=".//xsd:element[@name='entity-listeners']">
|
||||
<property name="entityListenerContainer"/>
|
||||
</bindings>
|
||||
|
||||
<bindings node=".//xsd:element[@name='sequence-generator']">
|
||||
<property name="sequenceGenerators"/>
|
||||
</bindings>
|
||||
|
||||
<bindings node=".//xsd:element[@name='table-generator']">
|
||||
<property name="tableGenerators"/>
|
||||
</bindings>
|
||||
|
||||
<bindings node=".//xsd:element[@name='identifier-generator']">
|
||||
<property name="identifierGenerators"/>
|
||||
</bindings>
|
||||
|
||||
<bindings node=".//xsd:element[@name='primary-key-join-column']">
|
||||
<property name="primaryKeyJoinColumns"/>
|
||||
</bindings>
|
||||
|
@ -150,12 +172,24 @@
|
|||
</bindings>
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:complexType[@name='association-override']">
|
||||
<bindings node=".//xsd:element[@name='join-column']">
|
||||
<property name="joinColumns"/>
|
||||
</bindings>
|
||||
<bindings node=".//xsd:element[@name='foreign-key']">
|
||||
<property name="foreignKeys"/>
|
||||
</bindings>
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:complexType[@name='embeddable']">
|
||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddable</inheritance:implements>
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:complexType[@name='mapped-superclass']">
|
||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbMappedSuperclass</inheritance:implements>
|
||||
<bindings node=".//xsd:element[@name='entity-listeners']">
|
||||
<property name="entityListenerContainer"/>
|
||||
</bindings>
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:complexType[@name='attributes']">
|
||||
|
@ -276,6 +310,21 @@
|
|||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbNotFoundCapable</inheritance:implements>
|
||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbAssociationAttribute</inheritance:implements>
|
||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbJoinTableCapable</inheritance:implements>
|
||||
<bindings node=".//xsd:element[@name='join-column']">
|
||||
<property name="joinColumns"/>
|
||||
</bindings>
|
||||
<bindings node=".//xsd:element[@name='foreign-key']">
|
||||
<property name="foreignKeys"/>
|
||||
</bindings>
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:complexType[@name='join-column']">
|
||||
<bindings node=".//xsd:element[@name='foreign-key']">
|
||||
<property name="foreignKeys"/>
|
||||
</bindings>
|
||||
<bindings node=".//xsd:element[@name='check-constraint']">
|
||||
<property name="checkConstraints"/>
|
||||
</bindings>
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:complexType[@name='hbm-any-mapping']">
|
||||
|
@ -395,11 +444,79 @@
|
|||
</bindings>
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:complexType[@name='constructor-result']">
|
||||
<bindings node=".//xsd:element[@name='column']">
|
||||
<property name="columns"/>
|
||||
</bindings>
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:group[@name='collection-structure-group']">
|
||||
<bindings node=".//xsd:element[@name='map-key-attribute-override']">
|
||||
<property name="mapKeyAttributeOverrides"/>
|
||||
</bindings>
|
||||
<bindings node=".//xsd:element[@name='map-key-convert']">
|
||||
<property name="mapKeyConverts"/>
|
||||
</bindings>
|
||||
<bindings node=".//xsd:element[@name='map-key-join-column']">
|
||||
<property name="mapKeyJoinColumns"/>
|
||||
</bindings>
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:complexType[@name='element-collection']">
|
||||
<bindings node=".//xsd:element[@name='attribute-override']">
|
||||
<property name="attributeOverrides"/>
|
||||
</bindings>
|
||||
<bindings node=".//xsd:element[@name='association-override']">
|
||||
<property name="associationOverrides"/>
|
||||
</bindings>
|
||||
<bindings node=".//xsd:element[@name='convert']">
|
||||
<property name="converts"/>
|
||||
</bindings>
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:complexType[@name='embedded']">
|
||||
<bindings node=".//xsd:element[@name='attribute-override']">
|
||||
<property name="attributeOverrides"/>
|
||||
</bindings>
|
||||
<bindings node=".//xsd:element[@name='association-override']">
|
||||
<property name="associationOverrides"/>
|
||||
</bindings>
|
||||
<bindings node=".//xsd:element[@name='convert']">
|
||||
<property name="converts"/>
|
||||
</bindings>
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:complexType[@name='embedded-id']">
|
||||
<bindings node=".//xsd:element[@name='attribute-override']">
|
||||
<property name="attributeOverrides"/>
|
||||
</bindings>
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:complexType[@name='entity-listeners']">
|
||||
<class name="JaxbEntityListenerContainerImpl"/>
|
||||
<bindings node=".//xsd:element[@name='entity-listener']">
|
||||
<property name="entityListeners"/>
|
||||
</bindings>
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:complexType[@name='join-table']">
|
||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbTableMapping</inheritance:implements>
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:complexType[@name='collection-table']">
|
||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbTableMapping</inheritance:implements>
|
||||
<bindings node=".//xsd:element[@name='join-column']">
|
||||
<property name="joinColumns"/>
|
||||
</bindings>
|
||||
<bindings node=".//xsd:element[@name='foreign-key']">
|
||||
<property name="foreignKeys"/>
|
||||
</bindings>
|
||||
<bindings node=".//xsd:element[@name='unique-constraint']">
|
||||
<property name="uniqueConstraints"/>
|
||||
</bindings>
|
||||
<bindings node=".//xsd:element[@name='index']">
|
||||
<property name="indexes"/>
|
||||
</bindings>
|
||||
</bindings>
|
||||
<bindings node="//xsd:complexType[@name='table-generator']">
|
||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbTableMapping</inheritance:implements>
|
||||
|
@ -610,6 +727,12 @@
|
|||
printMethod="org.hibernate.boot.jaxb.mapping.internal.LimitedCollectionClassificationMarshalling.toXml" />
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:simpleType[@name='not-found-enum']">
|
||||
<javaType name="org.hibernate.annotations.NotFoundAction"
|
||||
parseMethod="org.hibernate.boot.jaxb.mapping.internal.NotFoundActionMarshalling.fromXml"
|
||||
printMethod="org.hibernate.boot.jaxb.mapping.internal.NotFoundActionMarshalling.toXml" />
|
||||
</bindings>
|
||||
|
||||
<bindings node="//xsd:simpleType[@name='uuid-generator-style']">
|
||||
<javaType name="org.hibernate.annotations.UuidGenerator.Style"
|
||||
parseMethod="org.hibernate.boot.jaxb.mapping.internal.UuidGeneratorStyleMarshalling.fromXml"
|
||||
|
|
|
@ -52,8 +52,8 @@ public class JakartaXmlSmokeTests {
|
|||
|
||||
final JaxbPersistenceUnitMetadataImpl puMetadata = binding.getRoot().getPersistenceUnitMetadata();
|
||||
final JaxbPersistenceUnitDefaultsImpl puDefaults = puMetadata.getPersistenceUnitDefaults();
|
||||
final Stream<String> listenerNames = puDefaults.getEntityListeners()
|
||||
.getEntityListener()
|
||||
final Stream<String> listenerNames = puDefaults.getEntityListenerContainer()
|
||||
.getEntityListeners()
|
||||
.stream()
|
||||
.map( JaxbEntityListenerImpl::getClazz );
|
||||
assertThat( listenerNames ).containsOnly( "org.hibernate.jpa.test.pack.defaultpar.IncrementListener" );
|
||||
|
|
Loading…
Reference in New Issue