HHH-15251 - Unified mapping XSD based on JPA 3.1;
- `mapping-3.1.0.xsd` - JAXB model for `mapping-3.1.0.xsd` - Overriding caching (region, usage, include) via partial mapping document - Initial hbm.xml -> mapping.xml transformation support - Gradle task for performing transformations
This commit is contained in:
parent
b88094e70a
commit
26dbafb2b3
|
@ -124,10 +124,15 @@ xjc {
|
||||||
xjcBindingFile = file( 'src/main/xjb/hbm-mapping-bindings.xjb' )
|
xjcBindingFile = file( 'src/main/xjb/hbm-mapping-bindings.xjb' )
|
||||||
xjcExtensions += ['inheritance', 'simplify']
|
xjcExtensions += ['inheritance', 'simplify']
|
||||||
}
|
}
|
||||||
|
// orm {
|
||||||
|
// xsdFile = file( 'src/main/resources/org/hibernate/jpa/orm_2_2.xsd' )
|
||||||
|
// xjcBindingFile = file( 'src/main/xjb/mapping-bindings.xjb' )
|
||||||
|
// xjcExtensions += ['inheritance']
|
||||||
|
// }
|
||||||
mapping {
|
mapping {
|
||||||
xsdFile = file( 'src/main/resources/org/hibernate/jpa/orm_2_2.xsd' )
|
xsdFile = file( 'src/main/resources/org/hibernate/xsd/mapping/mapping-3.1.0.xsd' )
|
||||||
xjcBindingFile = file( 'src/main/xjb/mapping-bindings.xjb' )
|
xjcBindingFile = file( 'src/main/xjb/mapping-bindings.xjb' )
|
||||||
xjcExtensions += ['inheritance']
|
xjcExtensions += ['inheritance', 'simplify']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,45 @@ public enum OnDeleteAction {
|
||||||
/**
|
/**
|
||||||
* Take no action. The default.
|
* Take no action. The default.
|
||||||
*/
|
*/
|
||||||
NO_ACTION,
|
NO_ACTION( "no-action" ),
|
||||||
/**
|
/**
|
||||||
* Use cascade delete capabilities of the database foreign-key.
|
* Use cascade delete capabilities of the database foreign-key.
|
||||||
*/
|
*/
|
||||||
CASCADE
|
CASCADE( "cascade" );
|
||||||
|
|
||||||
|
private final String alternativeName;
|
||||||
|
|
||||||
|
OnDeleteAction(String alternativeName) {
|
||||||
|
this.alternativeName = alternativeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAlternativeName() {
|
||||||
|
return alternativeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OnDeleteAction fromExternalForm(Object value) {
|
||||||
|
if ( value == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( value instanceof OnDeleteAction ) {
|
||||||
|
return (OnDeleteAction) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String valueString = value.toString();
|
||||||
|
try {
|
||||||
|
return valueOf( valueString );
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException e) {
|
||||||
|
// the name did not match the enum value name...
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( OnDeleteAction checkAction : values() ) {
|
||||||
|
if ( checkAction.alternativeName.equalsIgnoreCase( valueString ) ) {
|
||||||
|
return checkAction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ package org.hibernate.annotations;
|
||||||
/**
|
/**
|
||||||
* Possible optimistic locking strategies.
|
* Possible optimistic locking strategies.
|
||||||
*
|
*
|
||||||
|
* @see OptimisticLocking
|
||||||
|
*
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
*/
|
*/
|
||||||
public enum OptimisticLockType {
|
public enum OptimisticLockType {
|
||||||
|
|
|
@ -6,9 +6,13 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.annotations;
|
package org.hibernate.annotations;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of available polymorphism for a particular entity.
|
* Type of available polymorphism for a particular entity.
|
||||||
*
|
*
|
||||||
|
* @see Polymorphism
|
||||||
|
*
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
*/
|
*/
|
||||||
public enum PolymorphismType {
|
public enum PolymorphismType {
|
||||||
|
@ -19,5 +23,26 @@ public enum PolymorphismType {
|
||||||
/**
|
/**
|
||||||
* This entity is retrieved only if explicitly asked.
|
* This entity is retrieved only if explicitly asked.
|
||||||
*/
|
*/
|
||||||
EXPLICIT
|
EXPLICIT;
|
||||||
|
|
||||||
|
public static PolymorphismType fromExternalValue(Object externalValue) {
|
||||||
|
if ( externalValue != null ) {
|
||||||
|
if ( externalValue instanceof PolymorphismType ) {
|
||||||
|
return (PolymorphismType) externalValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String externalValueStr = externalValue.toString();
|
||||||
|
for ( PolymorphismType checkType : values() ) {
|
||||||
|
if ( checkType.name().equalsIgnoreCase( externalValueStr ) ) {
|
||||||
|
return checkType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getExternalForm() {
|
||||||
|
return name().toLowerCase( Locale.ROOT );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,6 @@ import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
import org.hibernate.type.SerializationException;
|
import org.hibernate.type.SerializationException;
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entry point for working with sources of O/R mapping metadata, either
|
* Entry point for working with sources of O/R mapping metadata, either
|
||||||
* in the form of annotated classes, or as XML mapping documents.
|
* in the form of annotated classes, or as XML mapping documents.
|
||||||
|
@ -64,9 +62,8 @@ public class MetadataSources implements Serializable {
|
||||||
|
|
||||||
private final ServiceRegistry serviceRegistry;
|
private final ServiceRegistry serviceRegistry;
|
||||||
private final ClassLoaderService classLoaderService;
|
private final ClassLoaderService classLoaderService;
|
||||||
private final boolean disableXmlMappingBinders;
|
|
||||||
|
|
||||||
private XmlMappingBinderAccess xmlMappingBinderAccess;
|
private final XmlMappingBinderAccess xmlMappingBinderAccess;
|
||||||
|
|
||||||
private List<Binding<?>> xmlBindings;
|
private List<Binding<?>> xmlBindings;
|
||||||
private LinkedHashSet<Class<?>> annotatedClasses;
|
private LinkedHashSet<Class<?>> annotatedClasses;
|
||||||
|
@ -88,8 +85,17 @@ public class MetadataSources implements Serializable {
|
||||||
* @param serviceRegistry The service registry to use.
|
* @param serviceRegistry The service registry to use.
|
||||||
*/
|
*/
|
||||||
public MetadataSources(ServiceRegistry serviceRegistry) {
|
public MetadataSources(ServiceRegistry serviceRegistry) {
|
||||||
|
this( serviceRegistry, new XmlMappingBinderAccess( serviceRegistry ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance using the given {@link ServiceRegistry}.
|
||||||
|
*
|
||||||
|
* @param serviceRegistry The service registry to use.
|
||||||
|
*/
|
||||||
|
public MetadataSources(ServiceRegistry serviceRegistry, XmlMappingBinderAccess xmlMappingBinderAccess) {
|
||||||
// service registry really should be either BootstrapServiceRegistry or StandardServiceRegistry type...
|
// service registry really should be either BootstrapServiceRegistry or StandardServiceRegistry type...
|
||||||
if ( ! isExpectedServiceRegistryType( serviceRegistry ) ) {
|
if ( !isExpectedServiceRegistryType( serviceRegistry ) ) {
|
||||||
if ( LOG.isDebugEnabled() ) {
|
if ( LOG.isDebugEnabled() ) {
|
||||||
LOG.debugf(
|
LOG.debugf(
|
||||||
"Unexpected ServiceRegistry type [%s] encountered during building of MetadataSources; may cause " +
|
"Unexpected ServiceRegistry type [%s] encountered during building of MetadataSources; may cause " +
|
||||||
|
@ -100,7 +106,7 @@ public class MetadataSources implements Serializable {
|
||||||
}
|
}
|
||||||
this.serviceRegistry = serviceRegistry;
|
this.serviceRegistry = serviceRegistry;
|
||||||
this.classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
this.classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||||
this.disableXmlMappingBinders = false;
|
this.xmlMappingBinderAccess = xmlMappingBinderAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,7 +116,9 @@ public class MetadataSources implements Serializable {
|
||||||
Objects.requireNonNull( serviceRegistry );
|
Objects.requireNonNull( serviceRegistry );
|
||||||
this.serviceRegistry = serviceRegistry;
|
this.serviceRegistry = serviceRegistry;
|
||||||
this.classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
this.classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||||
this.disableXmlMappingBinders = disableXmlMappingBinders;
|
this.xmlMappingBinderAccess = disableXmlMappingBinders
|
||||||
|
? null
|
||||||
|
: new XmlMappingBinderAccess( serviceRegistry );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean isExpectedServiceRegistryType(ServiceRegistry serviceRegistry) {
|
protected static boolean isExpectedServiceRegistryType(ServiceRegistry serviceRegistry) {
|
||||||
|
@ -119,12 +127,6 @@ public class MetadataSources implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public XmlMappingBinderAccess getXmlMappingBinderAccess() {
|
public XmlMappingBinderAccess getXmlMappingBinderAccess() {
|
||||||
if ( disableXmlMappingBinders ) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if ( xmlMappingBinderAccess == null ) {
|
|
||||||
xmlMappingBinderAccess = new XmlMappingBinderAccess( serviceRegistry );
|
|
||||||
}
|
|
||||||
return xmlMappingBinderAccess;
|
return xmlMappingBinderAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstraction for locating class-path resources
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface ResourceLocator {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Locate the named resource
|
||||||
|
*
|
||||||
|
* @param resourceName The resource name to locate
|
||||||
|
*
|
||||||
|
* @return The located URL, or {@code null} if no match found
|
||||||
|
*/
|
||||||
|
URL locateResource(String resourceName);
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstraction for locating class-path resources
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface ResourceStreamLocator {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Locate the named resource
|
||||||
|
*
|
||||||
|
* @param resourceName The resource name to locate
|
||||||
|
*
|
||||||
|
* @return The located resource's InputStream, or {@code null} if no match found
|
||||||
|
*/
|
||||||
|
InputStream locateResourceStream(String resourceName);
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* 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.internal;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import org.hibernate.boot.ResourceLocator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple ResourceLocator impl using its own ClassLoader to locate the resource
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class SimpleResourceLocator implements ResourceLocator {
|
||||||
|
/**
|
||||||
|
* Singleton access
|
||||||
|
*/
|
||||||
|
public static final SimpleResourceLocator INSTANCE = new SimpleResourceLocator();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public URL locateResource(String resourceName) {
|
||||||
|
return getClass().getClassLoader().getResource( resourceName );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* 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.internal;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import org.hibernate.boot.ResourceLocator;
|
||||||
|
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard implementation of ResourceLocator delegating to the ClassLoaderService
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class StandardResourceLocator implements ResourceLocator {
|
||||||
|
private final ClassLoaderService classLoaderService;
|
||||||
|
|
||||||
|
public StandardResourceLocator(ClassLoaderService classLoaderService) {
|
||||||
|
this.classLoaderService = classLoaderService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public URL locateResource(String resourceName) {
|
||||||
|
return classLoaderService.locateResource( resourceName );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* 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.hbm.transform;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
interface ColumnAndFormulaSource {
|
||||||
|
String getColumnAttribute();
|
||||||
|
|
||||||
|
String getFormulaAttribute();
|
||||||
|
|
||||||
|
List<Serializable> getColumnOrFormula();
|
||||||
|
|
||||||
|
SourceColumnAdapter wrap(Serializable column);
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
/*
|
||||||
|
* 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.hbm.transform;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
interface ColumnAndFormulaTarget {
|
||||||
|
TargetColumnAdapter makeColumnAdapter(ColumnDefaults columnDefaults);
|
||||||
|
|
||||||
|
void addColumn(TargetColumnAdapter column);
|
||||||
|
|
||||||
|
void addFormula(String formula);
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* 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.hbm.transform;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
interface ColumnDefaults {
|
||||||
|
Boolean isNullable();
|
||||||
|
|
||||||
|
Integer getLength();
|
||||||
|
|
||||||
|
Integer getScale();
|
||||||
|
|
||||||
|
Integer getPrecision();
|
||||||
|
|
||||||
|
Boolean isUnique();
|
||||||
|
|
||||||
|
Boolean isInsertable();
|
||||||
|
|
||||||
|
Boolean isUpdateable();
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* 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.hbm.transform;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class ColumnDefaultsBasicImpl implements ColumnDefaults {
|
||||||
|
/**
|
||||||
|
* Singleton access
|
||||||
|
*/
|
||||||
|
public static final ColumnDefaultsBasicImpl INSTANCE = new ColumnDefaultsBasicImpl();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isNullable() {
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getLength() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getScale() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getPrecision() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isUnique() {
|
||||||
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isInsertable() {
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isUpdateable() {
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* 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.hbm.transform;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
class ColumnDefaultsInsertableNonUpdateableImpl implements ColumnDefaults {
|
||||||
|
/**
|
||||||
|
* Singleton access
|
||||||
|
*/
|
||||||
|
public static final ColumnDefaultsInsertableNonUpdateableImpl INSTANCE = new ColumnDefaultsInsertableNonUpdateableImpl();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isNullable() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getLength() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getScale() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getPrecision() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isUnique() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isInsertable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isUpdateable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* 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.hbm.transform;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public interface SourceColumnAdapter {
|
||||||
|
String getName();
|
||||||
|
Boolean isNotNull();
|
||||||
|
Boolean isUnique();
|
||||||
|
Integer getLength();
|
||||||
|
Integer getPrecision();
|
||||||
|
Integer getScale();
|
||||||
|
String getSqlType();
|
||||||
|
|
||||||
|
String getComment();
|
||||||
|
String getCheck();
|
||||||
|
String getDefault();
|
||||||
|
|
||||||
|
String getIndex();
|
||||||
|
String getUniqueKey();
|
||||||
|
|
||||||
|
String getRead();
|
||||||
|
String getWrite();
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* 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.hbm.transform;
|
||||||
|
|
||||||
|
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmColumnType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class SourceColumnAdapterJaxbHbmColumnType implements SourceColumnAdapter {
|
||||||
|
private final JaxbHbmColumnType hbmColumn;
|
||||||
|
|
||||||
|
public SourceColumnAdapterJaxbHbmColumnType(JaxbHbmColumnType hbmColumn) {
|
||||||
|
this.hbmColumn = hbmColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return hbmColumn.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isNotNull() {
|
||||||
|
return hbmColumn.isNotNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isUnique() {
|
||||||
|
return hbmColumn.isUnique();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getLength() {
|
||||||
|
return hbmColumn.getLength();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getPrecision() {
|
||||||
|
return hbmColumn.getPrecision();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getScale() {
|
||||||
|
return hbmColumn.getScale();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSqlType() {
|
||||||
|
return hbmColumn.getSqlType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getComment() {
|
||||||
|
return hbmColumn.getComment();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCheck() {
|
||||||
|
return hbmColumn.getCheck();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDefault() {
|
||||||
|
return hbmColumn.getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIndex() {
|
||||||
|
return hbmColumn.getIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUniqueKey() {
|
||||||
|
return hbmColumn.getUniqueKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRead() {
|
||||||
|
return hbmColumn.getRead();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getWrite() {
|
||||||
|
return hbmColumn.getWrite();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* 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.hbm.transform;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
interface TargetColumnAdapter {
|
||||||
|
void setName(String value);
|
||||||
|
|
||||||
|
void setTable(String value);
|
||||||
|
|
||||||
|
void setNullable(Boolean value);
|
||||||
|
|
||||||
|
void setUnique(Boolean value);
|
||||||
|
|
||||||
|
void setColumnDefinition(String value);
|
||||||
|
|
||||||
|
void setLength(Integer value);
|
||||||
|
|
||||||
|
void setPrecision(Integer value);
|
||||||
|
|
||||||
|
void setScale(Integer value);
|
||||||
|
|
||||||
|
void setDefault(String value);
|
||||||
|
|
||||||
|
void setCheck(String value);
|
||||||
|
|
||||||
|
void setComment(String value);
|
||||||
|
|
||||||
|
void setRead(String value);
|
||||||
|
|
||||||
|
void setWrite(String value);
|
||||||
|
|
||||||
|
void setInsertable(Boolean value);
|
||||||
|
|
||||||
|
void setUpdatable(Boolean value);
|
||||||
|
}
|
|
@ -0,0 +1,124 @@
|
||||||
|
/*
|
||||||
|
* 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.hbm.transform;
|
||||||
|
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbColumn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class TargetColumnAdapterJaxbColumn implements TargetColumnAdapter {
|
||||||
|
private final JaxbColumn jaxbColumn;
|
||||||
|
|
||||||
|
public TargetColumnAdapterJaxbColumn(ColumnDefaults columnDefaults) {
|
||||||
|
this( new JaxbColumn(), columnDefaults );
|
||||||
|
}
|
||||||
|
|
||||||
|
public TargetColumnAdapterJaxbColumn(JaxbColumn jaxbColumn, ColumnDefaults columnDefaults) {
|
||||||
|
this.jaxbColumn = jaxbColumn;
|
||||||
|
this.jaxbColumn.setLength( columnDefaults.getLength() );
|
||||||
|
this.jaxbColumn.setScale( columnDefaults.getScale() );
|
||||||
|
this.jaxbColumn.setPrecision( columnDefaults.getPrecision() );
|
||||||
|
this.jaxbColumn.setNullable( columnDefaults.isNullable() );
|
||||||
|
this.jaxbColumn.setUnique( columnDefaults.isUnique() );
|
||||||
|
this.jaxbColumn.setInsertable( columnDefaults.isInsertable() );
|
||||||
|
this.jaxbColumn.setUpdatable( columnDefaults.isUpdateable() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public JaxbColumn getTargetColumn() {
|
||||||
|
return jaxbColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setName(String value) {
|
||||||
|
jaxbColumn.setName( value );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTable(String value) {
|
||||||
|
jaxbColumn.setTable( value );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setNullable(Boolean value) {
|
||||||
|
if ( value != null ) {
|
||||||
|
jaxbColumn.setNullable( value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUnique(Boolean value) {
|
||||||
|
if ( value != null ) {
|
||||||
|
jaxbColumn.setUnique( value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInsertable(Boolean value) {
|
||||||
|
if ( value != null ) {
|
||||||
|
jaxbColumn.setInsertable( value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUpdatable(Boolean value) {
|
||||||
|
if ( value != null ) {
|
||||||
|
jaxbColumn.setUpdatable( value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLength(Integer value) {
|
||||||
|
if ( value != null ) {
|
||||||
|
jaxbColumn.setLength( value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPrecision(Integer value) {
|
||||||
|
if ( value != null ) {
|
||||||
|
jaxbColumn.setPrecision( value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setScale(Integer value) {
|
||||||
|
if ( value != null ) {
|
||||||
|
jaxbColumn.setScale( value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setColumnDefinition(String value) {
|
||||||
|
jaxbColumn.setColumnDefinition( value );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDefault(String value) {
|
||||||
|
jaxbColumn.setDefault( value );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCheck(String value) {
|
||||||
|
jaxbColumn.setCheck( value );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setComment(String value) {
|
||||||
|
jaxbColumn.setComment( value );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRead(String value) {
|
||||||
|
jaxbColumn.setRead( value );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setWrite(String value) {
|
||||||
|
jaxbColumn.setWrite( value );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,107 @@
|
||||||
|
/*
|
||||||
|
* 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.hbm.transform;
|
||||||
|
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbJoinColumn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class TargetColumnAdapterJaxbJoinColumn implements TargetColumnAdapter {
|
||||||
|
private final JaxbJoinColumn jaxbColumn;
|
||||||
|
|
||||||
|
public TargetColumnAdapterJaxbJoinColumn(ColumnDefaults columnDefaults) {
|
||||||
|
this( new JaxbJoinColumn(), columnDefaults );
|
||||||
|
}
|
||||||
|
|
||||||
|
public TargetColumnAdapterJaxbJoinColumn(JaxbJoinColumn jaxbColumn, ColumnDefaults columnDefaults) {
|
||||||
|
this.jaxbColumn = jaxbColumn;
|
||||||
|
this.jaxbColumn.setNullable( columnDefaults.isNullable() );
|
||||||
|
this.jaxbColumn.setUnique( columnDefaults.isUnique() );
|
||||||
|
this.jaxbColumn.setInsertable( columnDefaults.isInsertable() );
|
||||||
|
this.jaxbColumn.setUpdatable( columnDefaults.isUpdateable() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public JaxbJoinColumn getTargetColumn() {
|
||||||
|
return jaxbColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setName(String value) {
|
||||||
|
jaxbColumn.setName( value );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTable(String value) {
|
||||||
|
jaxbColumn.setTable( value );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setNullable(Boolean value) {
|
||||||
|
if ( value != null ) {
|
||||||
|
jaxbColumn.setNullable( value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUnique(Boolean value) {
|
||||||
|
if ( value != null ) {
|
||||||
|
jaxbColumn.setUnique( value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInsertable(Boolean value) {
|
||||||
|
if ( value != null ) {
|
||||||
|
jaxbColumn.setInsertable( value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUpdatable(Boolean value) {
|
||||||
|
if ( value != null ) {
|
||||||
|
jaxbColumn.setUpdatable( value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLength(Integer value) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPrecision(Integer value) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setScale(Integer value) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setColumnDefinition(String value) {
|
||||||
|
jaxbColumn.setColumnDefinition( value );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDefault(String value) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCheck(String value) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setComment(String value) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRead(String value) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setWrite(String value) {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* 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.hbm.transform;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How to handle features in the transformed `hbm.xml` which are not supported
|
||||||
|
* in the `mapping.xml` XSD
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public enum UnsupportedFeatureHandling {
|
||||||
|
/**
|
||||||
|
* Throw an exception.
|
||||||
|
*/
|
||||||
|
ERROR,
|
||||||
|
/**
|
||||||
|
* Similar to {@link #IGNORE} except that we log a warning
|
||||||
|
*/
|
||||||
|
WARN,
|
||||||
|
/**
|
||||||
|
* Simply ignore the feature. Logs a debug message
|
||||||
|
*/
|
||||||
|
IGNORE,
|
||||||
|
/**
|
||||||
|
* Pick the closest mapping, if possible. Falls back to {@link #IGNORE} if there is no close match
|
||||||
|
*/
|
||||||
|
PICK;
|
||||||
|
|
||||||
|
public static UnsupportedFeatureHandling fromSetting(Object value) {
|
||||||
|
return fromSetting( value, (v) -> null );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UnsupportedFeatureHandling fromSetting(Object value, UnsupportedFeatureHandling defaultValue) {
|
||||||
|
return fromSetting( value, (v) -> defaultValue );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UnsupportedFeatureHandling fromSetting(Object value, Function<Object, UnsupportedFeatureHandling> defaultValueSupplier) {
|
||||||
|
if ( value != null ) {
|
||||||
|
if ( value instanceof UnsupportedFeatureHandling ) {
|
||||||
|
return (UnsupportedFeatureHandling) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ERROR.name().equalsIgnoreCase( value.toString() ) ) {
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( IGNORE.name().equalsIgnoreCase( value.toString() ) ) {
|
||||||
|
return IGNORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( PICK.name().equalsIgnoreCase( value.toString() ) ) {
|
||||||
|
return PICK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultValueSupplier.apply( value );
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,14 +2,11 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.boot.jaxb.internal;
|
package org.hibernate.boot.jaxb.internal;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import jakarta.xml.bind.JAXBContext;
|
|
||||||
import jakarta.xml.bind.JAXBException;
|
|
||||||
import jakarta.xml.bind.Unmarshaller;
|
|
||||||
import javax.xml.stream.XMLEventReader;
|
import javax.xml.stream.XMLEventReader;
|
||||||
import javax.xml.stream.XMLInputFactory;
|
import javax.xml.stream.XMLInputFactory;
|
||||||
import javax.xml.stream.XMLStreamException;
|
import javax.xml.stream.XMLStreamException;
|
||||||
|
@ -19,41 +16,36 @@ import javax.xml.transform.Source;
|
||||||
import javax.xml.validation.Schema;
|
import javax.xml.validation.Schema;
|
||||||
|
|
||||||
import org.hibernate.boot.MappingException;
|
import org.hibernate.boot.MappingException;
|
||||||
|
import org.hibernate.boot.ResourceStreamLocator;
|
||||||
import org.hibernate.boot.jaxb.Origin;
|
import org.hibernate.boot.jaxb.Origin;
|
||||||
import org.hibernate.boot.jaxb.internal.stax.BufferedXMLEventReader;
|
import org.hibernate.boot.jaxb.internal.stax.BufferedXMLEventReader;
|
||||||
import org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver;
|
import org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver;
|
||||||
import org.hibernate.boot.jaxb.spi.Binder;
|
import org.hibernate.boot.jaxb.spi.Binder;
|
||||||
import org.hibernate.boot.jaxb.spi.Binding;
|
import org.hibernate.boot.jaxb.spi.Binding;
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
|
||||||
|
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
|
import jakarta.xml.bind.JAXBContext;
|
||||||
|
import jakarta.xml.bind.JAXBException;
|
||||||
|
import jakarta.xml.bind.Unmarshaller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractBinder implements Binder {
|
public abstract class AbstractBinder<T> implements Binder<T> {
|
||||||
private static final Logger log = Logger.getLogger( AbstractBinder.class );
|
private static final Logger log = Logger.getLogger( AbstractBinder.class );
|
||||||
|
|
||||||
private final LocalXmlResourceResolver xmlResourceResolver;
|
private final LocalXmlResourceResolver xmlResourceResolver;
|
||||||
private final boolean validateXml;
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
protected AbstractBinder(ResourceStreamLocator resourceStreamLocator) {
|
||||||
protected AbstractBinder(ClassLoaderService classLoaderService) {
|
this.xmlResourceResolver = new LocalXmlResourceResolver( resourceStreamLocator );
|
||||||
this( classLoaderService, true );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractBinder(ClassLoaderService classLoaderService, boolean validateXml) {
|
public abstract boolean isValidationEnabled();
|
||||||
this.xmlResourceResolver = new LocalXmlResourceResolver( classLoaderService );
|
|
||||||
this.validateXml = validateXml;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isValidationEnabled() {
|
|
||||||
return validateXml;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Binding bind(InputStream stream, Origin origin) {
|
public <X extends T> Binding<X> bind(InputStream stream, Origin origin) {
|
||||||
final XMLEventReader eventReader = createReader( stream, origin );
|
final XMLEventReader eventReader = createReader( stream, origin );
|
||||||
try {
|
try {
|
||||||
return doBind( eventReader, origin );
|
return doBind( eventReader, origin );
|
||||||
|
@ -81,7 +73,7 @@ public abstract class AbstractBinder implements Binder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Binding bind(Source source, Origin origin) {
|
public <X extends T> Binding<X> bind(Source source, Origin origin) {
|
||||||
final XMLEventReader eventReader = createReader( source, origin );
|
final XMLEventReader eventReader = createReader( source, origin );
|
||||||
return doBind( eventReader, origin );
|
return doBind( eventReader, origin );
|
||||||
}
|
}
|
||||||
|
@ -98,7 +90,7 @@ public abstract class AbstractBinder implements Binder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Binding doBind(XMLEventReader eventReader, Origin origin) {
|
private <X extends T> Binding<X> doBind(XMLEventReader eventReader, Origin origin) {
|
||||||
try {
|
try {
|
||||||
final StartElement rootElementStartEvent = seekRootElementStartEvent( eventReader, origin );
|
final StartElement rootElementStartEvent = seekRootElementStartEvent( eventReader, origin );
|
||||||
return doBind( eventReader, rootElementStartEvent, origin );
|
return doBind( eventReader, rootElementStartEvent, origin );
|
||||||
|
@ -107,7 +99,7 @@ public abstract class AbstractBinder implements Binder {
|
||||||
try {
|
try {
|
||||||
eventReader.close();
|
eventReader.close();
|
||||||
}
|
}
|
||||||
catch ( Exception e ) {
|
catch (Exception e) {
|
||||||
log.debug( "Unable to close StAX reader", e );
|
log.debug( "Unable to close StAX reader", e );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -149,15 +141,14 @@ public abstract class AbstractBinder implements Binder {
|
||||||
return rootElementStartEvent.asStartElement();
|
return rootElementStartEvent.asStartElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Binding doBind(XMLEventReader staxEventReader, StartElement rootElementStartEvent, Origin origin);
|
protected abstract <X extends T> Binding<X> doBind(XMLEventReader staxEventReader, StartElement rootElementStartEvent, Origin origin);
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
protected static boolean hasNamespace(StartElement startElement) {
|
protected static boolean hasNamespace(StartElement startElement) {
|
||||||
return StringHelper.isNotEmpty( startElement.getName().getNamespaceURI() );
|
return StringHelper.isNotEmpty( startElement.getName().getNamespaceURI() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
protected <X extends T> X jaxb(XMLEventReader reader, Schema xsd, JAXBContext jaxbContext, Origin origin) {
|
||||||
protected <T> T jaxb(XMLEventReader reader, Schema xsd, JAXBContext jaxbContext, Origin origin) {
|
|
||||||
final ContextProvidingValidationEventHandler handler = new ContextProvidingValidationEventHandler();
|
final ContextProvidingValidationEventHandler handler = new ContextProvidingValidationEventHandler();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -170,7 +161,8 @@ public abstract class AbstractBinder implements Binder {
|
||||||
}
|
}
|
||||||
unmarshaller.setEventHandler( handler );
|
unmarshaller.setEventHandler( handler );
|
||||||
|
|
||||||
return (T) unmarshaller.unmarshal( reader );
|
//noinspection unchecked
|
||||||
|
return (X) unmarshaller.unmarshal( reader );
|
||||||
}
|
}
|
||||||
catch ( JAXBException e ) {
|
catch ( JAXBException e ) {
|
||||||
throw new MappingException(
|
throw new MappingException(
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.boot.jaxb.internal;
|
package org.hibernate.boot.jaxb.internal;
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import jakarta.xml.bind.ValidationEventLocator;
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
class ContextProvidingValidationEventHandler implements ValidationEventHandler {
|
public class ContextProvidingValidationEventHandler implements ValidationEventHandler {
|
||||||
private int lineNumber;
|
private int lineNumber;
|
||||||
private int columnNumber;
|
private int columnNumber;
|
||||||
private String message;
|
private String message;
|
||||||
|
|
|
@ -2,46 +2,205 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.boot.jaxb.internal;
|
package org.hibernate.boot.jaxb.internal;
|
||||||
|
|
||||||
import jakarta.xml.bind.JAXBContext;
|
import java.util.function.Function;
|
||||||
import jakarta.xml.bind.JAXBException;
|
import java.util.function.Supplier;
|
||||||
import javax.xml.stream.XMLEventFactory;
|
import javax.xml.stream.XMLEventFactory;
|
||||||
import javax.xml.stream.XMLEventReader;
|
import javax.xml.stream.XMLEventReader;
|
||||||
import javax.xml.stream.events.StartElement;
|
import javax.xml.stream.events.StartElement;
|
||||||
|
|
||||||
|
import org.hibernate.Internal;
|
||||||
|
import org.hibernate.boot.ResourceStreamLocator;
|
||||||
import org.hibernate.boot.UnsupportedOrmXsdVersionException;
|
import org.hibernate.boot.UnsupportedOrmXsdVersionException;
|
||||||
|
import org.hibernate.boot.jaxb.JaxbLogger;
|
||||||
import org.hibernate.boot.jaxb.Origin;
|
import org.hibernate.boot.jaxb.Origin;
|
||||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
|
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
|
||||||
|
import org.hibernate.boot.jaxb.hbm.transform.HbmXmlTransformer;
|
||||||
|
import org.hibernate.boot.jaxb.hbm.transform.UnsupportedFeatureHandling;
|
||||||
import org.hibernate.boot.jaxb.internal.stax.HbmEventReader;
|
import org.hibernate.boot.jaxb.internal.stax.HbmEventReader;
|
||||||
import org.hibernate.boot.jaxb.internal.stax.JpaOrmXmlEventReader;
|
import org.hibernate.boot.jaxb.internal.stax.JpaOrmXmlEventReader;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappings;
|
import org.hibernate.boot.jaxb.internal.stax.MappingEventReader;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
|
||||||
|
import org.hibernate.boot.jaxb.spi.BindableMappingDescriptor;
|
||||||
import org.hibernate.boot.jaxb.spi.Binding;
|
import org.hibernate.boot.jaxb.spi.Binding;
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
import org.hibernate.boot.xsd.MappingXsdSupport;
|
import org.hibernate.boot.xsd.MappingXsdSupport;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.engine.config.spi.ConfigurationService;
|
||||||
|
import org.hibernate.internal.log.DeprecationLogger;
|
||||||
import org.hibernate.internal.util.config.ConfigurationException;
|
import org.hibernate.internal.util.config.ConfigurationException;
|
||||||
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
|
import jakarta.xml.bind.JAXBContext;
|
||||||
|
import jakarta.xml.bind.JAXBException;
|
||||||
|
|
||||||
|
import static org.hibernate.engine.config.spi.StandardConverters.BOOLEAN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Responsible for coordinating binding of mapping XML documents into
|
||||||
|
* JAXB representations, producing {@link Binding} references.
|
||||||
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class MappingBinder extends AbstractBinder {
|
public class MappingBinder extends AbstractBinder<BindableMappingDescriptor> {
|
||||||
private static final Logger log = Logger.getLogger( MappingBinder.class );
|
private static final Logger log = Logger.getLogger( MappingBinder.class );
|
||||||
|
|
||||||
private final XMLEventFactory xmlEventFactory = XMLEventFactory.newInstance();
|
private final XMLEventFactory xmlEventFactory = XMLEventFactory.newInstance();
|
||||||
|
|
||||||
|
private final Supplier<Options> optionsAccess;
|
||||||
|
private final Supplier<UnsupportedFeatureHandling> unsupportedHandlingAccess;
|
||||||
|
|
||||||
private JAXBContext hbmJaxbContext;
|
private JAXBContext hbmJaxbContext;
|
||||||
private JAXBContext entityMappingsJaxbContext;
|
private JAXBContext entityMappingsJaxbContext;
|
||||||
|
|
||||||
public MappingBinder(ClassLoaderService classLoaderService, boolean validateXml) {
|
public interface Options {
|
||||||
super( classLoaderService, validateXml );
|
boolean validateMappings();
|
||||||
|
|
||||||
|
boolean transformHbmMappings();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Options VALIDATING = new Options() {
|
||||||
|
@Override
|
||||||
|
public boolean validateMappings() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean transformHbmMappings() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static final Options NON_VALIDATING = new Options() {
|
||||||
|
@Override
|
||||||
|
public boolean validateMappings() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean transformHbmMappings() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full constructor
|
||||||
|
*/
|
||||||
|
public MappingBinder(
|
||||||
|
ResourceStreamLocator resourceStreamLocator,
|
||||||
|
Supplier<Options> optionsAccess,
|
||||||
|
Supplier<UnsupportedFeatureHandling> unsupportedHandlingAccess) {
|
||||||
|
super( resourceStreamLocator );
|
||||||
|
this.optionsAccess = optionsAccess;
|
||||||
|
this.unsupportedHandlingAccess = unsupportedHandlingAccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full non-lazy constructor
|
||||||
|
*/
|
||||||
|
private MappingBinder(
|
||||||
|
ResourceStreamLocator resourceStreamLocator,
|
||||||
|
Options options,
|
||||||
|
UnsupportedFeatureHandling unsupportedHandling) {
|
||||||
|
this( resourceStreamLocator, () -> options, () -> unsupportedHandling );
|
||||||
|
}
|
||||||
|
|
||||||
|
public MappingBinder(
|
||||||
|
ResourceStreamLocator resourceStreamLocator,
|
||||||
|
Function<String, Object> settingsAccess) {
|
||||||
|
super( resourceStreamLocator == null ? MappingBinder.class.getClassLoader()::getResourceAsStream : resourceStreamLocator );
|
||||||
|
|
||||||
|
if ( settingsAccess == null ) {
|
||||||
|
this.optionsAccess = () -> VALIDATING;
|
||||||
|
this.unsupportedHandlingAccess = () -> UnsupportedFeatureHandling.ERROR;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.optionsAccess = () -> new Options() {
|
||||||
|
@Override
|
||||||
|
public boolean validateMappings() {
|
||||||
|
final Object setting = settingsAccess.apply( AvailableSettings.VALIDATE_XML );
|
||||||
|
if ( setting == null ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return BOOLEAN.convert( setting );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean transformHbmMappings() {
|
||||||
|
final Object setting = settingsAccess.apply( AvailableSettings.TRANSFORM_HBM_XML );
|
||||||
|
if ( setting == null ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return BOOLEAN.convert( setting );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.unsupportedHandlingAccess = () -> {
|
||||||
|
final Object setting = settingsAccess.apply( AvailableSettings.TRANSFORM_HBM_XML_FEATURE_HANDLING );
|
||||||
|
return UnsupportedFeatureHandling.fromSetting( setting, UnsupportedFeatureHandling.ERROR );
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public MappingBinder(ServiceRegistry serviceRegistry) {
|
||||||
|
this(
|
||||||
|
serviceRegistry.getService( ClassLoaderService.class ),
|
||||||
|
(settingName) -> {
|
||||||
|
final ConfigurationService configurationService;
|
||||||
|
if ( serviceRegistry instanceof ServiceRegistryImplementor ) {
|
||||||
|
final ServiceRegistryImplementor serviceRegistryImplementor = (ServiceRegistryImplementor) serviceRegistry;
|
||||||
|
configurationService = serviceRegistryImplementor.fromRegistryOrChildren( ConfigurationService.class );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
configurationService = serviceRegistry.getService( ConfigurationService.class );
|
||||||
|
}
|
||||||
|
|
||||||
|
return configurationService == null ? null : configurationService.getSettings().get( settingName );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor used by the Gradle plugin
|
||||||
|
*/
|
||||||
|
public MappingBinder(ResourceStreamLocator resourceStreamLocator, UnsupportedFeatureHandling unsupportedHandling) {
|
||||||
|
this(
|
||||||
|
resourceStreamLocator,
|
||||||
|
new Options() {
|
||||||
|
@Override
|
||||||
|
public boolean validateMappings() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean transformHbmMappings() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
unsupportedHandling
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor used everywhere else
|
||||||
|
*/
|
||||||
|
public MappingBinder(ResourceStreamLocator resourceStreamLocator, Options options) {
|
||||||
|
this( resourceStreamLocator, options, UnsupportedFeatureHandling.ERROR );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Binding<?> doBind(
|
public boolean isValidationEnabled() {
|
||||||
|
return optionsAccess.get().validateMappings();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected <X extends BindableMappingDescriptor> Binding<X> doBind(
|
||||||
XMLEventReader staxEventReader,
|
XMLEventReader staxEventReader,
|
||||||
StartElement rootElementStartEvent,
|
StartElement rootElementStartEvent,
|
||||||
Origin origin) {
|
Origin origin) {
|
||||||
|
@ -51,17 +210,30 @@ public class MappingBinder extends AbstractBinder {
|
||||||
log.debugf( "Performing JAXB binding of hbm.xml document : %s", origin.toString() );
|
log.debugf( "Performing JAXB binding of hbm.xml document : %s", origin.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLEventReader hbmReader = new HbmEventReader( staxEventReader, xmlEventFactory );
|
final XMLEventReader hbmReader = new HbmEventReader( staxEventReader, xmlEventFactory );
|
||||||
JaxbHbmHibernateMapping hbmBindings = jaxb( hbmReader, MappingXsdSupport.INSTANCE.hbmXsd().getSchema(), hbmJaxbContext(), origin );
|
final JaxbHbmHibernateMapping hbmBindings = jaxb( hbmReader, MappingXsdSupport.INSTANCE.hbmXsd()
|
||||||
return new Binding<>( hbmBindings, origin );
|
.getSchema(), hbmJaxbContext(), origin );
|
||||||
|
|
||||||
|
if ( optionsAccess.get().transformHbmMappings() ) {
|
||||||
|
JaxbLogger.JAXB_LOGGER.tracef( "Performing on-the-fly hbm.xml -> mapping.xml transformation - %s ", origin );
|
||||||
|
//noinspection unchecked
|
||||||
|
return new Binding<>( (X) HbmXmlTransformer.transform( hbmBindings, origin, unsupportedHandlingAccess::get ), origin );
|
||||||
|
}
|
||||||
|
|
||||||
|
DeprecationLogger.DEPRECATION_LOGGER.logDeprecatedHbmXmlProcessing( origin.getType(), origin.getName() );
|
||||||
|
//noinspection unchecked
|
||||||
|
return new Binding<>( (X) hbmBindings, origin );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
assert "entity-mappings".equals( rootElementLocalName );
|
||||||
try {
|
try {
|
||||||
log.debugf( "Performing JAXB binding of orm.xml document : %s", origin.toString() );
|
log.debugf( "Performing JAXB binding of orm.xml document : %s", origin.toString() );
|
||||||
|
|
||||||
XMLEventReader reader = new JpaOrmXmlEventReader( staxEventReader, xmlEventFactory );
|
final XMLEventReader reader = new MappingEventReader( staxEventReader, xmlEventFactory );
|
||||||
JaxbEntityMappings bindingRoot = jaxb( reader, MappingXsdSupport.INSTANCE.latestJpaDescriptor().getSchema(), entityMappingsJaxbContext(), origin );
|
final JaxbEntityMappings bindingRoot = jaxb( reader, MappingXsdSupport.latestDescriptor()
|
||||||
return new Binding<>( bindingRoot, origin );
|
.getSchema(), mappingJaxbContext(), origin );
|
||||||
|
//noinspection unchecked
|
||||||
|
return new Binding<>( (X) bindingRoot, origin );
|
||||||
}
|
}
|
||||||
catch (JpaOrmXmlEventReader.BadVersionException e) {
|
catch (JpaOrmXmlEventReader.BadVersionException e) {
|
||||||
throw new UnsupportedOrmXsdVersionException( e.getRequestedVersion(), origin );
|
throw new UnsupportedOrmXsdVersionException( e.getRequestedVersion(), origin );
|
||||||
|
@ -74,19 +246,20 @@ public class MappingBinder extends AbstractBinder {
|
||||||
try {
|
try {
|
||||||
hbmJaxbContext = JAXBContext.newInstance( JaxbHbmHibernateMapping.class );
|
hbmJaxbContext = JAXBContext.newInstance( JaxbHbmHibernateMapping.class );
|
||||||
}
|
}
|
||||||
catch ( JAXBException e ) {
|
catch (JAXBException e) {
|
||||||
throw new ConfigurationException( "Unable to build hbm.xml JAXBContext", e );
|
throw new ConfigurationException( "Unable to build hbm.xml JAXBContext", e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return hbmJaxbContext;
|
return hbmJaxbContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JAXBContext entityMappingsJaxbContext() {
|
@Internal
|
||||||
|
public JAXBContext mappingJaxbContext() {
|
||||||
if ( entityMappingsJaxbContext == null ) {
|
if ( entityMappingsJaxbContext == null ) {
|
||||||
try {
|
try {
|
||||||
entityMappingsJaxbContext = JAXBContext.newInstance( JaxbEntityMappings.class );
|
entityMappingsJaxbContext = JAXBContext.newInstance( JaxbEntityMappings.class );
|
||||||
}
|
}
|
||||||
catch ( JAXBException e ) {
|
catch (JAXBException e) {
|
||||||
throw new ConfigurationException( "Unable to build orm.xml JAXBContext", e );
|
throw new ConfigurationException( "Unable to build orm.xml JAXBContext", e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,18 +18,16 @@ import org.jboss.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper for resolving XML Schema references locally.
|
* Helper for resolving XML Schema references locally.
|
||||||
* <p/>
|
*
|
||||||
* Note that *by design* we always use our ClassLoader to perform the lookups here.
|
* @implNote *By design* we always use our ClassLoader to perform the lookups here.
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class LocalSchemaLocator {
|
public class LocalSchemaLocator {
|
||||||
private static final Logger log = Logger.getLogger( LocalSchemaLocator.class );
|
private static final Logger log = Logger.getLogger( LocalSchemaLocator.class );
|
||||||
|
|
||||||
/**
|
|
||||||
* Disallow direct instantiation
|
|
||||||
*/
|
|
||||||
private LocalSchemaLocator() {
|
private LocalSchemaLocator() {
|
||||||
|
// Disallow direct instantiation
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.boot.jaxb.internal.stax;
|
package org.hibernate.boot.jaxb.internal.stax;
|
||||||
|
|
||||||
|
@ -11,9 +11,10 @@ import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import javax.xml.stream.XMLStreamException;
|
import javax.xml.stream.XMLStreamException;
|
||||||
|
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
import org.hibernate.boot.ResourceStreamLocator;
|
||||||
import org.hibernate.boot.xsd.ConfigXsdSupport;
|
import org.hibernate.boot.xsd.ConfigXsdSupport;
|
||||||
import org.hibernate.boot.xsd.MappingXsdSupport;
|
import org.hibernate.boot.xsd.MappingXsdSupport;
|
||||||
|
import org.hibernate.boot.xsd.XsdDescriptor;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
|
@ -27,10 +28,10 @@ public class LocalXmlResourceResolver implements javax.xml.stream.XMLResolver {
|
||||||
|
|
||||||
public static final String CLASSPATH_EXTENSION_URL_BASE = "classpath://";
|
public static final String CLASSPATH_EXTENSION_URL_BASE = "classpath://";
|
||||||
|
|
||||||
private final ClassLoaderService classLoaderService;
|
private final ResourceStreamLocator resourceStreamLocator;
|
||||||
|
|
||||||
public LocalXmlResourceResolver(ClassLoaderService classLoaderService) {
|
public LocalXmlResourceResolver(ResourceStreamLocator resourceStreamLocator) {
|
||||||
this.classLoaderService = classLoaderService;
|
this.resourceStreamLocator = resourceStreamLocator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -39,42 +40,45 @@ public class LocalXmlResourceResolver implements javax.xml.stream.XMLResolver {
|
||||||
|
|
||||||
if ( namespace != null ) {
|
if ( namespace != null ) {
|
||||||
log.debugf( "Interpreting namespace : %s", namespace );
|
log.debugf( "Interpreting namespace : %s", namespace );
|
||||||
|
if ( MappingXsdSupport._310.getNamespaceUri().matches( namespace ) ) {
|
||||||
|
return openUrlStream( MappingXsdSupport._310 );
|
||||||
|
}
|
||||||
if ( MappingXsdSupport.jpa10.getNamespaceUri().matches( namespace ) ) {
|
if ( MappingXsdSupport.jpa10.getNamespaceUri().matches( namespace ) ) {
|
||||||
// JPA 1.0 and 2.0 share the same namespace URI
|
// JPA 1.0 and 2.0 share the same namespace URI
|
||||||
return openUrlStream( LocalSchemaLocator.resolveLocalSchemaUrl( MappingXsdSupport.jpa10.getLocalResourceName() ) );
|
return openUrlStream( MappingXsdSupport.jpa10 );
|
||||||
}
|
}
|
||||||
else if ( MappingXsdSupport.jpa21.getNamespaceUri().matches( namespace ) ) {
|
else if ( MappingXsdSupport.jpa21.getNamespaceUri().matches( namespace ) ) {
|
||||||
// JPA 2.1 and 2.2 share the same namespace URI
|
// JPA 2.1 and 2.2 share the same namespace URI
|
||||||
return openUrlStream( LocalSchemaLocator.resolveLocalSchemaUrl( MappingXsdSupport.jpa21.getLocalResourceName() ) );
|
return openUrlStream( MappingXsdSupport.jpa21 );
|
||||||
}
|
}
|
||||||
else if ( MappingXsdSupport.jpa30.getNamespaceUri().matches( namespace ) ) {
|
else if ( MappingXsdSupport.jpa30.getNamespaceUri().matches( namespace ) ) {
|
||||||
return openUrlStream( LocalSchemaLocator.resolveLocalSchemaUrl( MappingXsdSupport.jpa30.getLocalResourceName() ) );
|
return openUrlStream( MappingXsdSupport.jpa30 );
|
||||||
}
|
}
|
||||||
else if ( MappingXsdSupport.jpa31.getNamespaceUri().matches( namespace ) ) {
|
else if ( MappingXsdSupport.jpa31.getNamespaceUri().matches( namespace ) ) {
|
||||||
return openUrlStream( LocalSchemaLocator.resolveLocalSchemaUrl( MappingXsdSupport.jpa31.getLocalResourceName() ) );
|
return openUrlStream( MappingXsdSupport.jpa31 );
|
||||||
}
|
}
|
||||||
else if ( ConfigXsdSupport.getJPA10().getNamespaceUri().matches( namespace ) ) {
|
else if ( ConfigXsdSupport.getJPA10().getNamespaceUri().matches( namespace ) ) {
|
||||||
// JPA 1.0 and 2.0 share the same namespace URI
|
// JPA 1.0 and 2.0 share the same namespace URI
|
||||||
return openUrlStream( LocalSchemaLocator.resolveLocalSchemaUrl( ConfigXsdSupport.getJPA10().getLocalResourceName() ) );
|
return openUrlStream( ConfigXsdSupport.getJPA10() );
|
||||||
}
|
}
|
||||||
else if ( ConfigXsdSupport.getJPA21().getNamespaceUri().matches( namespace ) ) {
|
else if ( ConfigXsdSupport.getJPA21().getNamespaceUri().matches( namespace ) ) {
|
||||||
// JPA 2.1 and 2.2 share the same namespace URI
|
// JPA 2.1 and 2.2 share the same namespace URI
|
||||||
return openUrlStream( LocalSchemaLocator.resolveLocalSchemaUrl( ConfigXsdSupport.getJPA21().getLocalResourceName() ) );
|
return openUrlStream( ConfigXsdSupport.getJPA21() );
|
||||||
}
|
}
|
||||||
else if ( ConfigXsdSupport.getJPA30().getNamespaceUri().matches( namespace ) ) {
|
else if ( ConfigXsdSupport.getJPA30().getNamespaceUri().matches( namespace ) ) {
|
||||||
return openUrlStream( LocalSchemaLocator.resolveLocalSchemaUrl( ConfigXsdSupport.getJPA30().getLocalResourceName() ) );
|
return openUrlStream( ConfigXsdSupport.getJPA30() );
|
||||||
}
|
}
|
||||||
else if ( ConfigXsdSupport.getJPA31().getNamespaceUri().matches( namespace ) ) {
|
else if ( ConfigXsdSupport.getJPA31().getNamespaceUri().matches( namespace ) ) {
|
||||||
return openUrlStream( LocalSchemaLocator.resolveLocalSchemaUrl( ConfigXsdSupport.getJPA31().getLocalResourceName() ) );
|
return openUrlStream( ConfigXsdSupport.getJPA31() );
|
||||||
}
|
}
|
||||||
else if ( MappingXsdSupport.hibernateMappingXml.getNamespaceUri().matches( namespace ) ) {
|
else if ( MappingXsdSupport.hibernateMappingXml.getNamespaceUri().matches( namespace ) ) {
|
||||||
return openUrlStream( LocalSchemaLocator.resolveLocalSchemaUrl( MappingXsdSupport.hibernateMappingXml.getLocalResourceName() ) );
|
return openUrlStream( MappingXsdSupport.hibernateMappingXml );
|
||||||
}
|
}
|
||||||
else if ( MappingXsdSupport.hbmXml.getNamespaceUri().matches( namespace ) ) {
|
else if ( MappingXsdSupport.hbmXml.getNamespaceUri().matches( namespace ) ) {
|
||||||
return openUrlStream( LocalSchemaLocator.resolveLocalSchemaUrl( MappingXsdSupport.hbmXml.getLocalResourceName() ) );
|
return openUrlStream( MappingXsdSupport.hbmXml );
|
||||||
}
|
}
|
||||||
else if ( ConfigXsdSupport.cfgXsd().getNamespaceUri().matches( namespace ) ) {
|
else if ( ConfigXsdSupport.cfgXsd().getNamespaceUri().matches( namespace ) ) {
|
||||||
return openUrlStream( LocalSchemaLocator.resolveLocalSchemaUrl( ConfigXsdSupport.cfgXsd().getLocalResourceName() ) );
|
return openUrlStream( ConfigXsdSupport.cfgXsd() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +132,10 @@ public class LocalXmlResourceResolver implements javax.xml.stream.XMLResolver {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private InputStream openUrlStream(XsdDescriptor xsdDescriptor) {
|
||||||
|
return openUrlStream( LocalSchemaLocator.resolveLocalSchemaUrl( xsdDescriptor.getLocalResourceName() ) );
|
||||||
|
}
|
||||||
|
|
||||||
private InputStream openUrlStream(URL url) {
|
private InputStream openUrlStream(URL url) {
|
||||||
try {
|
try {
|
||||||
return url.openStream();
|
return url.openStream();
|
||||||
|
@ -139,7 +147,7 @@ public class LocalXmlResourceResolver implements javax.xml.stream.XMLResolver {
|
||||||
|
|
||||||
private InputStream resolveInLocalNamespace(String path) {
|
private InputStream resolveInLocalNamespace(String path) {
|
||||||
try {
|
try {
|
||||||
return classLoaderService.locateResourceStream( path );
|
return resourceStreamLocator.locateResourceStream( path );
|
||||||
}
|
}
|
||||||
catch ( Throwable t ) {
|
catch ( Throwable t ) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -0,0 +1,183 @@
|
||||||
|
/*
|
||||||
|
* 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.internal.stax;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.xml.namespace.QName;
|
||||||
|
import javax.xml.stream.XMLEventFactory;
|
||||||
|
import javax.xml.stream.XMLEventReader;
|
||||||
|
import javax.xml.stream.XMLStreamException;
|
||||||
|
import javax.xml.stream.events.Attribute;
|
||||||
|
import javax.xml.stream.events.EndElement;
|
||||||
|
import javax.xml.stream.events.Namespace;
|
||||||
|
import javax.xml.stream.events.StartElement;
|
||||||
|
import javax.xml.stream.events.XMLEvent;
|
||||||
|
import javax.xml.stream.util.EventReaderDelegate;
|
||||||
|
|
||||||
|
import org.hibernate.boot.xsd.MappingXsdSupport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* StAX EVentReader for reading `mapping.xml` streams
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
* @author Hardy Ferentschik
|
||||||
|
*/
|
||||||
|
public class MappingEventReader extends EventReaderDelegate {
|
||||||
|
private static final String ROOT_ELEMENT_NAME = "entity-mappings";
|
||||||
|
private static final String VERSION_ATTRIBUTE_NAME = "version";
|
||||||
|
|
||||||
|
private final XMLEventFactory xmlEventFactory;
|
||||||
|
|
||||||
|
public MappingEventReader(XMLEventReader reader, XMLEventFactory xmlEventFactory) {
|
||||||
|
super( reader );
|
||||||
|
this.xmlEventFactory = xmlEventFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public XMLEvent peek() throws XMLStreamException {
|
||||||
|
return wrap( super.peek() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public XMLEvent nextEvent() throws XMLStreamException {
|
||||||
|
return wrap( super.nextEvent() );
|
||||||
|
}
|
||||||
|
|
||||||
|
private XMLEvent wrap(XMLEvent event) {
|
||||||
|
if ( event != null ) {
|
||||||
|
if ( event.isStartElement() ) {
|
||||||
|
return wrap( event.asStartElement() );
|
||||||
|
}
|
||||||
|
else if ( event.isEndElement() ) {
|
||||||
|
return wrap( event.asEndElement() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
private StartElement wrap(StartElement startElement) {
|
||||||
|
final List<Attribute> newElementAttributeList = mapAttributes( startElement );
|
||||||
|
final List<Namespace> newNamespaceList = mapNamespaces( startElement );
|
||||||
|
|
||||||
|
// Transfer the location info from the incoming event to the event factory
|
||||||
|
// so that the event we ask it to generate for us has the same location info
|
||||||
|
xmlEventFactory.setLocation( startElement.getLocation() );
|
||||||
|
return xmlEventFactory.createStartElement(
|
||||||
|
new QName( MappingXsdSupport.latestDescriptor().getNamespaceUri(), startElement.getName().getLocalPart() ),
|
||||||
|
newElementAttributeList.iterator(),
|
||||||
|
newNamespaceList.iterator()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Attribute> mapAttributes(StartElement startElement) {
|
||||||
|
final List<Attribute> mappedAttributes = new ArrayList<>();
|
||||||
|
|
||||||
|
final Iterator<Attribute> existingAttributesIterator = existingXmlAttributesIterator( startElement );
|
||||||
|
while ( existingAttributesIterator.hasNext() ) {
|
||||||
|
final Attribute originalAttribute = existingAttributesIterator.next();
|
||||||
|
final Attribute attributeToUse = mapAttribute( startElement, originalAttribute );
|
||||||
|
mappedAttributes.add( attributeToUse );
|
||||||
|
}
|
||||||
|
|
||||||
|
return mappedAttributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Iterator<Attribute> existingXmlAttributesIterator(StartElement startElement) {
|
||||||
|
return startElement.getAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Attribute mapAttribute(StartElement startElement, Attribute originalAttribute) {
|
||||||
|
// Here we look to see if this attribute is the JPA version attribute, and if so do 2 things:
|
||||||
|
// 1) validate its version attribute is valid
|
||||||
|
// 2) update its version attribute to the default version if not already
|
||||||
|
//
|
||||||
|
// NOTE : atm this is a very simple check using just the attribute's local name
|
||||||
|
// rather than checking its qualified name. It is possibly (though unlikely)
|
||||||
|
// that this could match on "other" version attributes in the same element
|
||||||
|
|
||||||
|
if ( ROOT_ELEMENT_NAME.equals( startElement.getName().getLocalPart() ) ) {
|
||||||
|
if ( VERSION_ATTRIBUTE_NAME.equals( originalAttribute.getName().getLocalPart() ) ) {
|
||||||
|
final String specifiedVersion = originalAttribute.getValue();
|
||||||
|
|
||||||
|
if ( ! MappingXsdSupport.isValidJpaVersion( specifiedVersion ) ) {
|
||||||
|
throw new BadVersionException( specifiedVersion );
|
||||||
|
}
|
||||||
|
|
||||||
|
return xmlEventFactory.createAttribute( VERSION_ATTRIBUTE_NAME, MappingXsdSupport.latestDescriptor().getVersion() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return originalAttribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Namespace> mapNamespaces(StartElement startElement) {
|
||||||
|
return mapNamespaces( existingXmlNamespacesIterator( startElement ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Namespace> mapNamespaces(Iterator<Namespace> originalNamespaceIterator ) {
|
||||||
|
final List<Namespace> mappedNamespaces = new ArrayList<>();
|
||||||
|
|
||||||
|
while ( originalNamespaceIterator.hasNext() ) {
|
||||||
|
final Namespace originalNamespace = originalNamespaceIterator.next();
|
||||||
|
final Namespace mappedNamespace = mapNamespace( originalNamespace );
|
||||||
|
mappedNamespaces.add( mappedNamespace );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( mappedNamespaces.isEmpty() ) {
|
||||||
|
mappedNamespaces.add( xmlEventFactory.createNamespace( MappingXsdSupport.latestDescriptor().getNamespaceUri() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return mappedNamespaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private Iterator<Namespace> existingXmlNamespacesIterator(StartElement startElement) {
|
||||||
|
return startElement.getNamespaces();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Namespace mapNamespace(Namespace originalNamespace) {
|
||||||
|
if ( MappingXsdSupport.shouldBeMappedToLatestJpaDescriptor( originalNamespace.getNamespaceURI() ) ) {
|
||||||
|
// this is a namespace "to map" so map it
|
||||||
|
return xmlEventFactory.createNamespace(
|
||||||
|
originalNamespace.getPrefix(),
|
||||||
|
MappingXsdSupport.latestDescriptor().getNamespaceUri()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return originalNamespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
private XMLEvent wrap(EndElement endElement) {
|
||||||
|
final List<Namespace> targetNamespaces = mapNamespaces( existingXmlNamespacesIterator( endElement ) );
|
||||||
|
|
||||||
|
// Transfer the location info from the incoming event to the event factory
|
||||||
|
// so that the event we ask it to generate for us has the same location info
|
||||||
|
xmlEventFactory.setLocation( endElement.getLocation() );
|
||||||
|
return xmlEventFactory.createEndElement(
|
||||||
|
new QName( MappingXsdSupport.latestDescriptor().getNamespaceUri(), endElement.getName().getLocalPart() ),
|
||||||
|
targetNamespaces.iterator()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Iterator<Namespace> existingXmlNamespacesIterator(EndElement endElement) {
|
||||||
|
return endElement.getNamespaces();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class BadVersionException extends RuntimeException {
|
||||||
|
private final String requestedVersion;
|
||||||
|
|
||||||
|
public BadVersionException(String requestedVersion) {
|
||||||
|
this.requestedVersion = requestedVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRequestedVersion() {
|
||||||
|
return requestedVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
* 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
|
* 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.spi;
|
package org.hibernate.boot.jaxb.mapping;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JAXB binding interface for association attributes (to-one and plural mappings)
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
public interface AssociationAttribute extends PersistentAttribute, FetchableAttribute {
|
public interface AssociationAttribute extends PersistentAttribute, FetchableAttribute {
|
||||||
|
|
||||||
JaxbJoinTable getJoinTable();
|
JaxbJoinTable getJoinTable();
|
||||||
|
|
||||||
void setJoinTable(JaxbJoinTable value);
|
void setJoinTable(JaxbJoinTable value);
|
||||||
|
@ -19,5 +23,4 @@ public interface AssociationAttribute extends PersistentAttribute, FetchableAttr
|
||||||
String getTargetEntity();
|
String getTargetEntity();
|
||||||
|
|
||||||
void setTargetEntity(String value);
|
void setTargetEntity(String value);
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JAXB binding interface for commonality between things which contain attributes.
|
||||||
|
*
|
||||||
|
* @apiNote In the mapping XSD, this equates to the `attributes` and `embeddable-attributes`
|
||||||
|
* nodes rather than the ManagedTypes themselves.
|
||||||
|
*
|
||||||
|
* @author Strong Liu
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public interface AttributesContainer {
|
||||||
|
List<JaxbBasic> getBasicAttributes();
|
||||||
|
|
||||||
|
List<JaxbEmbedded> getEmbeddedAttributes();
|
||||||
|
|
||||||
|
List<JaxbOneToOne> getOneToOneAttributes();
|
||||||
|
|
||||||
|
List<JaxbManyToOne> getManyToOneAttributes();
|
||||||
|
|
||||||
|
List<JaxbHbmAnyMapping> getDiscriminatedAssociations();
|
||||||
|
|
||||||
|
List<JaxbElementCollection> getElementCollectionAttributes();
|
||||||
|
|
||||||
|
List<JaxbOneToMany> getOneToManyAttributes();
|
||||||
|
|
||||||
|
List<JaxbManyToMany> getManyToManyAttributes();
|
||||||
|
|
||||||
|
List<JaxbHbmManyToAny> getPluralDiscriminatedAssociations();
|
||||||
|
|
||||||
|
List<JaxbTransient> getTransients();
|
||||||
|
}
|
|
@ -2,20 +2,24 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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.spi;
|
package org.hibernate.boot.jaxb.mapping;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import jakarta.persistence.EnumType;
|
import jakarta.persistence.EnumType;
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common interface for Jaxb bindings that represent persistent collection attributes.
|
* JAXB binding interface for plural attributes
|
||||||
*
|
*
|
||||||
* @author Brett Meyer
|
* @author Brett Meyer
|
||||||
*/
|
*/
|
||||||
public interface CollectionAttribute extends FetchableAttribute {
|
public interface CollectionAttribute extends FetchableAttribute {
|
||||||
|
JaxbPluralFetchMode getFetchMode();
|
||||||
|
|
||||||
|
void setFetchMode(JaxbPluralFetchMode mode);
|
||||||
|
|
||||||
String getOrderBy();
|
String getOrderBy();
|
||||||
|
|
||||||
|
@ -25,6 +29,10 @@ public interface CollectionAttribute extends FetchableAttribute {
|
||||||
|
|
||||||
void setOrderColumn(JaxbOrderColumn value);
|
void setOrderColumn(JaxbOrderColumn value);
|
||||||
|
|
||||||
|
String getSort();
|
||||||
|
|
||||||
|
void setSort(String value);
|
||||||
|
|
||||||
JaxbMapKey getMapKey();
|
JaxbMapKey getMapKey();
|
||||||
|
|
||||||
void setMapKey(JaxbMapKey value);
|
void setMapKey(JaxbMapKey value);
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JAXB binding interface for discriminated association based attributes (any and many-to-any)
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public interface DiscriminatedAssociation extends PersistentAttribute {
|
||||||
|
/**
|
||||||
|
* Details about the logical association foreign-key
|
||||||
|
*/
|
||||||
|
Key getKey();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Details about the discriminator
|
||||||
|
*/
|
||||||
|
Discriminator getDiscriminator();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The key of a {@link DiscriminatedAssociation} - the (logical) foreign-key value
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
interface Key {
|
||||||
|
List<JaxbColumn> getColumns();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JAXB binding interface for describing the discriminator of a discriminated association
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
interface Discriminator {
|
||||||
|
/**
|
||||||
|
* The column holding the discriminator value
|
||||||
|
*/
|
||||||
|
JaxbColumn getColumn();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapping of discriminator-values to the corresponding entity names
|
||||||
|
*/
|
||||||
|
List<? extends DiscriminatorMapping> getValueMappings();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapping of a discriminator value to the corresponding entity-name
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public interface DiscriminatorMapping {
|
||||||
|
String getDiscriminatorValue();
|
||||||
|
String getCorrespondingEntityName();
|
||||||
|
}
|
|
@ -2,15 +2,16 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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.spi;
|
package org.hibernate.boot.jaxb.mapping;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common interface for JAXB bindings representing entities and mapped-superclasses.
|
* JAXB binding interface for commonality between entity and mapped-superclass mappings
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public interface EntityOrMappedSuperclass extends ManagedType, LifecycleCallbackContainer {
|
public interface EntityOrMappedSuperclass extends ManagedType, LifecycleCallbackContainer {
|
||||||
|
|
||||||
JaxbIdClass getIdClass();
|
JaxbIdClass getIdClass();
|
||||||
|
|
||||||
void setIdClass(JaxbIdClass value);
|
void setIdClass(JaxbIdClass value);
|
||||||
|
@ -58,5 +59,4 @@ public interface EntityOrMappedSuperclass extends ManagedType, LifecycleCallback
|
||||||
JaxbAttributes getAttributes();
|
JaxbAttributes getAttributes();
|
||||||
|
|
||||||
void setAttributes(JaxbAttributes value);
|
void setAttributes(JaxbAttributes value);
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JAXB binding interface for EAGER/LAZY
|
||||||
|
*
|
||||||
|
* @apiNote All standard attributes are fetchable (basics allow FetchType as well); this
|
||||||
|
* contract distinguishes ANY mappings which are always eager and so do not allow
|
||||||
|
* specifying FetchType.
|
||||||
|
*
|
||||||
|
* @author Brett Meyer
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public interface FetchableAttribute extends PersistentAttribute {
|
||||||
|
FetchType getFetch();
|
||||||
|
void setFetch(FetchType value);
|
||||||
|
}
|
|
@ -2,12 +2,12 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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.spi;
|
package org.hibernate.boot.jaxb.mapping;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common interface for all the JAXB bindings representing lifecycle callbacks.
|
* JAXB binding interface for lifecycle callbacks.
|
||||||
*
|
*
|
||||||
* @author Strong Liu
|
* @author Strong Liu
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
|
@ -1,16 +1,25 @@
|
||||||
/*
|
/*
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
* 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
|
* 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.spi;
|
package org.hibernate.boot.jaxb.mapping;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JAXB binding interface for commonality between things which
|
||||||
|
* allow callback declarations. This includes <ul>
|
||||||
|
* <li>
|
||||||
|
* entities and mapped-superclasses
|
||||||
|
* </li>
|
||||||
|
* <li>
|
||||||
|
* entity-listener classes
|
||||||
|
* </li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
public interface LifecycleCallbackContainer {
|
public interface LifecycleCallbackContainer {
|
||||||
String getDescription();
|
|
||||||
|
|
||||||
void setDescription(String value);
|
|
||||||
|
|
||||||
JaxbPrePersist getPrePersist();
|
JaxbPrePersist getPrePersist();
|
||||||
|
|
||||||
void setPrePersist(JaxbPrePersist value);
|
void setPrePersist(JaxbPrePersist value);
|
||||||
|
@ -38,8 +47,4 @@ public interface LifecycleCallbackContainer {
|
||||||
JaxbPostLoad getPostLoad();
|
JaxbPostLoad getPostLoad();
|
||||||
|
|
||||||
void setPostLoad(JaxbPostLoad value);
|
void setPostLoad(JaxbPostLoad value);
|
||||||
|
|
||||||
String getClazz();
|
|
||||||
|
|
||||||
void setClazz(String value);
|
|
||||||
}
|
}
|
|
@ -2,9 +2,9 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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.spi;
|
package org.hibernate.boot.jaxb.mapping;
|
||||||
|
|
||||||
import jakarta.persistence.AccessType;
|
import jakarta.persistence.AccessType;
|
||||||
|
|
|
@ -1,31 +1,34 @@
|
||||||
/*
|
/*
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
* 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
|
* 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.spi;
|
package org.hibernate.boot.jaxb.mapping;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import jakarta.persistence.LockModeType;
|
import jakarta.persistence.LockModeType;
|
||||||
|
|
||||||
public interface NamedQuery extends Serializable {
|
public interface NamedQuery extends Serializable {
|
||||||
String getDescription();
|
String getName();
|
||||||
|
void setName(String value);
|
||||||
|
|
||||||
|
String getDescription();
|
||||||
void setDescription(String value);
|
void setDescription(String value);
|
||||||
|
|
||||||
String getQuery();
|
String getQuery();
|
||||||
|
|
||||||
void setQuery(String value);
|
void setQuery(String value);
|
||||||
|
|
||||||
LockModeType getLockMode();
|
String getComment();
|
||||||
|
void setComment(String comment);
|
||||||
|
|
||||||
|
Integer getTimeout();
|
||||||
|
void setTimeout(Integer timeout);
|
||||||
|
|
||||||
|
LockModeType getLockMode();
|
||||||
void setLockMode(LockModeType value);
|
void setLockMode(LockModeType value);
|
||||||
|
|
||||||
List<JaxbQueryHint> getHint();
|
List<JaxbQueryHint> getHint();
|
||||||
|
|
||||||
String getName();
|
|
||||||
|
|
||||||
void setName(String value);
|
|
||||||
}
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JAXB binding interface for natural-id definitions
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public interface NaturalId {
|
||||||
|
/**
|
||||||
|
* The cache config associated with this natural-id
|
||||||
|
*/
|
||||||
|
JaxbCaching getCaching();
|
||||||
|
|
||||||
|
List<JaxbBasic> getBasicAttributes();
|
||||||
|
|
||||||
|
List<JaxbManyToOne> getManyToOneAttributes();
|
||||||
|
}
|
|
@ -2,9 +2,9 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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.spi;
|
package org.hibernate.boot.jaxb.mapping;
|
||||||
|
|
||||||
import jakarta.persistence.AccessType;
|
import jakarta.persistence.AccessType;
|
||||||
|
|
||||||
|
@ -15,9 +15,21 @@ import jakarta.persistence.AccessType;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public interface PersistentAttribute {
|
public interface PersistentAttribute {
|
||||||
|
/**
|
||||||
|
* The attribute's name
|
||||||
|
*/
|
||||||
String getName();
|
String getName();
|
||||||
|
void setName(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JPA's way to specify an access-strategy
|
||||||
|
*/
|
||||||
AccessType getAccess();
|
AccessType getAccess();
|
||||||
|
|
||||||
void setAccess(AccessType accessType);
|
void setAccess(AccessType accessType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hibernate's pluggable access-strategy support
|
||||||
|
*/
|
||||||
|
String getAttributeAccessor();
|
||||||
|
void setAttributeAccessor(String value);
|
||||||
}
|
}
|
|
@ -2,9 +2,9 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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.spi;
|
package org.hibernate.boot.jaxb.mapping;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common interface for JAXB bindings that understand database schema (tables, sequences, etc).
|
* Common interface for JAXB bindings that understand database schema (tables, sequences, etc).
|
||||||
|
@ -14,10 +14,8 @@ package org.hibernate.boot.jaxb.mapping.spi;
|
||||||
*/
|
*/
|
||||||
public interface SchemaAware {
|
public interface SchemaAware {
|
||||||
String getSchema();
|
String getSchema();
|
||||||
|
|
||||||
void setSchema(String schema);
|
void setSchema(String schema);
|
||||||
|
|
||||||
String getCatalog();
|
String getCatalog();
|
||||||
|
|
||||||
void setCatalog(String catalog);
|
void setCatalog(String catalog);
|
||||||
}
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public interface ToOneAttribute extends AssociationAttribute {
|
||||||
|
JaxbSingularFetchMode getFetchMode();
|
||||||
|
|
||||||
|
void setFetchMode(JaxbSingularFetchMode mode);
|
||||||
|
}
|
|
@ -2,14 +2,14 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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;
|
package org.hibernate.boot.jaxb.mapping.marshall;
|
||||||
|
|
||||||
import jakarta.persistence.AccessType;
|
import jakarta.persistence.AccessType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marshalling support for dealing with JPA AccessType enums. Plugged into JAXB for binding
|
* JAXB marshalling for JPA's {@link AccessType}
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* 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.marshall;
|
||||||
|
|
||||||
|
import org.hibernate.cache.spi.access.AccessType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JAXB marshalling for Hibernate's {@link AccessType}
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class CacheAccessTypeMarshalling {
|
||||||
|
public static AccessType fromXml(String name) {
|
||||||
|
return AccessType.fromExternalName( name );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toXml(AccessType accessType) {
|
||||||
|
return accessType.name();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* 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.marshall;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.hibernate.CacheMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JAXB marshalling for Hibernate's {@link CacheMode}
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class CacheModeMarshalling {
|
||||||
|
public static CacheMode fromXml(String name) {
|
||||||
|
for ( CacheMode mode : CacheMode.values() ) {
|
||||||
|
if ( mode.name().equalsIgnoreCase( name ) ) {
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CacheMode.NORMAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toXml(CacheMode cacheMode) {
|
||||||
|
return cacheMode.name().toLowerCase( Locale.ENGLISH );
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,14 +2,14 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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;
|
package org.hibernate.boot.jaxb.mapping.marshall;
|
||||||
|
|
||||||
import jakarta.persistence.ConstraintMode;
|
import jakarta.persistence.ConstraintMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marshalling support for dealing with JPA ConstraintMode enums. Plugged into JAXB for binding
|
* JAXB marshalling for JPA's {@link ConstraintMode}
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
|
@ -2,14 +2,14 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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;
|
package org.hibernate.boot.jaxb.mapping.marshall;
|
||||||
|
|
||||||
import jakarta.persistence.DiscriminatorType;
|
import jakarta.persistence.DiscriminatorType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marshalling support for dealing with JPA DiscriminatorType enums. Plugged into JAXB for binding
|
* JAXB marshalling for {@link DiscriminatorType}
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
|
@ -2,14 +2,14 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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;
|
package org.hibernate.boot.jaxb.mapping.marshall;
|
||||||
|
|
||||||
import jakarta.persistence.EnumType;
|
import jakarta.persistence.EnumType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marshalling support for dealing with JPA EnumType enums. Plugged into JAXB for binding
|
* JAXB marshalling for {@link EnumType}
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
|
@ -2,14 +2,14 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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;
|
package org.hibernate.boot.jaxb.mapping.marshall;
|
||||||
|
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marshalling support for dealing with JPA FetchType enums. Plugged into JAXB for binding
|
* JAXB marshalling for {@link FetchType}
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* 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.marshall;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.hibernate.FlushMode;
|
||||||
|
import org.hibernate.HibernateException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JAXB marshalling for {@link FlushMode}
|
||||||
|
* <p/>
|
||||||
|
* NOTE : The XML schemas define the use of {@code "never"}, which corresponds
|
||||||
|
* to the removed FlushMode#NEVER. Here we will also handle mapping
|
||||||
|
* FlushMode#NEVER to FlushMode#MANUAL
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class FlushModeMarshalling {
|
||||||
|
public static FlushMode fromXml(String name) {
|
||||||
|
// valid values are a subset of all FlushMode possibilities, so we will
|
||||||
|
// handle the conversion here directly.
|
||||||
|
// Also, we want to map "never"->MANUAL (rather than NEVER)
|
||||||
|
if ( name == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( "never".equalsIgnoreCase( name ) ) {
|
||||||
|
return FlushMode.MANUAL;
|
||||||
|
}
|
||||||
|
else if ( "auto".equalsIgnoreCase( name ) ) {
|
||||||
|
return FlushMode.AUTO;
|
||||||
|
}
|
||||||
|
else if ( "always".equalsIgnoreCase( name ) ) {
|
||||||
|
return FlushMode.ALWAYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the incoming value was not null *and* was not one of the pre-defined
|
||||||
|
// values, we need to throw an exception. This *should never happen if the
|
||||||
|
// document we are processing conforms to the schema...
|
||||||
|
throw new HibernateException( "Unrecognized flush mode : " + name );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toXml(FlushMode mode) {
|
||||||
|
if ( mode == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// conversely, we want to map MANUAL -> "never" here
|
||||||
|
if ( mode == FlushMode.MANUAL ) {
|
||||||
|
return "never";
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo : what to do if the incoming value does not conform to allowed values?
|
||||||
|
// for now, we simply don't deal with that (we write it out).
|
||||||
|
|
||||||
|
return mode.name().toLowerCase( Locale.ENGLISH );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* 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.marshall;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.hibernate.tuple.GenerationTiming;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JAXB marshalling for {@link GenerationTiming}
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class GenerationTimingMarshalling {
|
||||||
|
public static GenerationTiming fromXml(String name) {
|
||||||
|
return GenerationTiming.parseFromName( name );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toXml(GenerationTiming generationTiming) {
|
||||||
|
return ( null == generationTiming ) ?
|
||||||
|
null :
|
||||||
|
generationTiming.name().toLowerCase( Locale.ENGLISH );
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,14 +2,14 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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;
|
package org.hibernate.boot.jaxb.mapping.marshall;
|
||||||
|
|
||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marshalling support for dealing with JPA GenerationType enums. Plugged into JAXB for binding
|
* JAXB marshalling for {@link GenerationType}
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
|
@ -2,14 +2,14 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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;
|
package org.hibernate.boot.jaxb.mapping.marshall;
|
||||||
|
|
||||||
import jakarta.persistence.InheritanceType;
|
import jakarta.persistence.InheritanceType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marshalling support for dealing with JPA InheritanceType enums. Plugged into JAXB for binding
|
* JAXB marshalling for {@link InheritanceType}
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
|
@ -2,14 +2,14 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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;
|
package org.hibernate.boot.jaxb.mapping.marshall;
|
||||||
|
|
||||||
import jakarta.persistence.LockModeType;
|
import jakarta.persistence.LockModeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marshalling support for dealing with JPA LockModeType enums. Plugged into JAXB for binding
|
* JAXB marshalling for {@link LockModeType}
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
|
@ -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.marshall;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.OnDeleteAction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class OnDeleteActionMarshalling {
|
||||||
|
public static OnDeleteAction fromXml(String name) {
|
||||||
|
return OnDeleteAction.fromExternalForm( name );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toXml(OnDeleteAction accessType) {
|
||||||
|
return accessType.getAlternativeName();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* 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.marshall;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.hibernate.engine.OptimisticLockStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JAXB marshalling for {@link OptimisticLockStyle}
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class OptimisticLockStyleMarshalling {
|
||||||
|
public static OptimisticLockStyle fromXml(String name) {
|
||||||
|
return OptimisticLockStyle.valueOf( name == null ? null : name.toUpperCase( Locale.ENGLISH ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toXml(OptimisticLockStyle lockMode) {
|
||||||
|
return lockMode == null ? null : lockMode.name().toLowerCase( Locale.ENGLISH );
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,14 +2,14 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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;
|
package org.hibernate.boot.jaxb.mapping.marshall;
|
||||||
|
|
||||||
import jakarta.persistence.ParameterMode;
|
import jakarta.persistence.ParameterMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marshalling support for dealing with JPA ParameterMode enums. Plugged into JAXB for binding
|
* JAXB marshalling for {@link ParameterMode}
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
|
@ -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.marshall;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.PolymorphismType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class PolymorphismTypeMarshalling {
|
||||||
|
public static PolymorphismType fromXml(String value) {
|
||||||
|
return PolymorphismType.fromExternalValue( value );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toXml(PolymorphismType value) {
|
||||||
|
return value.getExternalForm();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* 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.marshall;
|
||||||
|
|
||||||
|
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JAXB marshalling for {@link ExecuteUpdateResultCheckStyle}
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class ResultCheckStyleMarshalling {
|
||||||
|
public static ExecuteUpdateResultCheckStyle fromXml(String name) {
|
||||||
|
return ExecuteUpdateResultCheckStyle.fromExternalName( name );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toXml(ExecuteUpdateResultCheckStyle style) {
|
||||||
|
return style.externalName();
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,14 +2,14 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* 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;
|
package org.hibernate.boot.jaxb.mapping.marshall;
|
||||||
|
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marshalling support for dealing with JPA TemporalType enums. Plugged into JAXB for binding
|
* JAXB marshalling for {@link TemporalType}
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
|
@ -1,11 +0,0 @@
|
||||||
/*
|
|
||||||
* 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>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JAXB for JPA's {@code orm.xml} mapping schema.
|
|
||||||
*/
|
|
||||||
package org.hibernate.boot.jaxb.mapping;
|
|
|
@ -1,35 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.spi;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Common interface for JAXB bindings which are containers of attributes.
|
|
||||||
*
|
|
||||||
* @author Strong Liu
|
|
||||||
* @author Steve Ebersole
|
|
||||||
*/
|
|
||||||
public interface AttributesContainer {
|
|
||||||
|
|
||||||
List<JaxbTransient> getTransient();
|
|
||||||
|
|
||||||
List<JaxbBasic> getBasic();
|
|
||||||
|
|
||||||
List<JaxbElementCollection> getElementCollection();
|
|
||||||
|
|
||||||
List<JaxbEmbedded> getEmbedded();
|
|
||||||
|
|
||||||
List<JaxbManyToMany> getManyToMany();
|
|
||||||
|
|
||||||
List<JaxbManyToOne> getManyToOne();
|
|
||||||
|
|
||||||
List<JaxbOneToMany> getOneToMany();
|
|
||||||
|
|
||||||
List<JaxbOneToOne> getOneToOne();
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.spi;
|
|
||||||
|
|
||||||
import jakarta.persistence.FetchType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Common interface for JAXB bindings that represent attributes with laziness and fetch style.
|
|
||||||
*
|
|
||||||
* @author Brett Meyer
|
|
||||||
*/
|
|
||||||
public interface FetchableAttribute {
|
|
||||||
|
|
||||||
FetchType getFetch();
|
|
||||||
|
|
||||||
void setFetch(FetchType value);
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
* 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.spi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common type for things that can get be bound to a {@link Binding} for
|
||||||
|
* mapping documents.
|
||||||
|
*
|
||||||
|
* @apiNote The models generated from the hbm.xml and mapping.xml schemas
|
||||||
|
* both implement it.
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public interface BindableMappingDescriptor {
|
||||||
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.boot.jaxb.spi;
|
package org.hibernate.boot.jaxb.spi;
|
||||||
|
|
||||||
|
@ -16,24 +16,22 @@ import org.hibernate.boot.jaxb.Origin;
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public interface Binder {
|
public interface Binder<T> {
|
||||||
/**
|
/**
|
||||||
* Bind from an XML source.
|
* Bind from an XML source.
|
||||||
*
|
*
|
||||||
* @param source The XML source.
|
* @param source The XML source.
|
||||||
* @param origin The descriptor of the source origin
|
* @param origin The descriptor of the source origin
|
||||||
*
|
|
||||||
* @return The bound JAXB model
|
* @return The bound JAXB model
|
||||||
*/
|
*/
|
||||||
Binding bind(Source source, Origin origin);
|
<X extends T> Binding<X> bind(Source source, Origin origin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind from an InputStream
|
* Bind from an InputStream
|
||||||
*
|
*
|
||||||
* @param stream The InputStream containing XML
|
* @param stream The InputStream containing XML
|
||||||
* @param origin The descriptor of the stream origin
|
* @param origin The descriptor of the stream origin
|
||||||
*
|
|
||||||
* @return The bound JAXB model
|
* @return The bound JAXB model
|
||||||
*/
|
*/
|
||||||
Binding bind(InputStream stream, Origin origin);
|
<X extends T> Binding<X> bind(InputStream stream, Origin origin);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.hibernate.TimeZoneStorageStrategy;
|
|
||||||
import org.hibernate.boot.MetadataSources;
|
import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.boot.internal.InFlightMetadataCollectorImpl;
|
import org.hibernate.boot.internal.InFlightMetadataCollectorImpl;
|
||||||
import org.hibernate.boot.internal.MetadataBuildingContextRootImpl;
|
import org.hibernate.boot.internal.MetadataBuildingContextRootImpl;
|
||||||
|
@ -306,12 +305,25 @@ public class MetadataBuildingProcess {
|
||||||
processor.finishUp();
|
processor.finishUp();
|
||||||
|
|
||||||
if ( options.isXmlMappingEnabled() ) {
|
if ( options.isXmlMappingEnabled() ) {
|
||||||
|
//noinspection deprecation
|
||||||
final Iterable<AdditionalJaxbMappingProducer> producers = classLoaderService.loadJavaServices( AdditionalJaxbMappingProducer.class );
|
final Iterable<AdditionalJaxbMappingProducer> producers = classLoaderService.loadJavaServices( AdditionalJaxbMappingProducer.class );
|
||||||
if ( producers != null ) {
|
if ( producers != null ) {
|
||||||
final EntityHierarchyBuilder hierarchyBuilder = new EntityHierarchyBuilder();
|
final EntityHierarchyBuilder hierarchyBuilder = new EntityHierarchyBuilder();
|
||||||
// final MappingBinder mappingBinder = new MappingBinder( true );
|
final MappingBinder mappingBinder = new MappingBinder(
|
||||||
// We need to disable validation here. It seems Envers is not producing valid (according to schema) XML
|
classLoaderService,
|
||||||
final MappingBinder mappingBinder = new MappingBinder( classLoaderService, false );
|
new MappingBinder.Options() {
|
||||||
|
@Override
|
||||||
|
public boolean validateMappings() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean transformHbmMappings() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
//noinspection deprecation
|
||||||
for ( AdditionalJaxbMappingProducer producer : producers ) {
|
for ( AdditionalJaxbMappingProducer producer : producers ) {
|
||||||
log.tracef( "Calling AdditionalJaxbMappingProducer : %s", producer );
|
log.tracef( "Calling AdditionalJaxbMappingProducer : %s", producer );
|
||||||
Collection<MappingDocument> additionalMappings = producer.produceAdditionalMappings(
|
Collection<MappingDocument> additionalMappings = producer.produceAdditionalMappings(
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.boot.model.source.internal.annotations;
|
package org.hibernate.boot.model.source.internal.annotations;
|
||||||
|
|
||||||
|
@ -11,18 +11,13 @@ import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import jakarta.persistence.AttributeConverter;
|
|
||||||
import jakarta.persistence.Converter;
|
|
||||||
import jakarta.persistence.Embeddable;
|
|
||||||
import jakarta.persistence.Entity;
|
|
||||||
import jakarta.persistence.MappedSuperclass;
|
|
||||||
|
|
||||||
import org.hibernate.annotations.common.reflection.MetadataProviderInjector;
|
import org.hibernate.annotations.common.reflection.MetadataProviderInjector;
|
||||||
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||||
import org.hibernate.annotations.common.reflection.XClass;
|
import org.hibernate.annotations.common.reflection.XClass;
|
||||||
import org.hibernate.boot.AttributeConverterInfo;
|
import org.hibernate.boot.AttributeConverterInfo;
|
||||||
import org.hibernate.boot.internal.MetadataBuildingContextRootImpl;
|
import org.hibernate.boot.internal.MetadataBuildingContextRootImpl;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappings;
|
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
|
||||||
import org.hibernate.boot.jaxb.spi.Binding;
|
import org.hibernate.boot.jaxb.spi.Binding;
|
||||||
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
||||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||||
|
@ -41,6 +36,12 @@ import org.hibernate.internal.util.collections.CollectionHelper;
|
||||||
import org.jboss.jandex.IndexView;
|
import org.jboss.jandex.IndexView;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
|
import jakarta.persistence.AttributeConverter;
|
||||||
|
import jakarta.persistence.Converter;
|
||||||
|
import jakarta.persistence.Embeddable;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.MappedSuperclass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
@ -83,10 +84,10 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
|
||||||
( (MetadataProviderInjector) reflectionManager ).getMetadataProvider();
|
( (MetadataProviderInjector) reflectionManager ).getMetadataProvider();
|
||||||
for ( Binding<?> xmlBinding : managedResources.getXmlMappingBindings() ) {
|
for ( Binding<?> xmlBinding : managedResources.getXmlMappingBindings() ) {
|
||||||
Object root = xmlBinding.getRoot();
|
Object root = xmlBinding.getRoot();
|
||||||
if ( !(root instanceof JaxbEntityMappings) ) {
|
if ( !( root instanceof JaxbEntityMappings ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
JaxbEntityMappings entityMappings = (JaxbEntityMappings) xmlBinding.getRoot();
|
final JaxbEntityMappings entityMappings = (JaxbEntityMappings) xmlBinding.getRoot();
|
||||||
|
|
||||||
final List<String> classNames = jpaMetadataProvider.getXMLContext().addDocument( entityMappings );
|
final List<String> classNames = jpaMetadataProvider.getXMLContext().addDocument( entityMappings );
|
||||||
for ( String className : classNames ) {
|
for ( String className : classNames ) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.boot.registry.classloading.spi;
|
package org.hibernate.boot.registry.classloading.spi;
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@ import java.net.URL;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hibernate.boot.ResourceLocator;
|
||||||
|
import org.hibernate.boot.ResourceStreamLocator;
|
||||||
import org.hibernate.service.Service;
|
import org.hibernate.service.Service;
|
||||||
import org.hibernate.service.spi.Stoppable;
|
import org.hibernate.service.spi.Stoppable;
|
||||||
|
|
||||||
|
@ -20,7 +22,7 @@ import org.hibernate.service.spi.Stoppable;
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public interface ClassLoaderService extends Service, Stoppable {
|
public interface ClassLoaderService extends ResourceLocator, ResourceStreamLocator, Service, Stoppable {
|
||||||
/**
|
/**
|
||||||
* Locate a class by name.
|
* Locate a class by name.
|
||||||
*
|
*
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.hibernate.internal.CoreLogging;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.service.Service;
|
import org.hibernate.service.Service;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
import org.hibernate.service.internal.AbstractServiceRegistryImpl;
|
||||||
import org.hibernate.service.spi.ServiceBinding;
|
import org.hibernate.service.spi.ServiceBinding;
|
||||||
import org.hibernate.service.spi.ServiceException;
|
import org.hibernate.service.spi.ServiceException;
|
||||||
import org.hibernate.service.spi.ServiceInitiator;
|
import org.hibernate.service.spi.ServiceInitiator;
|
||||||
|
@ -306,4 +307,9 @@ public class BootstrapServiceRegistryImpl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends Service> T fromRegistryOrChildren(Class<T> serviceRole) {
|
||||||
|
return AbstractServiceRegistryImpl.fromRegistryOrChildren( serviceRole, this, childRegistries );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
import org.hibernate.boot.MappingNotFoundException;
|
import org.hibernate.boot.MappingNotFoundException;
|
||||||
import org.hibernate.boot.archive.spi.InputStreamAccess;
|
import org.hibernate.boot.archive.spi.InputStreamAccess;
|
||||||
|
@ -19,6 +20,7 @@ import org.hibernate.boot.jaxb.internal.FileXmlSource;
|
||||||
import org.hibernate.boot.jaxb.internal.InputStreamXmlSource;
|
import org.hibernate.boot.jaxb.internal.InputStreamXmlSource;
|
||||||
import org.hibernate.boot.jaxb.internal.MappingBinder;
|
import org.hibernate.boot.jaxb.internal.MappingBinder;
|
||||||
import org.hibernate.boot.jaxb.internal.UrlXmlSource;
|
import org.hibernate.boot.jaxb.internal.UrlXmlSource;
|
||||||
|
import org.hibernate.boot.jaxb.spi.BindableMappingDescriptor;
|
||||||
import org.hibernate.boot.jaxb.spi.Binding;
|
import org.hibernate.boot.jaxb.spi.Binding;
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
@ -26,6 +28,9 @@ import org.hibernate.service.ServiceRegistry;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Poor naming. Models the binder and a class-loader to be a
|
||||||
|
* one-stop-shop in terms of {@link #bind binding} a resource
|
||||||
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class XmlMappingBinderAccess {
|
public class XmlMappingBinderAccess {
|
||||||
|
@ -36,18 +41,19 @@ public class XmlMappingBinderAccess {
|
||||||
|
|
||||||
public XmlMappingBinderAccess(ServiceRegistry serviceRegistry) {
|
public XmlMappingBinderAccess(ServiceRegistry serviceRegistry) {
|
||||||
this.classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
this.classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||||
|
this.mappingBinder = new MappingBinder( serviceRegistry );
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE : The boolean here indicates whether or not to perform validation as we load XML documents.
|
public XmlMappingBinderAccess(ServiceRegistry serviceRegistry, Function<String, Object> configAccess) {
|
||||||
// Should we expose this setting? Disabling would speed up JAXP and JAXB at runtime, but potentially
|
this.classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||||
// at the cost of less obvious errors when a document is not valid.
|
this.mappingBinder = new MappingBinder( classLoaderService, configAccess );
|
||||||
this.mappingBinder = new MappingBinder( classLoaderService, true );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MappingBinder getMappingBinder() {
|
public MappingBinder getMappingBinder() {
|
||||||
return mappingBinder;
|
return mappingBinder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Binding bind(String resource) {
|
public <X extends BindableMappingDescriptor> Binding<X> bind(String resource) {
|
||||||
LOG.tracef( "reading mappings from resource : %s", resource );
|
LOG.tracef( "reading mappings from resource : %s", resource );
|
||||||
|
|
||||||
final Origin origin = new Origin( SourceType.RESOURCE, resource );
|
final Origin origin = new Origin( SourceType.RESOURCE, resource );
|
||||||
|
@ -56,10 +62,11 @@ public class XmlMappingBinderAccess {
|
||||||
throw new MappingNotFoundException( origin );
|
throw new MappingNotFoundException( origin );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//noinspection unchecked
|
||||||
return new UrlXmlSource( origin, url ).doBind( getMappingBinder() );
|
return new UrlXmlSource( origin, url ).doBind( getMappingBinder() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Binding bind(File file) {
|
public <X extends BindableMappingDescriptor> Binding<X> bind(File file) {
|
||||||
final Origin origin = new Origin( SourceType.FILE, file.getPath() );
|
final Origin origin = new Origin( SourceType.FILE, file.getPath() );
|
||||||
LOG.tracef( "reading mappings from file : %s", origin.getName() );
|
LOG.tracef( "reading mappings from file : %s", origin.getName() );
|
||||||
|
|
||||||
|
@ -67,15 +74,17 @@ public class XmlMappingBinderAccess {
|
||||||
throw new MappingNotFoundException( origin );
|
throw new MappingNotFoundException( origin );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//noinspection unchecked
|
||||||
return new FileXmlSource( origin, file ).doBind( getMappingBinder() );
|
return new FileXmlSource( origin, file ).doBind( getMappingBinder() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Binding bind(InputStreamAccess xmlInputStreamAccess) {
|
public <X extends BindableMappingDescriptor> Binding<X> bind(InputStreamAccess xmlInputStreamAccess) {
|
||||||
LOG.tracef( "reading mappings from InputStreamAccess : %s", xmlInputStreamAccess.getStreamName() );
|
LOG.tracef( "reading mappings from InputStreamAccess : %s", xmlInputStreamAccess.getStreamName() );
|
||||||
|
|
||||||
final Origin origin = new Origin( SourceType.INPUT_STREAM, xmlInputStreamAccess.getStreamName() );
|
final Origin origin = new Origin( SourceType.INPUT_STREAM, xmlInputStreamAccess.getStreamName() );
|
||||||
InputStream xmlInputStream = xmlInputStreamAccess.accessInputStream();
|
InputStream xmlInputStream = xmlInputStreamAccess.accessInputStream();
|
||||||
try {
|
try {
|
||||||
|
//noinspection unchecked
|
||||||
return new InputStreamXmlSource( origin, xmlInputStream, false ).doBind( mappingBinder );
|
return new InputStreamXmlSource( origin, xmlInputStream, false ).doBind( mappingBinder );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
@ -88,17 +97,19 @@ public class XmlMappingBinderAccess {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Binding bind(InputStream xmlInputStream) {
|
public <X extends BindableMappingDescriptor> Binding<X> bind(InputStream xmlInputStream) {
|
||||||
LOG.trace( "reading mappings from InputStream" );
|
LOG.trace( "reading mappings from InputStream" );
|
||||||
final Origin origin = new Origin( SourceType.INPUT_STREAM, null );
|
final Origin origin = new Origin( SourceType.INPUT_STREAM, null );
|
||||||
|
//noinspection unchecked
|
||||||
return new InputStreamXmlSource( origin, xmlInputStream, false ).doBind( getMappingBinder() );
|
return new InputStreamXmlSource( origin, xmlInputStream, false ).doBind( getMappingBinder() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Binding bind(URL url) {
|
public <X extends BindableMappingDescriptor> Binding<X> bind(URL url) {
|
||||||
final String urlExternalForm = url.toExternalForm();
|
final String urlExternalForm = url.toExternalForm();
|
||||||
LOG.debugf( "Reading mapping document from URL : %s", urlExternalForm );
|
LOG.debugf( "Reading mapping document from URL : %s", urlExternalForm );
|
||||||
|
|
||||||
final Origin origin = new Origin( SourceType.URL, urlExternalForm );
|
final Origin origin = new Origin( SourceType.URL, urlExternalForm );
|
||||||
|
//noinspection unchecked
|
||||||
return new UrlXmlSource( origin, url ).doBind( getMappingBinder() );
|
return new UrlXmlSource( origin, url ).doBind( getMappingBinder() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
* 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
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.boot.xsd;
|
package org.hibernate.boot.xsd;
|
||||||
|
|
||||||
|
@ -23,6 +23,12 @@ public class MappingXsdSupport {
|
||||||
*/
|
*/
|
||||||
public static final MappingXsdSupport INSTANCE = new MappingXsdSupport();
|
public static final MappingXsdSupport INSTANCE = new MappingXsdSupport();
|
||||||
|
|
||||||
|
public static final XsdDescriptor _310 = LocalXsdResolver.buildXsdDescriptor(
|
||||||
|
"org/hibernate/xsd/mapping/mapping-3.1.0.xsd",
|
||||||
|
"3.1",
|
||||||
|
"http://www.hibernate.org/xsd/orm/mapping"
|
||||||
|
);
|
||||||
|
|
||||||
public static final XsdDescriptor jpa10 = LocalXsdResolver.buildXsdDescriptor(
|
public static final XsdDescriptor jpa10 = LocalXsdResolver.buildXsdDescriptor(
|
||||||
"org/hibernate/jpa/orm_1_0.xsd",
|
"org/hibernate/jpa/orm_1_0.xsd",
|
||||||
"1.0",
|
"1.0",
|
||||||
|
@ -75,6 +81,10 @@ public class MappingXsdSupport {
|
||||||
//Do not construct new instances
|
//Do not construct new instances
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static XsdDescriptor latestDescriptor() {
|
||||||
|
return _310;
|
||||||
|
}
|
||||||
|
|
||||||
public static XsdDescriptor latestJpaDescriptor() {
|
public static XsdDescriptor latestJpaDescriptor() {
|
||||||
return jpa22;
|
return jpa22;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.cache.spi.access;
|
package org.hibernate.cache.spi.access;
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public enum AccessType {
|
||||||
}
|
}
|
||||||
// Check to see if making upper-case matches an enum name.
|
// Check to see if making upper-case matches an enum name.
|
||||||
try {
|
try {
|
||||||
return AccessType.valueOf( externalName.toUpperCase( Locale.ROOT) );
|
return AccessType.valueOf( externalName.toUpperCase( Locale.ROOT ) );
|
||||||
}
|
}
|
||||||
catch ( IllegalArgumentException e ) {
|
catch ( IllegalArgumentException e ) {
|
||||||
throw new UnknownAccessTypeException( externalName );
|
throw new UnknownAccessTypeException( externalName );
|
||||||
|
|
|
@ -2,29 +2,30 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.cfg;
|
package org.hibernate.cfg;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import jakarta.persistence.criteria.CriteriaDelete;
|
|
||||||
import jakarta.persistence.criteria.CriteriaQuery;
|
|
||||||
import jakarta.persistence.criteria.CriteriaUpdate;
|
|
||||||
|
|
||||||
import org.hibernate.CustomEntityDirtinessStrategy;
|
import org.hibernate.CustomEntityDirtinessStrategy;
|
||||||
import org.hibernate.Incubating;
|
import org.hibernate.Incubating;
|
||||||
import org.hibernate.Interceptor;
|
import org.hibernate.Interceptor;
|
||||||
import org.hibernate.SessionFactoryObserver;
|
import org.hibernate.SessionFactoryObserver;
|
||||||
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
||||||
import org.hibernate.id.enhanced.ImplicitDatabaseObjectNamingStrategy;
|
|
||||||
import org.hibernate.cache.spi.TimestampsCacheFactory;
|
import org.hibernate.cache.spi.TimestampsCacheFactory;
|
||||||
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
|
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
|
||||||
|
import org.hibernate.id.enhanced.ImplicitDatabaseObjectNamingStrategy;
|
||||||
import org.hibernate.jpa.LegacySpecHints;
|
import org.hibernate.jpa.LegacySpecHints;
|
||||||
import org.hibernate.query.spi.QueryPlan;
|
import org.hibernate.query.spi.QueryPlan;
|
||||||
import org.hibernate.query.sqm.NullPrecedence;
|
import org.hibernate.query.sqm.NullPrecedence;
|
||||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||||
import org.hibernate.resource.jdbc.spi.StatementInspector;
|
import org.hibernate.resource.jdbc.spi.StatementInspector;
|
||||||
|
|
||||||
|
import jakarta.persistence.criteria.CriteriaDelete;
|
||||||
|
import jakarta.persistence.criteria.CriteriaQuery;
|
||||||
|
import jakarta.persistence.criteria.CriteriaUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enumerates the configuration properties supported by Hibernate, including
|
* Enumerates the configuration properties supported by Hibernate, including
|
||||||
* properties defined by the JPA specification.
|
* properties defined by the JPA specification.
|
||||||
|
@ -2934,4 +2935,31 @@ public interface AvailableSettings {
|
||||||
* By default, the persistent context is not discarded, as per the JPA specification.
|
* By default, the persistent context is not discarded, as per the JPA specification.
|
||||||
*/
|
*/
|
||||||
String DISCARD_PC_ON_CLOSE = "hibernate.discard_pc_on_close";
|
String DISCARD_PC_ON_CLOSE = "hibernate.discard_pc_on_close";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether XML should be validated against their schema as Hibernate reads them.
|
||||||
|
* <p/>
|
||||||
|
* Default is {@code true}
|
||||||
|
*
|
||||||
|
* @since 6.1
|
||||||
|
*/
|
||||||
|
String VALIDATE_XML = "hibernate.validate_xml";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables processing `hbm.xml` mappings by transforming them to `mapping.xml` and using
|
||||||
|
* that processor. Default is false, must be opted-into.
|
||||||
|
*
|
||||||
|
* @since 6.1
|
||||||
|
*/
|
||||||
|
String TRANSFORM_HBM_XML = "hibernate.transform_hbm_xml.enabled";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How features in a `hbm.xml` file which are not supported for transformation should be handled.
|
||||||
|
* <p/>
|
||||||
|
* Default is {@link org.hibernate.boot.jaxb.hbm.transform.UnsupportedFeatureHandling#ERROR}
|
||||||
|
*
|
||||||
|
* @see org.hibernate.boot.jaxb.hbm.transform.UnsupportedFeatureHandling
|
||||||
|
* @since 6.1
|
||||||
|
*/
|
||||||
|
String TRANSFORM_HBM_XML_FEATURE_HANDLING = "hibernate.transform_hbm_xml.unsupported_feature_handling";
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,6 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import jakarta.persistence.AttributeConverter;
|
|
||||||
import jakarta.persistence.SharedCacheMode;
|
|
||||||
|
|
||||||
import org.hibernate.EmptyInterceptor;
|
import org.hibernate.EmptyInterceptor;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
@ -39,14 +37,14 @@ import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl;
|
||||||
import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
|
import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
|
||||||
import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl;
|
import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl;
|
||||||
import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
|
import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
|
||||||
import org.hibernate.boot.registry.BootstrapServiceRegistry;
|
|
||||||
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
|
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
|
||||||
import org.hibernate.boot.query.NamedHqlQueryDefinition;
|
import org.hibernate.boot.query.NamedHqlQueryDefinition;
|
||||||
import org.hibernate.boot.query.NamedNativeQueryDefinition;
|
import org.hibernate.boot.query.NamedNativeQueryDefinition;
|
||||||
import org.hibernate.boot.query.NamedProcedureCallDefinition;
|
import org.hibernate.boot.query.NamedProcedureCallDefinition;
|
||||||
import org.hibernate.boot.query.NamedResultSetMappingDescriptor;
|
import org.hibernate.boot.query.NamedResultSetMappingDescriptor;
|
||||||
|
import org.hibernate.boot.registry.BootstrapServiceRegistry;
|
||||||
|
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
|
||||||
|
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.boot.spi.XmlMappingBinderAccess;
|
import org.hibernate.boot.spi.XmlMappingBinderAccess;
|
||||||
import org.hibernate.cfg.annotations.NamedEntityGraphDefinition;
|
import org.hibernate.cfg.annotations.NamedEntityGraphDefinition;
|
||||||
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
|
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
|
||||||
|
@ -59,6 +57,9 @@ import org.hibernate.type.BasicType;
|
||||||
import org.hibernate.type.SerializationException;
|
import org.hibernate.type.SerializationException;
|
||||||
import org.hibernate.usertype.UserType;
|
import org.hibernate.usertype.UserType;
|
||||||
|
|
||||||
|
import jakarta.persistence.AttributeConverter;
|
||||||
|
import jakarta.persistence.SharedCacheMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A convenience API making it easier to bootstrap an instance of Hibernate
|
* A convenience API making it easier to bootstrap an instance of Hibernate
|
||||||
* using {@link MetadataBuilder} and {@link StandardServiceRegistryBuilder}
|
* using {@link MetadataBuilder} and {@link StandardServiceRegistryBuilder}
|
||||||
|
@ -151,11 +152,18 @@ public class Configuration {
|
||||||
*/
|
*/
|
||||||
public Configuration(BootstrapServiceRegistry serviceRegistry) {
|
public Configuration(BootstrapServiceRegistry serviceRegistry) {
|
||||||
this.bootstrapServiceRegistry = serviceRegistry;
|
this.bootstrapServiceRegistry = serviceRegistry;
|
||||||
this.metadataSources = new MetadataSources( serviceRegistry );
|
this.metadataSources = new MetadataSources( serviceRegistry, createMappingBinderAccess( serviceRegistry ) );
|
||||||
this.classmateContext = new ClassmateContext();
|
this.classmateContext = new ClassmateContext();
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private XmlMappingBinderAccess createMappingBinderAccess(BootstrapServiceRegistry serviceRegistry) {
|
||||||
|
return new XmlMappingBinderAccess(
|
||||||
|
serviceRegistry,
|
||||||
|
(settingName) -> properties == null ? null : properties.get( settingName )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance, using the given {@link MetadataSources}, and a
|
* Create a new instance, using the given {@link MetadataSources}, and a
|
||||||
* {@link BootstrapServiceRegistry} obtained from the {@link MetadataSources}.
|
* {@link BootstrapServiceRegistry} obtained from the {@link MetadataSources}.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.cfg.annotations.reflection.internal;
|
package org.hibernate.cfg.annotations.reflection.internal;
|
||||||
|
|
||||||
|
@ -21,6 +21,88 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import org.hibernate.AnnotationException;
|
||||||
|
import org.hibernate.annotations.Any;
|
||||||
|
import org.hibernate.annotations.Cache;
|
||||||
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
|
import org.hibernate.annotations.Cascade;
|
||||||
|
import org.hibernate.annotations.Columns;
|
||||||
|
import org.hibernate.annotations.ManyToAny;
|
||||||
|
import org.hibernate.annotations.Subselect;
|
||||||
|
import org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor;
|
||||||
|
import org.hibernate.annotations.common.annotationfactory.AnnotationFactory;
|
||||||
|
import org.hibernate.annotations.common.reflection.AnnotationReader;
|
||||||
|
import org.hibernate.annotations.common.reflection.ReflectionUtil;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.AssociationAttribute;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.AttributesContainer;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.EntityOrMappedSuperclass;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbAssociationOverride;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbAttributeOverride;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbAttributes;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbBasic;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbCaching;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbCascadeType;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbCollectionTable;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbColumn;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbColumnResult;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbConstructorResult;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbConvert;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbDiscriminatorColumn;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbElementCollection;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbEmbeddable;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbEmbedded;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbEmbeddedId;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbEmptyType;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbEntity;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbEntityListener;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbEntityListeners;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbEntityResult;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbFieldResult;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbGeneratedValue;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbId;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbIdClass;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbIndex;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbInheritance;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbJoinColumn;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbJoinTable;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbLob;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbManyToMany;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbManyToOne;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbMapKey;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbMapKeyClass;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbMapKeyColumn;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbMapKeyJoinColumn;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbMappedSuperclass;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbNamedAttributeNode;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbNamedEntityGraph;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbNamedNativeQuery;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbNamedQuery;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbNamedStoredProcedureQuery;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbNamedSubgraph;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbOneToMany;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbOneToOne;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbOrderColumn;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbPrimaryKeyJoinColumn;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbQueryHint;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbSecondaryTable;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbSequenceGenerator;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbSqlResultSetMapping;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbStoredProcedureParameter;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbTable;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbTableGenerator;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbUniqueConstraint;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbVersion;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.LifecycleCallbackContainer;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.ManagedType;
|
||||||
|
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||||
|
import org.hibernate.boot.spi.BootstrapContext;
|
||||||
|
import org.hibernate.boot.spi.ClassLoaderAccess;
|
||||||
|
import org.hibernate.cfg.annotations.reflection.PersistentAttributeFilter;
|
||||||
|
import org.hibernate.internal.CoreLogging;
|
||||||
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
|
import org.hibernate.internal.util.StringHelper;
|
||||||
|
|
||||||
import jakarta.persistence.Access;
|
import jakarta.persistence.Access;
|
||||||
import jakarta.persistence.AccessType;
|
import jakarta.persistence.AccessType;
|
||||||
import jakarta.persistence.AssociationOverride;
|
import jakarta.persistence.AssociationOverride;
|
||||||
|
@ -114,84 +196,6 @@ import jakarta.persistence.Transient;
|
||||||
import jakarta.persistence.UniqueConstraint;
|
import jakarta.persistence.UniqueConstraint;
|
||||||
import jakarta.persistence.Version;
|
import jakarta.persistence.Version;
|
||||||
|
|
||||||
import org.hibernate.AnnotationException;
|
|
||||||
import org.hibernate.annotations.Any;
|
|
||||||
import org.hibernate.annotations.Cascade;
|
|
||||||
import org.hibernate.annotations.Columns;
|
|
||||||
import org.hibernate.annotations.ManyToAny;
|
|
||||||
import org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor;
|
|
||||||
import org.hibernate.annotations.common.annotationfactory.AnnotationFactory;
|
|
||||||
import org.hibernate.annotations.common.reflection.AnnotationReader;
|
|
||||||
import org.hibernate.annotations.common.reflection.ReflectionUtil;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.AssociationAttribute;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.AttributesContainer;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.EntityOrMappedSuperclass;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbAssociationOverride;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbAttributeOverride;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbAttributes;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbBasic;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbCascadeType;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbCollectionTable;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbColumn;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbColumnResult;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbConstructorResult;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbConvert;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbDiscriminatorColumn;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbElementCollection;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddable;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbedded;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddedId;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEmptyType;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntity;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityListener;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityListeners;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityResult;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbFieldResult;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbGeneratedValue;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbId;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbIdClass;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbIndex;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbInheritance;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbJoinColumn;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbJoinTable;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbLob;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbManyToMany;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbManyToOne;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbMapKey;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbMapKeyClass;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbMapKeyColumn;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbMapKeyJoinColumn;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbMappedSuperclass;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedAttributeNode;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedEntityGraph;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedNativeQuery;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedQuery;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedStoredProcedureQuery;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbNamedSubgraph;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbOneToMany;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbOneToOne;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbOrderColumn;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPrimaryKeyJoinColumn;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbQueryHint;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbSecondaryTable;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbSequenceGenerator;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbSqlResultSetMapping;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbStoredProcedureParameter;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbTable;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbTableGenerator;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbTransient;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbUniqueConstraint;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbVersion;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.LifecycleCallbackContainer;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.ManagedType;
|
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
|
||||||
import org.hibernate.boot.spi.BootstrapContext;
|
|
||||||
import org.hibernate.boot.spi.ClassLoaderAccess;
|
|
||||||
import org.hibernate.cfg.annotations.reflection.PersistentAttributeFilter;
|
|
||||||
import org.hibernate.internal.CoreLogging;
|
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
|
||||||
import org.hibernate.internal.util.StringHelper;
|
|
||||||
|
|
||||||
import static org.hibernate.cfg.annotations.reflection.internal.PropertyMappingElementCollector.JAXB_TRANSIENT_NAME;
|
import static org.hibernate.cfg.annotations.reflection.internal.PropertyMappingElementCollector.JAXB_TRANSIENT_NAME;
|
||||||
import static org.hibernate.cfg.annotations.reflection.internal.PropertyMappingElementCollector.PERSISTENT_ATTRIBUTE_NAME;
|
import static org.hibernate.cfg.annotations.reflection.internal.PropertyMappingElementCollector.PERSISTENT_ATTRIBUTE_NAME;
|
||||||
|
|
||||||
|
@ -300,6 +304,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
annotationToXml.put( Convert.class, "convert" );
|
annotationToXml.put( Convert.class, "convert" );
|
||||||
annotationToXml.put( Converts.class, "convert" );
|
annotationToXml.put( Converts.class, "convert" );
|
||||||
annotationToXml.put( ConstructorResult.class, "constructor-result" );
|
annotationToXml.put( ConstructorResult.class, "constructor-result" );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final XMLContext xmlContext;
|
private final XMLContext xmlContext;
|
||||||
|
@ -412,7 +417,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
XMLContext.Default defaults = xmlContext.getDefaultWithoutGlobalCatalogAndSchema( className );
|
XMLContext.Default defaults = xmlContext.getDefaultWithoutGlobalCatalogAndSchema( className );
|
||||||
if ( className != null && propertyName == null ) {
|
if ( className != null && propertyName == null ) {
|
||||||
//is a class
|
//is a class
|
||||||
ManagedType managedTypeOverride = xmlContext.getManagedTypeOverride( className );
|
final ManagedType managedTypeOverride = xmlContext.getManagedTypeOverride( className );
|
||||||
Annotation[] annotations = getPhysicalAnnotations();
|
Annotation[] annotations = getPhysicalAnnotations();
|
||||||
List<Annotation> annotationList = new ArrayList<>( annotations.length + 5 );
|
List<Annotation> annotationList = new ArrayList<>( annotations.length + 5 );
|
||||||
annotationsMap = new HashMap<>( annotations.length + 5 );
|
annotationsMap = new HashMap<>( annotations.length + 5 );
|
||||||
|
@ -430,6 +435,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
addIfNotNull( annotationList, getPrimaryKeyJoinColumns( managedTypeOverride, defaults ) );
|
addIfNotNull( annotationList, getPrimaryKeyJoinColumns( managedTypeOverride, defaults ) );
|
||||||
addIfNotNull( annotationList, getIdClass( managedTypeOverride, defaults ) );
|
addIfNotNull( annotationList, getIdClass( managedTypeOverride, defaults ) );
|
||||||
addIfNotNull( annotationList, getCacheable( managedTypeOverride, defaults ) );
|
addIfNotNull( annotationList, getCacheable( managedTypeOverride, defaults ) );
|
||||||
|
addIfNotNull( annotationList, getCaching( managedTypeOverride, defaults ) );
|
||||||
addIfNotNull( annotationList, getInheritance( managedTypeOverride, defaults ) );
|
addIfNotNull( annotationList, getInheritance( managedTypeOverride, defaults ) );
|
||||||
addIfNotNull( annotationList, getDiscriminatorValue( managedTypeOverride, defaults ) );
|
addIfNotNull( annotationList, getDiscriminatorValue( managedTypeOverride, defaults ) );
|
||||||
addIfNotNull( annotationList, getDiscriminatorColumn( managedTypeOverride, defaults ) );
|
addIfNotNull( annotationList, getDiscriminatorColumn( managedTypeOverride, defaults ) );
|
||||||
|
@ -455,8 +461,8 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
checkForOrphanProperties( managedTypeOverride );
|
checkForOrphanProperties( managedTypeOverride );
|
||||||
}
|
}
|
||||||
else if ( className != null ) { //&& propertyName != null ) { //always true but less confusing
|
else if ( className != null ) { //&& propertyName != null ) { //always true but less confusing
|
||||||
ManagedType managedTypeOverride = xmlContext.getManagedTypeOverride( className );
|
final ManagedType managedTypeOverride = xmlContext.getManagedTypeOverride( className );
|
||||||
JaxbEntityListener entityListenerOverride = xmlContext.getEntityListenerOverride( className );
|
final JaxbEntityListener entityListenerOverride = xmlContext.getEntityListenerOverride( className );
|
||||||
Annotation[] annotations = getPhysicalAnnotations();
|
Annotation[] annotations = getPhysicalAnnotations();
|
||||||
List<Annotation> annotationList = new ArrayList<>( annotations.length + 5 );
|
List<Annotation> annotationList = new ArrayList<>( annotations.length + 5 );
|
||||||
annotationsMap = new HashMap<>( annotations.length + 5 );
|
annotationsMap = new HashMap<>( annotations.length + 5 );
|
||||||
|
@ -509,13 +515,17 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void remove(List<Annotation> annotationList, Class<? extends Annotation> annotationToRemove) {
|
||||||
|
annotationList.removeIf( next -> next.getClass().equals( annotationToRemove ) );
|
||||||
|
}
|
||||||
|
|
||||||
private Annotation getConvertsForAttribute(PropertyMappingElementCollector elementsForProperty, XMLContext.Default defaults) {
|
private Annotation getConvertsForAttribute(PropertyMappingElementCollector elementsForProperty, XMLContext.Default defaults) {
|
||||||
// NOTE : we use a map here to make sure that an xml and annotation referring to the same attribute
|
// NOTE : we use a map here to make sure that an xml and annotation referring to the same attribute
|
||||||
// properly overrides. Very sparse map, yes, but easy setup.
|
// properly overrides. Very sparse map, yes, but easy setup.
|
||||||
// todo : revisit this
|
// todo : revisit this
|
||||||
// although bear in mind that this code is no longer used in 5.0...
|
// although bear in mind that this code is no longer used in 5.0...
|
||||||
|
|
||||||
final Map<String,Convert> convertAnnotationsMap = new HashMap<>();
|
final Map<String, Convert> convertAnnotationsMap = new HashMap<>();
|
||||||
|
|
||||||
for ( JaxbBasic element : elementsForProperty.getBasic() ) {
|
for ( JaxbBasic element : elementsForProperty.getBasic() ) {
|
||||||
JaxbConvert convert = element.getConvert();
|
JaxbConvert convert = element.getConvert();
|
||||||
|
@ -551,7 +561,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
private Converts getConverts(ManagedType root, XMLContext.Default defaults) {
|
private Converts getConverts(ManagedType root, XMLContext.Default defaults) {
|
||||||
// NOTE : we use a map here to make sure that an xml and annotation referring to the same attribute
|
// NOTE : we use a map here to make sure that an xml and annotation referring to the same attribute
|
||||||
// properly overrides. Bit sparse, but easy...
|
// properly overrides. Bit sparse, but easy...
|
||||||
final Map<String,Convert> convertAnnotationsMap = new HashMap<>();
|
final Map<String, Convert> convertAnnotationsMap = new HashMap<>();
|
||||||
|
|
||||||
if ( root instanceof JaxbEntity ) {
|
if ( root instanceof JaxbEntity ) {
|
||||||
applyXmlDefinedConverts( ( (JaxbEntity) root ).getConvert(), defaults, null, convertAnnotationsMap );
|
applyXmlDefinedConverts( ( (JaxbEntity) root ).getConvert(), defaults, null, convertAnnotationsMap );
|
||||||
|
@ -577,7 +587,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
List<JaxbConvert> elements,
|
List<JaxbConvert> elements,
|
||||||
XMLContext.Default defaults,
|
XMLContext.Default defaults,
|
||||||
String attributeNamePrefix,
|
String attributeNamePrefix,
|
||||||
Map<String,Convert> convertAnnotationsMap) {
|
Map<String, Convert> convertAnnotationsMap) {
|
||||||
for ( JaxbConvert convertElement : elements ) {
|
for ( JaxbConvert convertElement : elements ) {
|
||||||
final AnnotationDescriptor convertAnnotationDescriptor = new AnnotationDescriptor( Convert.class );
|
final AnnotationDescriptor convertAnnotationDescriptor = new AnnotationDescriptor( Convert.class );
|
||||||
copyAttribute( convertAnnotationDescriptor, "attribute-name", convertElement.getAttributeName(), false );
|
copyAttribute( convertAnnotationDescriptor, "attribute-name", convertElement.getAttributeName(), false );
|
||||||
|
@ -678,14 +688,14 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
checkForOrphanProperties( jaxbAttributes.getEmbeddedId(), properties, PERSISTENT_ATTRIBUTE_NAME );
|
checkForOrphanProperties( jaxbAttributes.getEmbeddedId(), properties, PERSISTENT_ATTRIBUTE_NAME );
|
||||||
checkForOrphanProperties( jaxbAttributes.getVersion(), properties, PERSISTENT_ATTRIBUTE_NAME );
|
checkForOrphanProperties( jaxbAttributes.getVersion(), properties, PERSISTENT_ATTRIBUTE_NAME );
|
||||||
}
|
}
|
||||||
checkForOrphanProperties( container.getBasic(), properties, PERSISTENT_ATTRIBUTE_NAME );
|
checkForOrphanProperties( container.getBasicAttributes(), properties, PERSISTENT_ATTRIBUTE_NAME );
|
||||||
checkForOrphanProperties( container.getManyToOne(), properties, PERSISTENT_ATTRIBUTE_NAME );
|
checkForOrphanProperties( container.getManyToOneAttributes(), properties, PERSISTENT_ATTRIBUTE_NAME );
|
||||||
checkForOrphanProperties( container.getOneToMany(), properties, PERSISTENT_ATTRIBUTE_NAME );
|
checkForOrphanProperties( container.getOneToManyAttributes(), properties, PERSISTENT_ATTRIBUTE_NAME );
|
||||||
checkForOrphanProperties( container.getOneToOne(), properties, PERSISTENT_ATTRIBUTE_NAME );
|
checkForOrphanProperties( container.getOneToOneAttributes(), properties, PERSISTENT_ATTRIBUTE_NAME );
|
||||||
checkForOrphanProperties( container.getManyToMany(), properties, PERSISTENT_ATTRIBUTE_NAME );
|
checkForOrphanProperties( container.getManyToManyAttributes(), properties, PERSISTENT_ATTRIBUTE_NAME );
|
||||||
checkForOrphanProperties( container.getElementCollection(), properties, PERSISTENT_ATTRIBUTE_NAME );
|
checkForOrphanProperties( container.getElementCollectionAttributes(), properties, PERSISTENT_ATTRIBUTE_NAME );
|
||||||
checkForOrphanProperties( container.getEmbedded(), properties, PERSISTENT_ATTRIBUTE_NAME );
|
checkForOrphanProperties( container.getEmbeddedAttributes(), properties, PERSISTENT_ATTRIBUTE_NAME );
|
||||||
checkForOrphanProperties( container.getTransient(), properties, JAXB_TRANSIENT_NAME );
|
checkForOrphanProperties( container.getTransients(), properties, JAXB_TRANSIENT_NAME );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -811,7 +821,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
private EntityListeners getEntityListeners(ManagedType root, XMLContext.Default defaults) {
|
private EntityListeners getEntityListeners(ManagedType root, XMLContext.Default defaults) {
|
||||||
JaxbEntityListeners element = root instanceof EntityOrMappedSuperclass ? ( (EntityOrMappedSuperclass) root ).getEntityListeners() : null;
|
JaxbEntityListeners element = root instanceof EntityOrMappedSuperclass ? ( (EntityOrMappedSuperclass) root ).getEntityListeners() : null;
|
||||||
if ( element != null ) {
|
if ( element != null ) {
|
||||||
List<Class> entityListenerClasses = new ArrayList<>();
|
final List<Class<?>> entityListenerClasses = new ArrayList<>();
|
||||||
for ( JaxbEntityListener subelement : element.getEntityListener() ) {
|
for ( JaxbEntityListener subelement : element.getEntityListener() ) {
|
||||||
String className = subelement.getClazz();
|
String className = subelement.getClazz();
|
||||||
try {
|
try {
|
||||||
|
@ -821,14 +831,14 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch ( ClassLoadingException e ) {
|
catch (ClassLoadingException e) {
|
||||||
throw new AnnotationException(
|
throw new AnnotationException(
|
||||||
"Unable to find class: " + className, e
|
"Unable to find class: " + className, e
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AnnotationDescriptor ad = new AnnotationDescriptor( EntityListeners.class );
|
AnnotationDescriptor ad = new AnnotationDescriptor( EntityListeners.class );
|
||||||
ad.setValue( "value", entityListenerClasses.toArray( new Class[entityListenerClasses.size()] ) );
|
ad.setValue( "value", entityListenerClasses.toArray( new Class[0] ) );
|
||||||
return AnnotationFactory.create( ad );
|
return AnnotationFactory.create( ad );
|
||||||
}
|
}
|
||||||
else if ( defaults.canUseJavaAnnotations() ) {
|
else if ( defaults.canUseJavaAnnotations() ) {
|
||||||
|
@ -1215,7 +1225,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
joinColumns.add( AnnotationFactory.create( column ) );
|
joinColumns.add( AnnotationFactory.create( column ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return joinColumns.toArray( new MapKeyJoinColumn[joinColumns.size()] );
|
return joinColumns.toArray( new MapKeyJoinColumn[0] );
|
||||||
}
|
}
|
||||||
|
|
||||||
private AttributeOverrides getMapKeyAttributeOverrides(List<JaxbAttributeOverride> elements, XMLContext.Default defaults) {
|
private AttributeOverrides getMapKeyAttributeOverrides(List<JaxbAttributeOverride> elements, XMLContext.Default defaults) {
|
||||||
|
@ -1223,7 +1233,27 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
return mergeAttributeOverrides( defaults, attributes, false );
|
return mergeAttributeOverrides( defaults, attributes, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Cacheable getCacheable(ManagedType root, XMLContext.Default defaults){
|
private Cache getCaching(ManagedType root, XMLContext.Default defaults) {
|
||||||
|
if ( root instanceof JaxbEntity ) {
|
||||||
|
final JaxbCaching caching = ( (JaxbEntity) root ).getCaching();
|
||||||
|
if ( caching != null ) {
|
||||||
|
final AnnotationDescriptor ad = new AnnotationDescriptor( Cache.class );
|
||||||
|
ad.setValue( "usage", CacheConcurrencyStrategy.fromAccessType( caching.getAccess() ) );
|
||||||
|
ad.setValue( "region", caching.getRegion() );
|
||||||
|
ad.setValue( "include", caching.getInclude().value() );
|
||||||
|
return AnnotationFactory.create( ad );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( defaults.canUseJavaAnnotations() ) {
|
||||||
|
return getPhysicalAnnotation( Cache.class );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Cacheable getCacheable(ManagedType root, XMLContext.Default defaults) {
|
||||||
if ( root instanceof JaxbEntity ) {
|
if ( root instanceof JaxbEntity ) {
|
||||||
Boolean attValue = ( (JaxbEntity) root ).isCacheable();
|
Boolean attValue = ( (JaxbEntity) root ).isCacheable();
|
||||||
if ( attValue != null ) {
|
if ( attValue != null ) {
|
||||||
|
@ -1730,14 +1760,9 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
}
|
}
|
||||||
List<Column> columns = new ArrayList<>( 1 );
|
List<Column> columns = new ArrayList<>( 1 );
|
||||||
columns.add( getColumn( element, false, nodeName ) );
|
columns.add( getColumn( element, false, nodeName ) );
|
||||||
if ( columns.size() > 0 ) {
|
AnnotationDescriptor columnsDescr = new AnnotationDescriptor( Columns.class );
|
||||||
AnnotationDescriptor columnsDescr = new AnnotationDescriptor( Columns.class );
|
columnsDescr.setValue( "columns", columns.toArray( new Column[ columns.size() ] ) );
|
||||||
columnsDescr.setValue( "columns", columns.toArray( new Column[columns.size()] ) );
|
return AnnotationFactory.create( columnsDescr );
|
||||||
return AnnotationFactory.create( columnsDescr );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Columns buildColumns(List<JaxbColumn> elements, String nodeName) {
|
private Columns buildColumns(List<JaxbColumn> elements, String nodeName) {
|
||||||
|
@ -1747,7 +1772,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
}
|
}
|
||||||
if ( columns.size() > 0 ) {
|
if ( columns.size() > 0 ) {
|
||||||
AnnotationDescriptor columnsDescr = new AnnotationDescriptor( Columns.class );
|
AnnotationDescriptor columnsDescr = new AnnotationDescriptor( Columns.class );
|
||||||
columnsDescr.setValue( "columns", columns.toArray( new Column[columns.size()] ) );
|
columnsDescr.setValue( "columns", columns.toArray( new Column[ columns.size() ] ) );
|
||||||
return AnnotationFactory.create( columnsDescr );
|
return AnnotationFactory.create( columnsDescr );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1804,11 +1829,11 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mergeWithAnnotations Whether to use Java annotations for this
|
* @param mergeWithAnnotations Whether to use Java annotations for this
|
||||||
* element, if present and not disabled by the XMLContext defaults.
|
* element, if present and not disabled by the XMLContext defaults.
|
||||||
* In some contexts (such as an element-collection mapping) merging
|
* In some contexts (such as an element-collection mapping) merging
|
||||||
*/
|
*/
|
||||||
private AssociationOverrides getAssociationOverrides(List<JaxbAssociationOverride> elements, XMLContext.Default defaults,
|
private AssociationOverrides getAssociationOverrides(List<JaxbAssociationOverride> elements, XMLContext.Default defaults,
|
||||||
boolean mergeWithAnnotations) {
|
boolean mergeWithAnnotations) {
|
||||||
List<AssociationOverride> attributes = buildAssociationOverrides( elements, defaults );
|
List<AssociationOverride> attributes = buildAssociationOverrides( elements, defaults );
|
||||||
if ( mergeWithAnnotations && defaults.canUseJavaAnnotations() ) {
|
if ( mergeWithAnnotations && defaults.canUseJavaAnnotations() ) {
|
||||||
AssociationOverride annotation = getPhysicalAnnotation( AssociationOverride.class );
|
AssociationOverride annotation = getPhysicalAnnotation( AssociationOverride.class );
|
||||||
|
@ -1891,12 +1916,12 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mergeWithAnnotations Whether to use Java annotations for this
|
* @param mergeWithAnnotations Whether to use Java annotations for this
|
||||||
* element, if present and not disabled by the XMLContext defaults.
|
* element, if present and not disabled by the XMLContext defaults.
|
||||||
* In some contexts (such as an association mapping) merging with
|
* In some contexts (such as an association mapping) merging with
|
||||||
* annotations is never allowed.
|
* annotations is never allowed.
|
||||||
*/
|
*/
|
||||||
private AttributeOverrides getAttributeOverrides(List<JaxbAttributeOverride> elements, XMLContext.Default defaults,
|
private AttributeOverrides getAttributeOverrides(List<JaxbAttributeOverride> elements, XMLContext.Default defaults,
|
||||||
boolean mergeWithAnnotations) {
|
boolean mergeWithAnnotations) {
|
||||||
List<AttributeOverride> attributes = buildAttributeOverrides( elements, "attribute-override" );
|
List<AttributeOverride> attributes = buildAttributeOverrides( elements, "attribute-override" );
|
||||||
return mergeAttributeOverrides( defaults, attributes, mergeWithAnnotations );
|
return mergeAttributeOverrides( defaults, attributes, mergeWithAnnotations );
|
||||||
}
|
}
|
||||||
|
@ -2002,23 +2027,27 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExcludeSuperclassListeners getExcludeSuperclassListeners(ManagedType root, XMLContext.Default defaults) {
|
private ExcludeSuperclassListeners getExcludeSuperclassListeners(ManagedType root, XMLContext.Default defaults) {
|
||||||
return (ExcludeSuperclassListeners) getMarkerAnnotation( ExcludeSuperclassListeners.class,
|
return (ExcludeSuperclassListeners) getMarkerAnnotation(
|
||||||
|
ExcludeSuperclassListeners.class,
|
||||||
root instanceof EntityOrMappedSuperclass
|
root instanceof EntityOrMappedSuperclass
|
||||||
? ( (EntityOrMappedSuperclass) root ).getExcludeSuperclassListeners()
|
? ( (EntityOrMappedSuperclass) root ).getExcludeSuperclassListeners()
|
||||||
: null,
|
: null,
|
||||||
defaults );
|
defaults
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExcludeDefaultListeners getExcludeDefaultListeners(ManagedType root, XMLContext.Default defaults) {
|
private ExcludeDefaultListeners getExcludeDefaultListeners(ManagedType root, XMLContext.Default defaults) {
|
||||||
return (ExcludeDefaultListeners) getMarkerAnnotation( ExcludeDefaultListeners.class,
|
return (ExcludeDefaultListeners) getMarkerAnnotation(
|
||||||
|
ExcludeDefaultListeners.class,
|
||||||
root instanceof EntityOrMappedSuperclass
|
root instanceof EntityOrMappedSuperclass
|
||||||
? ( (EntityOrMappedSuperclass) root ).getExcludeDefaultListeners()
|
? ( (EntityOrMappedSuperclass) root ).getExcludeDefaultListeners()
|
||||||
: null,
|
: null,
|
||||||
defaults );
|
defaults
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Annotation getMarkerAnnotation(Class<? extends Annotation> clazz, JaxbEmptyType element,
|
private Annotation getMarkerAnnotation(Class<? extends Annotation> clazz, JaxbEmptyType element,
|
||||||
XMLContext.Default defaults) {
|
XMLContext.Default defaults) {
|
||||||
if ( element != null ) {
|
if ( element != null ) {
|
||||||
return AnnotationFactory.create( new AnnotationDescriptor( clazz ) );
|
return AnnotationFactory.create( new AnnotationDescriptor( clazz ) );
|
||||||
}
|
}
|
||||||
|
@ -2033,7 +2062,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
|
|
||||||
private SqlResultSetMappings getSqlResultSetMappings(ManagedType root, XMLContext.Default defaults) {
|
private SqlResultSetMappings getSqlResultSetMappings(ManagedType root, XMLContext.Default defaults) {
|
||||||
List<SqlResultSetMapping> results = root instanceof JaxbEntity
|
List<SqlResultSetMapping> results = root instanceof JaxbEntity
|
||||||
? buildSqlResultsetMappings( ( (JaxbEntity) root ).getSqlResultSetMapping(), defaults, classLoaderAccess )
|
? buildSqlResultSetMappings( ( (JaxbEntity) root ).getSqlResultSetMapping(), defaults, classLoaderAccess )
|
||||||
: new ArrayList<>();
|
: new ArrayList<>();
|
||||||
if ( defaults.canUseJavaAnnotations() ) {
|
if ( defaults.canUseJavaAnnotations() ) {
|
||||||
SqlResultSetMapping annotation = getPhysicalAnnotation( SqlResultSetMapping.class );
|
SqlResultSetMapping annotation = getPhysicalAnnotation( SqlResultSetMapping.class );
|
||||||
|
@ -2080,8 +2109,8 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
String annotationAttributeName,
|
String annotationAttributeName,
|
||||||
List<JaxbNamedSubgraph> subgraphNodes,
|
List<JaxbNamedSubgraph> subgraphNodes,
|
||||||
ClassLoaderAccess classLoaderAccess) {
|
ClassLoaderAccess classLoaderAccess) {
|
||||||
List<NamedSubgraph> annSubgraphNodes = new ArrayList<>( );
|
List<NamedSubgraph> annSubgraphNodes = new ArrayList<>();
|
||||||
for(JaxbNamedSubgraph subgraphNode : subgraphNodes){
|
for ( JaxbNamedSubgraph subgraphNode : subgraphNodes ) {
|
||||||
AnnotationDescriptor annSubgraphNode = new AnnotationDescriptor( NamedSubgraph.class );
|
AnnotationDescriptor annSubgraphNode = new AnnotationDescriptor( NamedSubgraph.class );
|
||||||
copyAttribute( annSubgraphNode, "name", subgraphNode.getName(), true );
|
copyAttribute( annSubgraphNode, "name", subgraphNode.getName(), true );
|
||||||
String clazzName = subgraphNode.getClazz();
|
String clazzName = subgraphNode.getClazz();
|
||||||
|
@ -2099,19 +2128,19 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
annSubgraphNodes.add( AnnotationFactory.create( annSubgraphNode ) );
|
annSubgraphNodes.add( AnnotationFactory.create( annSubgraphNode ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
ann.setValue( annotationAttributeName, annSubgraphNodes.toArray( new NamedSubgraph[annSubgraphNodes.size()] ) );
|
ann.setValue( annotationAttributeName, annSubgraphNodes.toArray( new NamedSubgraph[ annSubgraphNodes.size() ] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void bindNamedAttributeNodes(List<JaxbNamedAttributeNode> elements, AnnotationDescriptor ann) {
|
private static void bindNamedAttributeNodes(List<JaxbNamedAttributeNode> elements, AnnotationDescriptor ann) {
|
||||||
List<NamedAttributeNode> annNamedAttributeNodes = new ArrayList<>( );
|
List<NamedAttributeNode> annNamedAttributeNodes = new ArrayList<>();
|
||||||
for( JaxbNamedAttributeNode element : elements){
|
for ( JaxbNamedAttributeNode element : elements ) {
|
||||||
AnnotationDescriptor annNamedAttributeNode = new AnnotationDescriptor( NamedAttributeNode.class );
|
AnnotationDescriptor annNamedAttributeNode = new AnnotationDescriptor( NamedAttributeNode.class );
|
||||||
copyAttribute( annNamedAttributeNode, "value", "name", element.getName(),true );
|
copyAttribute( annNamedAttributeNode, "value", "name", element.getName(), true );
|
||||||
copyAttribute( annNamedAttributeNode, "subgraph", element.getSubgraph(), false );
|
copyAttribute( annNamedAttributeNode, "subgraph", element.getSubgraph(), false );
|
||||||
copyAttribute( annNamedAttributeNode, "key-subgraph", element.getKeySubgraph(), false );
|
copyAttribute( annNamedAttributeNode, "key-subgraph", element.getKeySubgraph(), false );
|
||||||
annNamedAttributeNodes.add( AnnotationFactory.create( annNamedAttributeNode ) );
|
annNamedAttributeNodes.add( AnnotationFactory.create( annNamedAttributeNode ) );
|
||||||
}
|
}
|
||||||
ann.setValue( "attributeNodes", annNamedAttributeNodes.toArray( new NamedAttributeNode[annNamedAttributeNodes.size()] ) );
|
ann.setValue( "attributeNodes", annNamedAttributeNodes.toArray( new NamedAttributeNode[0] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<NamedStoredProcedureQuery> buildNamedStoreProcedureQueries(
|
public static List<NamedStoredProcedureQuery> buildNamedStoreProcedureQueries(
|
||||||
|
@ -2152,7 +2181,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
|
|
||||||
ann.setValue(
|
ann.setValue(
|
||||||
"parameters",
|
"parameters",
|
||||||
storedProcedureParameters.toArray( new StoredProcedureParameter[storedProcedureParameters.size()] )
|
storedProcedureParameters.toArray( new StoredProcedureParameter[0] )
|
||||||
);
|
);
|
||||||
|
|
||||||
List<Class<?>> returnClasses = new ArrayList<>();
|
List<Class<?>> returnClasses = new ArrayList<>();
|
||||||
|
@ -2168,7 +2197,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
}
|
}
|
||||||
returnClasses.add( clazz );
|
returnClasses.add( clazz );
|
||||||
}
|
}
|
||||||
ann.setValue( "resultClasses", returnClasses.toArray( new Class[returnClasses.size()] ) );
|
ann.setValue( "resultClasses", returnClasses.toArray( new Class[0] ) );
|
||||||
|
|
||||||
|
|
||||||
ann.setValue( "resultSetMappings", element.getResultSetMapping().toArray( new String[0] ) );
|
ann.setValue( "resultSetMappings", element.getResultSetMapping().toArray( new String[0] ) );
|
||||||
|
@ -2179,7 +2208,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<SqlResultSetMapping> buildSqlResultsetMappings(
|
public static List<SqlResultSetMapping> buildSqlResultSetMappings(
|
||||||
List<JaxbSqlResultSetMapping> elements,
|
List<JaxbSqlResultSetMapping> elements,
|
||||||
XMLContext.Default defaults,
|
XMLContext.Default defaults,
|
||||||
ClassLoaderAccess classLoaderAccess) {
|
ClassLoaderAccess classLoaderAccess) {
|
||||||
|
@ -2501,7 +2530,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void buildQueryHints(List<JaxbQueryHint> elements, AnnotationDescriptor ann){
|
private static void buildQueryHints(List<JaxbQueryHint> elements, AnnotationDescriptor ann) {
|
||||||
List<QueryHint> queryHints = new ArrayList<>( elements.size() );
|
List<QueryHint> queryHints = new ArrayList<>( elements.size() );
|
||||||
for ( JaxbQueryHint hint : elements ) {
|
for ( JaxbQueryHint hint : elements ) {
|
||||||
AnnotationDescriptor hintDescriptor = new AnnotationDescriptor( QueryHint.class );
|
AnnotationDescriptor hintDescriptor = new AnnotationDescriptor( QueryHint.class );
|
||||||
|
@ -2566,7 +2595,10 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private TableGenerator getTableGenerator(ManagedType root, XMLContext.Default defaults) {
|
private TableGenerator getTableGenerator(ManagedType root, XMLContext.Default defaults) {
|
||||||
return getTableGenerator( root instanceof JaxbEntity ? ( (JaxbEntity) root ).getTableGenerator() : null, defaults );
|
return getTableGenerator(
|
||||||
|
root instanceof JaxbEntity ? ( (JaxbEntity) root ).getTableGenerator() : null,
|
||||||
|
defaults
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TableGenerator getTableGenerator(JaxbTableGenerator element, XMLContext.Default defaults) {
|
private TableGenerator getTableGenerator(JaxbTableGenerator element, XMLContext.Default defaults) {
|
||||||
|
@ -2631,8 +2663,10 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SequenceGenerator getSequenceGenerator(ManagedType root, XMLContext.Default defaults) {
|
private SequenceGenerator getSequenceGenerator(ManagedType root, XMLContext.Default defaults) {
|
||||||
return getSequenceGenerator( root instanceof JaxbEntity ? ( (JaxbEntity) root ).getSequenceGenerator() : null,
|
return getSequenceGenerator(
|
||||||
defaults );
|
root instanceof JaxbEntity ? ( (JaxbEntity) root ).getSequenceGenerator() : null,
|
||||||
|
defaults
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SequenceGenerator getSequenceGenerator(JaxbSequenceGenerator element, XMLContext.Default defaults) {
|
private SequenceGenerator getSequenceGenerator(JaxbSequenceGenerator element, XMLContext.Default defaults) {
|
||||||
|
@ -2716,8 +2750,9 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private IdClass getIdClass(ManagedType root, XMLContext.Default defaults) {
|
private IdClass getIdClass(ManagedType root, XMLContext.Default defaults) {
|
||||||
JaxbIdClass element = root instanceof EntityOrMappedSuperclass ?
|
final JaxbIdClass element = root instanceof EntityOrMappedSuperclass
|
||||||
( (EntityOrMappedSuperclass) root ).getIdClass() : null;
|
? ( (EntityOrMappedSuperclass) root ).getIdClass()
|
||||||
|
: null;
|
||||||
if ( element != null ) {
|
if ( element != null ) {
|
||||||
String className = element.getClazz();
|
String className = element.getClazz();
|
||||||
if ( className != null ) {
|
if ( className != null ) {
|
||||||
|
@ -2756,8 +2791,10 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
* element, if present and not disabled by the XMLContext defaults.
|
* element, if present and not disabled by the XMLContext defaults.
|
||||||
* In some contexts (such as an association mapping) merging with
|
* In some contexts (such as an association mapping) merging with
|
||||||
*/
|
*/
|
||||||
private PrimaryKeyJoinColumns getPrimaryKeyJoinColumns(List<JaxbPrimaryKeyJoinColumn> elements,
|
private PrimaryKeyJoinColumns getPrimaryKeyJoinColumns(
|
||||||
XMLContext.Default defaults, boolean mergeWithAnnotations) {
|
List<JaxbPrimaryKeyJoinColumn> elements,
|
||||||
|
XMLContext.Default defaults,
|
||||||
|
boolean mergeWithAnnotations) {
|
||||||
PrimaryKeyJoinColumn[] columns = buildPrimaryKeyJoinColumns( elements );
|
PrimaryKeyJoinColumn[] columns = buildPrimaryKeyJoinColumns( elements );
|
||||||
if ( mergeWithAnnotations ) {
|
if ( mergeWithAnnotations ) {
|
||||||
if ( columns.length == 0 && defaults.canUseJavaAnnotations() ) {
|
if ( columns.length == 0 && defaults.canUseJavaAnnotations() ) {
|
||||||
|
@ -2835,8 +2872,19 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Subselect getTableExpression(JaxbEntity entity, XMLContext.Default defaults) {
|
||||||
|
final String tableExpression = entity.getTableExpression();
|
||||||
|
if ( StringHelper.isEmpty( tableExpression ) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final AnnotationDescriptor annotation = new AnnotationDescriptor( Subselect.class );
|
||||||
|
annotation.setValue( "value", tableExpression );
|
||||||
|
return AnnotationFactory.create( annotation );
|
||||||
|
}
|
||||||
|
|
||||||
private Table getTable(ManagedType root, XMLContext.Default defaults) {
|
private Table getTable(ManagedType root, XMLContext.Default defaults) {
|
||||||
JaxbTable element = root instanceof JaxbEntity ? ( (JaxbEntity) root ).getTable() : null;
|
final JaxbTable element = root instanceof JaxbEntity ? ( (JaxbEntity) root ).getTable() : null;
|
||||||
if ( element == null ) {
|
if ( element == null ) {
|
||||||
//no element but might have some default or some annotation
|
//no element but might have some default or some annotation
|
||||||
if ( StringHelper.isNotEmpty( defaults.getCatalog() )
|
if ( StringHelper.isNotEmpty( defaults.getCatalog() )
|
||||||
|
@ -2890,9 +2938,10 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SecondaryTables getSecondaryTables(ManagedType root, XMLContext.Default defaults) {
|
private SecondaryTables getSecondaryTables(ManagedType root, XMLContext.Default defaults) {
|
||||||
List<JaxbSecondaryTable> elements = root instanceof JaxbEntity ?
|
final List<JaxbSecondaryTable> elements = root instanceof JaxbEntity
|
||||||
( (JaxbEntity) root ).getSecondaryTable() : Collections.emptyList();
|
? ( (JaxbEntity) root ).getSecondaryTable()
|
||||||
List<SecondaryTable> secondaryTables = new ArrayList<>( 3 );
|
: Collections.emptyList();
|
||||||
|
final List<SecondaryTable> secondaryTables = new ArrayList<>( 3 );
|
||||||
for ( JaxbSecondaryTable element : elements ) {
|
for ( JaxbSecondaryTable element : elements ) {
|
||||||
AnnotationDescriptor annotation = new AnnotationDescriptor( SecondaryTable.class );
|
AnnotationDescriptor annotation = new AnnotationDescriptor( SecondaryTable.class );
|
||||||
copyAttribute( annotation, "name", element.getName(), false );
|
copyAttribute( annotation, "name", element.getName(), false );
|
||||||
|
@ -2964,42 +3013,43 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void buildIndex(AnnotationDescriptor annotation, List<JaxbIndex> elements) {
|
private static void buildIndex(AnnotationDescriptor annotation, List<JaxbIndex> elements) {
|
||||||
Index[] indexes = new Index[elements.size()];
|
Index[] indexes = new Index[ elements.size() ];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for ( JaxbIndex element : elements ) {
|
for ( JaxbIndex element : elements ) {
|
||||||
AnnotationDescriptor indexAnn = new AnnotationDescriptor( Index.class );
|
AnnotationDescriptor indexAnn = new AnnotationDescriptor( Index.class );
|
||||||
copyAttribute( indexAnn, "name", element.getName(), false );
|
copyAttribute( indexAnn, "name", element.getName(), false );
|
||||||
copyAttribute( indexAnn, "column-list", element.getColumnList(), true );
|
copyAttribute( indexAnn, "column-list", element.getColumnList(), true );
|
||||||
copyAttribute( indexAnn, "unique", element.isUnique(), false );
|
copyAttribute( indexAnn, "unique", element.isUnique(), false );
|
||||||
indexes[i++] = AnnotationFactory.create( indexAnn );
|
indexes[ i++ ] = AnnotationFactory.create( indexAnn );
|
||||||
}
|
}
|
||||||
annotation.setValue( "indexes", indexes );
|
annotation.setValue( "indexes", indexes );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void buildUniqueConstraints(AnnotationDescriptor annotation,
|
private static void buildUniqueConstraints(AnnotationDescriptor annotation,
|
||||||
List<JaxbUniqueConstraint> elements) {
|
List<JaxbUniqueConstraint> elements) {
|
||||||
UniqueConstraint[] uniqueConstraints = new UniqueConstraint[elements.size()];
|
UniqueConstraint[] uniqueConstraints = new UniqueConstraint[ elements.size() ];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for ( JaxbUniqueConstraint element : elements ) {
|
for ( JaxbUniqueConstraint element : elements ) {
|
||||||
String[] columnNames = element.getColumnName().toArray( new String[0] );
|
String[] columnNames = element.getColumnName().toArray( new String[ 0 ] );
|
||||||
AnnotationDescriptor ucAnn = new AnnotationDescriptor( UniqueConstraint.class );
|
AnnotationDescriptor ucAnn = new AnnotationDescriptor( UniqueConstraint.class );
|
||||||
copyAttribute( ucAnn, "name", element.getName(), false );
|
copyAttribute( ucAnn, "name", element.getName(), false );
|
||||||
ucAnn.setValue( "columnNames", columnNames );
|
ucAnn.setValue( "columnNames", columnNames );
|
||||||
uniqueConstraints[i++] = AnnotationFactory.create( ucAnn );
|
uniqueConstraints[ i++ ] = AnnotationFactory.create( ucAnn );
|
||||||
}
|
}
|
||||||
annotation.setValue( "uniqueConstraints", uniqueConstraints );
|
annotation.setValue( "uniqueConstraints", uniqueConstraints );
|
||||||
}
|
}
|
||||||
|
|
||||||
private PrimaryKeyJoinColumn[] buildPrimaryKeyJoinColumns(List<JaxbPrimaryKeyJoinColumn> elements) {
|
private PrimaryKeyJoinColumn[] buildPrimaryKeyJoinColumns(List<JaxbPrimaryKeyJoinColumn> elements) {
|
||||||
PrimaryKeyJoinColumn[] pkJoinColumns = new PrimaryKeyJoinColumn[elements.size()];
|
PrimaryKeyJoinColumn[] pkJoinColumns = new PrimaryKeyJoinColumn[ elements.size() ];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for ( JaxbPrimaryKeyJoinColumn element : elements ) {
|
for ( JaxbPrimaryKeyJoinColumn element : elements ) {
|
||||||
AnnotationDescriptor pkAnn = new AnnotationDescriptor( PrimaryKeyJoinColumn.class );
|
AnnotationDescriptor pkAnn = new AnnotationDescriptor( PrimaryKeyJoinColumn.class );
|
||||||
copyAttribute( pkAnn, "name", element.getName(), false );
|
copyAttribute( pkAnn, "name", element.getName(), false );
|
||||||
copyAttribute( pkAnn, "referenced-column-name", element.getReferencedColumnName(), false );
|
copyAttribute( pkAnn, "referenced-column-name", element.getReferencedColumnName(), false );
|
||||||
copyAttribute( pkAnn, "column-definition", element.getColumnDefinition(), false );
|
copyAttribute( pkAnn, "column-definition", element.getColumnDefinition(), false );
|
||||||
pkJoinColumns[i++] = AnnotationFactory.create( pkAnn );
|
pkJoinColumns[ i++ ] = AnnotationFactory.create( pkAnn );
|
||||||
}
|
}
|
||||||
return pkJoinColumns;
|
return pkJoinColumns;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.cfg.annotations.reflection.internal;
|
package org.hibernate.cfg.annotations.reflection.internal;
|
||||||
|
|
||||||
|
@ -12,6 +12,17 @@ import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.common.reflection.AnnotationReader;
|
||||||
|
import org.hibernate.annotations.common.reflection.MetadataProvider;
|
||||||
|
import org.hibernate.annotations.common.reflection.java.JavaMetadataProvider;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbSequenceGenerator;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbTableGenerator;
|
||||||
|
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||||
|
import org.hibernate.boot.spi.BootstrapContext;
|
||||||
|
import org.hibernate.boot.spi.ClassLoaderAccess;
|
||||||
|
|
||||||
import jakarta.persistence.EntityListeners;
|
import jakarta.persistence.EntityListeners;
|
||||||
import jakarta.persistence.NamedNativeQuery;
|
import jakarta.persistence.NamedNativeQuery;
|
||||||
import jakarta.persistence.NamedQuery;
|
import jakarta.persistence.NamedQuery;
|
||||||
|
@ -20,16 +31,6 @@ import jakarta.persistence.SequenceGenerator;
|
||||||
import jakarta.persistence.SqlResultSetMapping;
|
import jakarta.persistence.SqlResultSetMapping;
|
||||||
import jakarta.persistence.TableGenerator;
|
import jakarta.persistence.TableGenerator;
|
||||||
|
|
||||||
import org.hibernate.annotations.common.reflection.AnnotationReader;
|
|
||||||
import org.hibernate.annotations.common.reflection.MetadataProvider;
|
|
||||||
import org.hibernate.annotations.common.reflection.java.JavaMetadataProvider;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappings;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbSequenceGenerator;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbTableGenerator;
|
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
|
||||||
import org.hibernate.boot.spi.BootstrapContext;
|
|
||||||
import org.hibernate.boot.spi.ClassLoaderAccess;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MetadataProvider aware of the JPA Deployment descriptor (orm.xml, ...).
|
* MetadataProvider aware of the JPA Deployment descriptor (orm.xml, ...).
|
||||||
*
|
*
|
||||||
|
@ -105,14 +106,14 @@ public final class JPAXMLOverriddenMetadataProvider implements MetadataProvider
|
||||||
try {
|
try {
|
||||||
entityListeners.add( classLoaderAccess.classForName( className ) );
|
entityListeners.add( classLoaderAccess.classForName( className ) );
|
||||||
}
|
}
|
||||||
catch ( ClassLoadingException e ) {
|
catch (ClassLoadingException e) {
|
||||||
throw new IllegalStateException( "Default entity listener class not found: " + className );
|
throw new IllegalStateException( "Default entity listener class not found: " + className );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defaults.put( EntityListeners.class, entityListeners );
|
defaults.put( EntityListeners.class, entityListeners );
|
||||||
for ( JaxbEntityMappings entityMappings : xmlContext.getAllDocuments() ) {
|
for ( JaxbEntityMappings entityMappings : xmlContext.getAllDocuments() ) {
|
||||||
List<JaxbSequenceGenerator> jaxbSequenceGenerators = entityMappings.getSequenceGenerator();
|
List<JaxbSequenceGenerator> jaxbSequenceGenerators = entityMappings.getSequenceGenerator();
|
||||||
List<SequenceGenerator> sequenceGenerators = ( List<SequenceGenerator> ) defaults.get( SequenceGenerator.class );
|
List<SequenceGenerator> sequenceGenerators = (List<SequenceGenerator>) defaults.get( SequenceGenerator.class );
|
||||||
if ( sequenceGenerators == null ) {
|
if ( sequenceGenerators == null ) {
|
||||||
sequenceGenerators = new ArrayList<>();
|
sequenceGenerators = new ArrayList<>();
|
||||||
defaults.put( SequenceGenerator.class, sequenceGenerators );
|
defaults.put( SequenceGenerator.class, sequenceGenerators );
|
||||||
|
@ -122,7 +123,7 @@ public final class JPAXMLOverriddenMetadataProvider implements MetadataProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
List<JaxbTableGenerator> jaxbTableGenerators = entityMappings.getTableGenerator();
|
List<JaxbTableGenerator> jaxbTableGenerators = entityMappings.getTableGenerator();
|
||||||
List<TableGenerator> tableGenerators = ( List<TableGenerator> ) defaults.get( TableGenerator.class );
|
List<TableGenerator> tableGenerators = (List<TableGenerator>) defaults.get( TableGenerator.class );
|
||||||
if ( tableGenerators == null ) {
|
if ( tableGenerators == null ) {
|
||||||
tableGenerators = new ArrayList<>();
|
tableGenerators = new ArrayList<>();
|
||||||
defaults.put( TableGenerator.class, tableGenerators );
|
defaults.put( TableGenerator.class, tableGenerators );
|
||||||
|
@ -130,7 +131,8 @@ public final class JPAXMLOverriddenMetadataProvider implements MetadataProvider
|
||||||
for ( JaxbTableGenerator element : jaxbTableGenerators ) {
|
for ( JaxbTableGenerator element : jaxbTableGenerators ) {
|
||||||
tableGenerators.add(
|
tableGenerators.add(
|
||||||
JPAXMLOverriddenAnnotationReader.buildTableGeneratorAnnotation(
|
JPAXMLOverriddenAnnotationReader.buildTableGeneratorAnnotation(
|
||||||
element, xmlDefaults
|
element,
|
||||||
|
xmlDefaults
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -141,7 +143,7 @@ public final class JPAXMLOverriddenMetadataProvider implements MetadataProvider
|
||||||
defaults.put( NamedQuery.class, namedQueries );
|
defaults.put( NamedQuery.class, namedQueries );
|
||||||
}
|
}
|
||||||
List<NamedQuery> currentNamedQueries = JPAXMLOverriddenAnnotationReader.buildNamedQueries(
|
List<NamedQuery> currentNamedQueries = JPAXMLOverriddenAnnotationReader.buildNamedQueries(
|
||||||
entityMappings.getNamedQuery(),
|
entityMappings.getNamedQueries(),
|
||||||
xmlDefaults,
|
xmlDefaults,
|
||||||
classLoaderAccess
|
classLoaderAccess
|
||||||
);
|
);
|
||||||
|
@ -153,7 +155,7 @@ public final class JPAXMLOverriddenMetadataProvider implements MetadataProvider
|
||||||
defaults.put( NamedNativeQuery.class, namedNativeQueries );
|
defaults.put( NamedNativeQuery.class, namedNativeQueries );
|
||||||
}
|
}
|
||||||
List<NamedNativeQuery> currentNamedNativeQueries = JPAXMLOverriddenAnnotationReader.buildNamedNativeQueries(
|
List<NamedNativeQuery> currentNamedNativeQueries = JPAXMLOverriddenAnnotationReader.buildNamedNativeQueries(
|
||||||
entityMappings.getNamedNativeQuery(),
|
entityMappings.getNamedNativeQueries(),
|
||||||
xmlDefaults,
|
xmlDefaults,
|
||||||
classLoaderAccess
|
classLoaderAccess
|
||||||
);
|
);
|
||||||
|
@ -166,8 +168,8 @@ public final class JPAXMLOverriddenMetadataProvider implements MetadataProvider
|
||||||
sqlResultSetMappings = new ArrayList<>();
|
sqlResultSetMappings = new ArrayList<>();
|
||||||
defaults.put( SqlResultSetMapping.class, sqlResultSetMappings );
|
defaults.put( SqlResultSetMapping.class, sqlResultSetMappings );
|
||||||
}
|
}
|
||||||
List<SqlResultSetMapping> currentSqlResultSetMappings = JPAXMLOverriddenAnnotationReader.buildSqlResultsetMappings(
|
List<SqlResultSetMapping> currentSqlResultSetMappings = JPAXMLOverriddenAnnotationReader.buildSqlResultSetMappings(
|
||||||
entityMappings.getSqlResultSetMapping(),
|
entityMappings.getSqlResultSetMappings(),
|
||||||
xmlDefaults,
|
xmlDefaults,
|
||||||
classLoaderAccess
|
classLoaderAccess
|
||||||
);
|
);
|
||||||
|
@ -180,7 +182,7 @@ public final class JPAXMLOverriddenMetadataProvider implements MetadataProvider
|
||||||
}
|
}
|
||||||
List<NamedStoredProcedureQuery> currentNamedStoredProcedureQueries = JPAXMLOverriddenAnnotationReader
|
List<NamedStoredProcedureQuery> currentNamedStoredProcedureQueries = JPAXMLOverriddenAnnotationReader
|
||||||
.buildNamedStoreProcedureQueries(
|
.buildNamedStoreProcedureQueries(
|
||||||
entityMappings.getNamedStoredProcedureQuery(),
|
entityMappings.getNamedProcedureQueries(),
|
||||||
xmlDefaults,
|
xmlDefaults,
|
||||||
classLoaderAccess
|
classLoaderAccess
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
* 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
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.cfg.annotations.reflection.internal;
|
package org.hibernate.cfg.annotations.reflection.internal;
|
||||||
|
|
||||||
|
@ -11,29 +11,30 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.AttributesContainer;
|
import org.hibernate.boot.jaxb.mapping.AttributesContainer;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbAttributes;
|
import org.hibernate.boot.jaxb.mapping.JaxbAttributes;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbBasic;
|
import org.hibernate.boot.jaxb.mapping.JaxbBasic;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbElementCollection;
|
import org.hibernate.boot.jaxb.mapping.JaxbElementCollection;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbedded;
|
import org.hibernate.boot.jaxb.mapping.JaxbEmbedded;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddedId;
|
import org.hibernate.boot.jaxb.mapping.JaxbEmbeddedId;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbId;
|
import org.hibernate.boot.jaxb.mapping.JaxbId;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbManyToMany;
|
import org.hibernate.boot.jaxb.mapping.JaxbManyToMany;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbManyToOne;
|
import org.hibernate.boot.jaxb.mapping.JaxbManyToOne;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbOneToMany;
|
import org.hibernate.boot.jaxb.mapping.JaxbOneToMany;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbOneToOne;
|
import org.hibernate.boot.jaxb.mapping.JaxbOneToOne;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPostLoad;
|
import org.hibernate.boot.jaxb.mapping.JaxbPostLoad;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPostPersist;
|
import org.hibernate.boot.jaxb.mapping.JaxbPostPersist;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPostRemove;
|
import org.hibernate.boot.jaxb.mapping.JaxbPostRemove;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPostUpdate;
|
import org.hibernate.boot.jaxb.mapping.JaxbPostUpdate;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPrePersist;
|
import org.hibernate.boot.jaxb.mapping.JaxbPrePersist;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPreRemove;
|
import org.hibernate.boot.jaxb.mapping.JaxbPreRemove;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPreUpdate;
|
import org.hibernate.boot.jaxb.mapping.JaxbPreUpdate;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbTransient;
|
import org.hibernate.boot.jaxb.mapping.JaxbTransient;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbVersion;
|
import org.hibernate.boot.jaxb.mapping.JaxbVersion;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.LifecycleCallback;
|
import org.hibernate.boot.jaxb.mapping.LifecycleCallback;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.LifecycleCallbackContainer;
|
import org.hibernate.boot.jaxb.mapping.LifecycleCallbackContainer;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.PersistentAttribute;
|
import org.hibernate.boot.jaxb.mapping.PersistentAttribute;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reproduces what we used to do with a {@code List<Element>} in {@link JPAXMLOverriddenAnnotationReader},
|
* Reproduces what we used to do with a {@code List<Element>} in {@link JPAXMLOverriddenAnnotationReader},
|
||||||
|
@ -52,14 +53,14 @@ final class PropertyMappingElementCollector {
|
||||||
|
|
||||||
private List<JaxbId> id;
|
private List<JaxbId> id;
|
||||||
private List<JaxbEmbeddedId> embeddedId;
|
private List<JaxbEmbeddedId> embeddedId;
|
||||||
private List<JaxbBasic> basic;
|
|
||||||
private List<JaxbVersion> version;
|
private List<JaxbVersion> version;
|
||||||
private List<JaxbManyToOne> manyToOne;
|
private List<JaxbBasic> basic;
|
||||||
private List<JaxbOneToMany> oneToMany;
|
|
||||||
private List<JaxbOneToOne> oneToOne;
|
|
||||||
private List<JaxbManyToMany> manyToMany;
|
|
||||||
private List<JaxbElementCollection> elementCollection;
|
|
||||||
private List<JaxbEmbedded> embedded;
|
private List<JaxbEmbedded> embedded;
|
||||||
|
private List<JaxbOneToOne> oneToOne;
|
||||||
|
private List<JaxbManyToOne> manyToOne;
|
||||||
|
private List<JaxbElementCollection> elementCollection;
|
||||||
|
private List<JaxbOneToMany> oneToMany;
|
||||||
|
private List<JaxbManyToMany> manyToMany;
|
||||||
private List<JaxbTransient> _transient;
|
private List<JaxbTransient> _transient;
|
||||||
|
|
||||||
private List<JaxbPrePersist> prePersist;
|
private List<JaxbPrePersist> prePersist;
|
||||||
|
@ -95,19 +96,19 @@ final class PropertyMappingElementCollector {
|
||||||
|
|
||||||
public void collectPersistentAttributesIfMatching(AttributesContainer container) {
|
public void collectPersistentAttributesIfMatching(AttributesContainer container) {
|
||||||
if ( container instanceof JaxbAttributes ) {
|
if ( container instanceof JaxbAttributes ) {
|
||||||
JaxbAttributes jaxbAttributes = (JaxbAttributes) container;
|
final JaxbAttributes jaxbAttributes = (JaxbAttributes) container;
|
||||||
id = collectIfMatching( id, jaxbAttributes.getId(), PERSISTENT_ATTRIBUTE_NAME );
|
id = collectIfMatching( id, jaxbAttributes.getId(), PERSISTENT_ATTRIBUTE_NAME );
|
||||||
embeddedId = collectIfMatching( embeddedId, jaxbAttributes.getEmbeddedId(), PERSISTENT_ATTRIBUTE_NAME );
|
embeddedId = collectIfMatching( embeddedId, jaxbAttributes.getEmbeddedId(), PERSISTENT_ATTRIBUTE_NAME );
|
||||||
version = collectIfMatching( version, jaxbAttributes.getVersion(), PERSISTENT_ATTRIBUTE_NAME );
|
version = collectIfMatching( version, jaxbAttributes.getVersion(), PERSISTENT_ATTRIBUTE_NAME );
|
||||||
}
|
}
|
||||||
basic = collectIfMatching( basic, container.getBasic(), PERSISTENT_ATTRIBUTE_NAME );
|
basic = collectIfMatching( basic, container.getBasicAttributes(), PERSISTENT_ATTRIBUTE_NAME );
|
||||||
manyToOne = collectIfMatching( manyToOne, container.getManyToOne(), PERSISTENT_ATTRIBUTE_NAME );
|
manyToOne = collectIfMatching( manyToOne, container.getManyToOneAttributes(), PERSISTENT_ATTRIBUTE_NAME );
|
||||||
oneToMany = collectIfMatching( oneToMany, container.getOneToMany(), PERSISTENT_ATTRIBUTE_NAME );
|
oneToMany = collectIfMatching( oneToMany, container.getOneToManyAttributes(), PERSISTENT_ATTRIBUTE_NAME );
|
||||||
oneToOne = collectIfMatching( oneToOne, container.getOneToOne(), PERSISTENT_ATTRIBUTE_NAME );
|
oneToOne = collectIfMatching( oneToOne, container.getOneToOneAttributes(), PERSISTENT_ATTRIBUTE_NAME );
|
||||||
manyToMany = collectIfMatching( manyToMany, container.getManyToMany(), PERSISTENT_ATTRIBUTE_NAME );
|
manyToMany = collectIfMatching( manyToMany, container.getManyToManyAttributes(), PERSISTENT_ATTRIBUTE_NAME );
|
||||||
elementCollection = collectIfMatching( elementCollection, container.getElementCollection(), PERSISTENT_ATTRIBUTE_NAME );
|
elementCollection = collectIfMatching( elementCollection, container.getElementCollectionAttributes(), PERSISTENT_ATTRIBUTE_NAME );
|
||||||
embedded = collectIfMatching( embedded, container.getEmbedded(), PERSISTENT_ATTRIBUTE_NAME );
|
embedded = collectIfMatching( embedded, container.getEmbeddedAttributes(), PERSISTENT_ATTRIBUTE_NAME );
|
||||||
_transient = collectIfMatching( _transient, container.getTransient(), JAXB_TRANSIENT_NAME );
|
_transient = collectIfMatching( _transient, container.getTransients(), JAXB_TRANSIENT_NAME );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void collectLifecycleCallbacksIfMatching(LifecycleCallbackContainer container) {
|
public void collectLifecycleCallbacksIfMatching(LifecycleCallbackContainer container) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.cfg.annotations.reflection.internal;
|
package org.hibernate.cfg.annotations.reflection.internal;
|
||||||
|
|
||||||
|
@ -11,20 +11,18 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import jakarta.persistence.AccessType;
|
|
||||||
import jakarta.persistence.AttributeConverter;
|
|
||||||
|
|
||||||
import org.hibernate.AnnotationException;
|
import org.hibernate.AnnotationException;
|
||||||
import org.hibernate.boot.internal.ClassmateContext;
|
import org.hibernate.boot.internal.ClassmateContext;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbConverter;
|
import org.hibernate.boot.jaxb.mapping.JaxbConverter;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntity;
|
import org.hibernate.boot.jaxb.mapping.JaxbEntity;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityListener;
|
import org.hibernate.boot.jaxb.mapping.JaxbEntityListener;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityListeners;
|
import org.hibernate.boot.jaxb.mapping.JaxbEntityListeners;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappings;
|
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbMappedSuperclass;
|
import org.hibernate.boot.jaxb.mapping.JaxbMappedSuperclass;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPersistenceUnitDefaults;
|
import org.hibernate.boot.jaxb.mapping.JaxbPersistenceUnitDefaults;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPersistenceUnitMetadata;
|
import org.hibernate.boot.jaxb.mapping.JaxbPersistenceUnitMetadata;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.ManagedType;
|
import org.hibernate.boot.jaxb.mapping.ManagedType;
|
||||||
import org.hibernate.boot.model.convert.internal.ClassBasedConverterDescriptor;
|
import org.hibernate.boot.model.convert.internal.ClassBasedConverterDescriptor;
|
||||||
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||||
|
@ -35,6 +33,9 @@ import org.hibernate.internal.CoreLogging;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
|
|
||||||
|
import jakarta.persistence.AccessType;
|
||||||
|
import jakarta.persistence.AttributeConverter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper for consuming orm.xml mappings.
|
* A helper for consuming orm.xml mappings.
|
||||||
*
|
*
|
||||||
|
@ -64,21 +65,24 @@ public class XMLContext implements Serializable {
|
||||||
* @param entityMappings The xml document to add
|
* @param entityMappings The xml document to add
|
||||||
* @return Add an xml document to this context and return the list of added class names.
|
* @return Add an xml document to this context and return the list of added class names.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings( "unchecked" )
|
@SuppressWarnings("unchecked")
|
||||||
public List<String> addDocument(JaxbEntityMappings entityMappings) {
|
public List<String> addDocument(JaxbEntityMappings entityMappings) {
|
||||||
hasContext = true;
|
hasContext = true;
|
||||||
List<String> addedClasses = new ArrayList<>();
|
|
||||||
|
final List<String> addedClasses = new ArrayList<>();
|
||||||
|
|
||||||
//global defaults
|
//global defaults
|
||||||
JaxbPersistenceUnitMetadata metadata = entityMappings.getPersistenceUnitMetadata();
|
final JaxbPersistenceUnitMetadata metadata = entityMappings.getPersistenceUnitMetadata();
|
||||||
if ( metadata != null ) {
|
if ( metadata != null ) {
|
||||||
if ( globalDefaults == null ) {
|
if ( globalDefaults == null ) {
|
||||||
globalDefaults = new Default();
|
globalDefaults = new Default();
|
||||||
globalDefaults.setMetadataComplete(
|
globalDefaults.setMetadataComplete(
|
||||||
metadata.getXmlMappingMetadataComplete() != null ?
|
metadata.getXmlMappingMetadataComplete() != null
|
||||||
Boolean.TRUE :
|
? Boolean.TRUE
|
||||||
null
|
: null
|
||||||
);
|
);
|
||||||
JaxbPersistenceUnitDefaults defaultElement = metadata.getPersistenceUnitDefaults();
|
|
||||||
|
final JaxbPersistenceUnitDefaults defaultElement = metadata.getPersistenceUnitDefaults();
|
||||||
if ( defaultElement != null ) {
|
if ( defaultElement != null ) {
|
||||||
globalDefaults.setSchema( defaultElement.getSchema() );
|
globalDefaults.setSchema( defaultElement.getSchema() );
|
||||||
globalDefaults.setCatalog( defaultElement.getCatalog() );
|
globalDefaults.setCatalog( defaultElement.getCatalog() );
|
||||||
|
@ -102,13 +106,13 @@ public class XMLContext implements Serializable {
|
||||||
entityMappingDefault.setAccess( entityMappings.getAccess() );
|
entityMappingDefault.setAccess( entityMappings.getAccess() );
|
||||||
defaultElements.add( entityMappings );
|
defaultElements.add( entityMappings );
|
||||||
|
|
||||||
setLocalAttributeConverterDefinitions( entityMappings.getConverter(), packageName );
|
setLocalAttributeConverterDefinitions( entityMappings.getConverters(), packageName );
|
||||||
|
|
||||||
addClass( entityMappings.getEntity(), packageName, entityMappingDefault, addedClasses );
|
addClass( entityMappings.getEntities(), packageName, entityMappingDefault, addedClasses );
|
||||||
|
|
||||||
addClass( entityMappings.getMappedSuperclass(), packageName, entityMappingDefault, addedClasses );
|
addClass( entityMappings.getMappedSuperclasses(), packageName, entityMappingDefault, addedClasses );
|
||||||
|
|
||||||
addClass( entityMappings.getEmbeddable(), packageName, entityMappingDefault, addedClasses );
|
addClass( entityMappings.getEmbeddables(), packageName, entityMappingDefault, addedClasses );
|
||||||
|
|
||||||
return addedClasses;
|
return addedClasses;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +151,7 @@ public class XMLContext implements Serializable {
|
||||||
List<String> localAddedClasses = new ArrayList<>();
|
List<String> localAddedClasses = new ArrayList<>();
|
||||||
if ( listeners != null ) {
|
if ( listeners != null ) {
|
||||||
List<JaxbEntityListener> elements = listeners.getEntityListener();
|
List<JaxbEntityListener> elements = listeners.getEntityListener();
|
||||||
for (JaxbEntityListener listener : elements) {
|
for ( JaxbEntityListener listener : elements ) {
|
||||||
String listenerClassName = buildSafeClassName( listener.getClazz(), packageName );
|
String listenerClassName = buildSafeClassName( listener.getClazz(), packageName );
|
||||||
if ( entityListenerOverride.containsKey( listenerClassName ) ) {
|
if ( entityListenerOverride.containsKey( listenerClassName ) ) {
|
||||||
LOG.duplicateListener( listenerClassName );
|
LOG.duplicateListener( listenerClassName );
|
||||||
|
@ -162,7 +166,6 @@ public class XMLContext implements Serializable {
|
||||||
return localAddedClasses;
|
return localAddedClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private void setLocalAttributeConverterDefinitions(List<JaxbConverter> converterElements, String packageName) {
|
private void setLocalAttributeConverterDefinitions(List<JaxbConverter> converterElements, String packageName) {
|
||||||
for ( JaxbConverter converterElement : converterElements ) {
|
for ( JaxbConverter converterElement : converterElements ) {
|
||||||
final String className = converterElement.getClazz();
|
final String className = converterElement.getClazz();
|
||||||
|
|
|
@ -15,31 +15,25 @@ import static org.hibernate.engine.config.spi.ConfigurationService.Converter;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class StandardConverters {
|
public class StandardConverters {
|
||||||
public static final Converter<Boolean> BOOLEAN = new Converter<Boolean>() {
|
public static final Converter<Boolean> BOOLEAN = (value) -> {
|
||||||
@Override
|
if ( value == null ) {
|
||||||
public Boolean convert(Object value) {
|
throw new IllegalArgumentException( "Null value passed to convert" );
|
||||||
if ( value == null ) {
|
|
||||||
throw new IllegalArgumentException( "Null value passed to convert" );
|
|
||||||
}
|
|
||||||
|
|
||||||
return Boolean.class.isInstance( value )
|
|
||||||
? Boolean.class.cast( value )
|
|
||||||
: Boolean.parseBoolean( value.toString() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return value instanceof Boolean
|
||||||
|
? (Boolean) value
|
||||||
|
: Boolean.parseBoolean( value.toString() );
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final Converter<String> STRING = new Converter<String>() {
|
public static final Converter<String> STRING = (value) -> {
|
||||||
@Override
|
if ( value == null ) {
|
||||||
public String convert(Object value) {
|
throw new IllegalArgumentException( "Null value passed to convert" );
|
||||||
if ( value == null ) {
|
|
||||||
throw new IllegalArgumentException( "Null value passed to convert" );
|
|
||||||
}
|
|
||||||
|
|
||||||
return value.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return value.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final Converter<Integer> INTEGER = value -> {
|
public static final Converter<Integer> INTEGER = (value) -> {
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
throw new IllegalArgumentException( "Null value passed to convert" );
|
throw new IllegalArgumentException( "Null value passed to convert" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,13 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.internal.log;
|
package org.hibernate.internal.log;
|
||||||
|
|
||||||
|
import org.hibernate.boot.jaxb.SourceType;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
|
||||||
import org.jboss.logging.BasicLogger;
|
import org.jboss.logging.BasicLogger;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
import org.jboss.logging.annotations.LogMessage;
|
import org.jboss.logging.annotations.LogMessage;
|
||||||
|
@ -238,4 +241,18 @@ public interface DeprecationLogger extends BasicLogger {
|
||||||
value = "Encountered deprecated setting [%s]; instead %s"
|
value = "Encountered deprecated setting [%s]; instead %s"
|
||||||
)
|
)
|
||||||
void deprecatedSetting2(String settingName, String alternative);
|
void deprecatedSetting2(String settingName, String alternative);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Different from {@link #deprecatedSetting} in that sometimes there is no
|
||||||
|
* direct alternative
|
||||||
|
*/
|
||||||
|
@LogMessage(level = WARN)
|
||||||
|
@Message(
|
||||||
|
id = 90000028,
|
||||||
|
value = "Support for `<hibernate-mappings/>` is deprecated [%s : %s]; " +
|
||||||
|
"migrate to orm.xml or mapping.xml, or enable `" + AvailableSettings.TRANSFORM_HBM_XML +
|
||||||
|
"` for on the fly transformation"
|
||||||
|
)
|
||||||
|
void logDeprecatedHbmXmlProcessing(SourceType sourceType, String name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -264,7 +264,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
|
||||||
|
|
||||||
this.standardServiceRegistry = ssrBuilder.build();
|
this.standardServiceRegistry = ssrBuilder.build();
|
||||||
|
|
||||||
final MetadataSources metadataSources = new MetadataSources( bsr );
|
final MetadataSources metadataSources = new MetadataSources( standardServiceRegistry );
|
||||||
this.metamodelBuilder = (MetadataBuilderImplementor) metadataSources.getMetadataBuilder( standardServiceRegistry );
|
this.metamodelBuilder = (MetadataBuilderImplementor) metadataSources.getMetadataBuilder( standardServiceRegistry );
|
||||||
List<ConverterDescriptor> attributeConverterDefinitions = applyMappingResources( metadataSources );
|
List<ConverterDescriptor> attributeConverterDefinitions = applyMappingResources( metadataSources );
|
||||||
|
|
||||||
|
|
|
@ -435,12 +435,39 @@ public abstract class AbstractServiceRegistryImpl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends Service> T fromRegistryOrChildren(Class<T> serviceRole) {
|
||||||
|
return fromRegistryOrChildren( serviceRole, this, childRegistries );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T extends Service> T fromRegistryOrChildren(
|
||||||
|
Class<T> serviceRole,
|
||||||
|
ServiceRegistryImplementor serviceRegistry,
|
||||||
|
Set<ServiceRegistryImplementor> childRegistries) {
|
||||||
|
// prefer `serviceRegistry`
|
||||||
|
final T localService = serviceRegistry.getService( serviceRole );
|
||||||
|
if ( localService != null ) {
|
||||||
|
return localService;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( childRegistries != null ) {
|
||||||
|
for ( ServiceRegistryImplementor childRegistry : childRegistries ) {
|
||||||
|
final T extracted = childRegistry.getService( serviceRole );
|
||||||
|
if ( extracted != null ) {
|
||||||
|
return extracted;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not intended for general use. We need the ability to stop and "reactivate" a registry to allow
|
* Not intended for general use. We need the ability to stop and "reactivate" a registry to allow
|
||||||
* experimentation with technologies such as GraalVM, Quarkus and Cri-O.
|
* experimentation with technologies such as GraalVM, Quarkus and Cri-O.
|
||||||
*/
|
*/
|
||||||
public synchronized void reactivate() {
|
public synchronized void reactivate() {
|
||||||
if ( !active.compareAndSet(false, true) ) {
|
if ( !active.compareAndSet( false, true ) ) {
|
||||||
throw new IllegalStateException( "Was not inactive, could not reactivate!" );
|
throw new IllegalStateException( "Was not inactive, could not reactivate!" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,4 +46,6 @@ public interface ServiceRegistryImplementor extends ServiceRegistry {
|
||||||
* via this callback.
|
* via this callback.
|
||||||
*/
|
*/
|
||||||
void deRegisterChild(ServiceRegistryImplementor child);
|
void deRegisterChild(ServiceRegistryImplementor child);
|
||||||
|
|
||||||
|
<T extends Service> T fromRegistryOrChildren(Class<T> serviceRole);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -89,6 +89,10 @@
|
||||||
<!-- Binding model customizations -->
|
<!-- Binding model customizations -->
|
||||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||||
|
|
||||||
|
<jaxb:bindings node="//xsd:element[@name='hibernate-mapping']/xsd:complexType">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.spi.BindableMappingDescriptor</inheritance:implements>
|
||||||
|
</jaxb:bindings>
|
||||||
|
|
||||||
<jaxb:bindings node="//xsd:complexType[@name='ToolingHintContainer']">
|
<jaxb:bindings node="//xsd:complexType[@name='ToolingHintContainer']">
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.hbm.spi.ToolingHintContainer</inheritance:implements>
|
<inheritance:implements>org.hibernate.boot.jaxb.hbm.spi.ToolingHintContainer</inheritance:implements>
|
||||||
</jaxb:bindings>
|
</jaxb:bindings>
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
extensionBindingPrefixes="inheritance"
|
extensionBindingPrefixes="inheritance"
|
||||||
version="3.0">
|
version="3.0">
|
||||||
|
|
||||||
<bindings schemaLocation="../resources/org/hibernate/jpa/orm_2_2.xsd" node="/xsd:schema">
|
<bindings schemaLocation="../resources/org/hibernate/xsd/mapping/mapping-3.1.0.xsd" node="/xsd:schema">
|
||||||
<schemaBindings>
|
<schemaBindings>
|
||||||
<package name="org.hibernate.boot.jaxb.mapping.spi" />
|
<package name="org.hibernate.boot.jaxb.mapping" />
|
||||||
<nameXmlTransform>
|
<nameXmlTransform>
|
||||||
<typeName prefix="Jaxb" />
|
<typeName prefix="Jaxb" />
|
||||||
<elementName prefix="Jaxb" />
|
<elementName prefix="Jaxb" />
|
||||||
|
@ -17,174 +17,376 @@
|
||||||
</nameXmlTransform>
|
</nameXmlTransform>
|
||||||
</schemaBindings>
|
</schemaBindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:element[@name='entity-mappings']/xsd:complexType">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.spi.BindableMappingDescriptor</inheritance:implements>
|
||||||
|
|
||||||
|
<bindings node=".//xsd:element[@name='filter-def']">
|
||||||
|
<property name="filterDefinitions"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='fetch-profile']">
|
||||||
|
<property name="fetchProfiles"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='identifier-generator']">
|
||||||
|
<property name="genericGenerators"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='database-object']">
|
||||||
|
<property name="databaseObjects"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='import']">
|
||||||
|
<property name="hqlImports"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='named-query']">
|
||||||
|
<property name="namedQueries"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='named-native-query']">
|
||||||
|
<property name="namedNativeQueries"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='named-stored-procedure-query']">
|
||||||
|
<property name="namedProcedureQueries"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='sql-result-set-mapping']">
|
||||||
|
<property name="sqlResultSetMappings"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='mapped-superclass']">
|
||||||
|
<property name="mappedSuperclasses"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='entity']">
|
||||||
|
<property name="entities"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='embeddable']">
|
||||||
|
<property name="embeddables"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='converter']">
|
||||||
|
<property name="converters"/>
|
||||||
|
</bindings>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='entity']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.EntityOrMappedSuperclass</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='embeddable']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.ManagedType</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='mapped-superclass']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.EntityOrMappedSuperclass</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='attributes']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.AttributesContainer</inheritance:implements>
|
||||||
|
<bindings node=".//xsd:element[@name='basic']">
|
||||||
|
<property name="basicAttributes"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='embedded']">
|
||||||
|
<property name="embeddedAttributes"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='one-to-one']">
|
||||||
|
<property name="oneToOneAttributes"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='many-to-one']">
|
||||||
|
<property name="manyToOneAttributes"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='any']">
|
||||||
|
<property name="discriminatedAssociations"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='element-collection']">
|
||||||
|
<property name="elementCollectionAttributes"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='one-to-many']">
|
||||||
|
<property name="oneToManyAttributes"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='many-to-many']">
|
||||||
|
<property name="manyToManyAttributes"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='many-to-any']">
|
||||||
|
<property name="pluralDiscriminatedAssociations"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='transient']">
|
||||||
|
<property name="transients"/>
|
||||||
|
</bindings>
|
||||||
|
</bindings>
|
||||||
|
<bindings node="//xsd:complexType[@name='embeddable-attributes']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.AttributesContainer</inheritance:implements>
|
||||||
|
<bindings node=".//xsd:element[@name='basic']">
|
||||||
|
<property name="basicAttributes"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='embedded']">
|
||||||
|
<property name="embeddedAttributes"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='one-to-one']">
|
||||||
|
<property name="oneToOneAttributes"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='many-to-one']">
|
||||||
|
<property name="manyToOneAttributes"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='any']">
|
||||||
|
<property name="discriminatedAssociations"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='element-collection']">
|
||||||
|
<property name="elementCollectionAttributes"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='one-to-many']">
|
||||||
|
<property name="oneToManyAttributes"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='many-to-many']">
|
||||||
|
<property name="manyToManyAttributes"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='many-to-any']">
|
||||||
|
<property name="pluralDiscriminatedAssociations"/>
|
||||||
|
</bindings>
|
||||||
|
<bindings node=".//xsd:element[@name='transient']">
|
||||||
|
<property name="transients"/>
|
||||||
|
</bindings>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='id']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.PersistentAttribute</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='embedded-id']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.PersistentAttribute</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='version']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.PersistentAttribute</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='basic']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.PersistentAttribute</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='embedded']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.PersistentAttribute</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='one-to-one']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.ToOneAttribute</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='many-to-one']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.ToOneAttribute</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='hbm-any-mapping']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.DiscriminatedAssociation</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='element-collection']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.CollectionAttribute</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='one-to-many']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.CollectionAttribute</inheritance:implements>
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.AssociationAttribute</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='many-to-many']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.CollectionAttribute</inheritance:implements>
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.AssociationAttribute</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='hbm-many-to-any']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.DiscriminatedAssociation</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='hbm-any-discriminator']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.DiscriminatedAssociation.Discriminator</inheritance:implements>
|
||||||
|
<bindings node=".//xsd:element[@name='mapping']">
|
||||||
|
<property name="valueMappings"/>
|
||||||
|
</bindings>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='hbm-any-discriminator-value-mapping']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.DiscriminatorMapping</inheritance:implements>
|
||||||
|
<property name="correspondingEntityName"/>
|
||||||
|
<bindings node=".//xsd:attribute[@name='value']">
|
||||||
|
<property name="discriminatorValue"/>
|
||||||
|
</bindings>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='hbm-any-key']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.DiscriminatedAssociation.Key</inheritance:implements>
|
||||||
|
<bindings node=".//xsd:element[@name='column']">
|
||||||
|
<property name="columns"/>
|
||||||
|
</bindings>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='secondary-table']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.SchemaAware</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
<bindings node="//xsd:complexType[@name='table']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.SchemaAware</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
<bindings node="//xsd:complexType[@name='join-table']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.SchemaAware</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
<bindings node="//xsd:complexType[@name='collection-table']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.SchemaAware</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
<bindings node="//xsd:complexType[@name='table-generator']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.SchemaAware</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
<bindings node="//xsd:complexType[@name='sequence-generator']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.SchemaAware</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
<bindings node="//xsd:complexType[@name='database-object']">
|
||||||
|
<bindings node=".//xsd:element[@name='dialect-scope']">
|
||||||
|
<property name="dialectScopes"/>
|
||||||
|
</bindings>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='entity-listener']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.LifecycleCallbackContainer</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='pre-persist']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.LifecycleCallback</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
<bindings node="//xsd:complexType[@name='pre-remove']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.LifecycleCallback</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
<bindings node="//xsd:complexType[@name='pre-update']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.LifecycleCallback</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
<bindings node="//xsd:complexType[@name='post-load']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.LifecycleCallback</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
<bindings node="//xsd:complexType[@name='post-remove']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.LifecycleCallback</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
<bindings node="//xsd:complexType[@name='post-update']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.LifecycleCallback</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
<bindings node="//xsd:complexType[@name='post-persist']">
|
||||||
|
<inheritance:implements>org.hibernate.boot.jaxb.mapping.LifecycleCallback</inheritance:implements>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:complexType[@name='named-native-query']">
|
||||||
|
<bindings node=".//xsd:element[@name='synchronize']">
|
||||||
|
<property name="synchronizations"/>
|
||||||
|
</bindings>
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!--
|
||||||
|
#################################################################
|
||||||
|
Marshalling of enum values
|
||||||
|
#################################################################
|
||||||
|
-->
|
||||||
|
|
||||||
<bindings node="//xsd:simpleType[@name='access-type']">
|
<bindings node="//xsd:simpleType[@name='access-type']">
|
||||||
<javaType name="jakarta.persistence.AccessType"
|
<javaType name="jakarta.persistence.AccessType"
|
||||||
parseMethod="org.hibernate.boot.jaxb.mapping.internal.AccessTypeMarshalling.fromXml"
|
parseMethod="org.hibernate.boot.jaxb.mapping.marshall.AccessTypeMarshalling.fromXml"
|
||||||
printMethod="org.hibernate.boot.jaxb.mapping.internal.AccessTypeMarshalling.toXml" />
|
printMethod="org.hibernate.boot.jaxb.mapping.marshall.AccessTypeMarshalling.toXml" />
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:simpleType[@name='cache-access-type']">
|
||||||
|
<javaType name="org.hibernate.cache.spi.access.AccessType"
|
||||||
|
parseMethod="org.hibernate.boot.jaxb.mapping.marshall.CacheAccessTypeMarshalling.fromXml"
|
||||||
|
printMethod="org.hibernate.boot.jaxb.mapping.marshall.CacheAccessTypeMarshalling.toXml" />
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:simpleType[@name='hbm-cache-mode-type']">
|
||||||
|
<javaType name="org.hibernate.CacheMode"
|
||||||
|
parseMethod="org.hibernate.boot.jaxb.mapping.marshall.CacheModeMarshalling.fromXml"
|
||||||
|
printMethod="org.hibernate.boot.jaxb.mapping.marshall.CacheModeMarshalling.toXml" />
|
||||||
</bindings>
|
</bindings>
|
||||||
|
|
||||||
<bindings node="//xsd:simpleType[@name='discriminator-type']">
|
<bindings node="//xsd:simpleType[@name='discriminator-type']">
|
||||||
<javaType name="jakarta.persistence.DiscriminatorType"
|
<javaType name="jakarta.persistence.DiscriminatorType"
|
||||||
parseMethod="org.hibernate.boot.jaxb.mapping.internal.DiscriminatorTypeMarshalling.fromXml"
|
parseMethod="org.hibernate.boot.jaxb.mapping.marshall.DiscriminatorTypeMarshalling.fromXml"
|
||||||
printMethod="org.hibernate.boot.jaxb.mapping.internal.DiscriminatorTypeMarshalling.toXml" />
|
printMethod="org.hibernate.boot.jaxb.mapping.marshall.DiscriminatorTypeMarshalling.toXml" />
|
||||||
</bindings>
|
</bindings>
|
||||||
|
|
||||||
<bindings node="//xsd:simpleType[@name='enum-type']">
|
<bindings node="//xsd:simpleType[@name='enum-type']">
|
||||||
<javaType name="jakarta.persistence.EnumType"
|
<javaType name="jakarta.persistence.EnumType"
|
||||||
parseMethod="org.hibernate.boot.jaxb.mapping.internal.EnumTypeMarshalling.fromXml"
|
parseMethod="org.hibernate.boot.jaxb.mapping.marshall.EnumTypeMarshalling.fromXml"
|
||||||
printMethod="org.hibernate.boot.jaxb.mapping.internal.EnumTypeMarshalling.toXml" />
|
printMethod="org.hibernate.boot.jaxb.mapping.marshall.EnumTypeMarshalling.toXml" />
|
||||||
</bindings>
|
</bindings>
|
||||||
|
|
||||||
<bindings node="//xsd:simpleType[@name='fetch-type']">
|
<bindings node="//xsd:simpleType[@name='fetch-type']">
|
||||||
<javaType name="jakarta.persistence.FetchType"
|
<javaType name="jakarta.persistence.FetchType"
|
||||||
parseMethod="org.hibernate.boot.jaxb.mapping.internal.FetchTypeMarshalling.fromXml"
|
parseMethod="org.hibernate.boot.jaxb.mapping.marshall.FetchTypeMarshalling.fromXml"
|
||||||
printMethod="org.hibernate.boot.jaxb.mapping.internal.FetchTypeMarshalling.toXml" />
|
printMethod="org.hibernate.boot.jaxb.mapping.marshall.FetchTypeMarshalling.toXml" />
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:simpleType[@name='flush-mode-type']">
|
||||||
|
<javaType name="org.hibernate.FlushMode"
|
||||||
|
parseMethod="org.hibernate.boot.jaxb.mapping.marshall.FlushModeMarshalling.fromXml"
|
||||||
|
printMethod="org.hibernate.boot.jaxb.mapping.marshall.FlushModeMarshalling.toXml" />
|
||||||
</bindings>
|
</bindings>
|
||||||
|
|
||||||
<bindings node="//xsd:simpleType[@name='lock-mode-type']">
|
<bindings node="//xsd:simpleType[@name='lock-mode-type']">
|
||||||
<javaType name="jakarta.persistence.LockModeType"
|
<javaType name="jakarta.persistence.LockModeType"
|
||||||
parseMethod="org.hibernate.boot.jaxb.mapping.internal.LockModeTypeMarshalling.fromXml"
|
parseMethod="org.hibernate.boot.jaxb.mapping.marshall.LockModeTypeMarshalling.fromXml"
|
||||||
printMethod="org.hibernate.boot.jaxb.mapping.internal.LockModeTypeMarshalling.toXml" />
|
printMethod="org.hibernate.boot.jaxb.mapping.marshall.LockModeTypeMarshalling.toXml" />
|
||||||
</bindings>
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:simpleType[@name='optimistic-locking-type']">
|
||||||
|
<javaType name="org.hibernate.engine.OptimisticLockStyle"
|
||||||
|
parseMethod="org.hibernate.boot.jaxb.mapping.marshall.OptimisticLockStyleMarshalling.fromXml"
|
||||||
|
printMethod="org.hibernate.boot.jaxb.mapping.marshall.OptimisticLockStyleMarshalling.toXml" />
|
||||||
|
</bindings>
|
||||||
|
|
||||||
<bindings node="//xsd:simpleType[@name='parameter-mode']">
|
<bindings node="//xsd:simpleType[@name='parameter-mode']">
|
||||||
<javaType name="jakarta.persistence.ParameterMode"
|
<javaType name="jakarta.persistence.ParameterMode"
|
||||||
parseMethod="org.hibernate.boot.jaxb.mapping.internal.ParameterModeMarshalling.fromXml"
|
parseMethod="org.hibernate.boot.jaxb.mapping.marshall.ParameterModeMarshalling.fromXml"
|
||||||
printMethod="org.hibernate.boot.jaxb.mapping.internal.ParameterModeMarshalling.toXml" />
|
printMethod="org.hibernate.boot.jaxb.mapping.marshall.ParameterModeMarshalling.toXml" />
|
||||||
</bindings>
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:simpleType[@name='custom-sql-check-type']">
|
||||||
|
<javaType name="org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle"
|
||||||
|
parseMethod="org.hibernate.boot.jaxb.mapping.marshall.ResultCheckStyleMarshalling.fromXml"
|
||||||
|
printMethod="org.hibernate.boot.jaxb.mapping.marshall.ResultCheckStyleMarshalling.toXml" />
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:simpleType[@name='on-delete-type']">
|
||||||
|
<javaType name="org.hibernate.annotations.OnDeleteAction"
|
||||||
|
parseMethod="org.hibernate.boot.jaxb.mapping.marshall.OnDeleteActionMarshalling.fromXml"
|
||||||
|
printMethod="org.hibernate.boot.jaxb.mapping.marshall.OnDeleteActionMarshalling.toXml" />
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:simpleType[@name='polymorphism-type']">
|
||||||
|
<javaType name="org.hibernate.annotations.PolymorphismType"
|
||||||
|
parseMethod="org.hibernate.boot.jaxb.mapping.marshall.PolymorphismTypeMarshalling.fromXml"
|
||||||
|
printMethod="org.hibernate.boot.jaxb.mapping.marshall.PolymorphismTypeMarshalling.toXml" />
|
||||||
|
</bindings>
|
||||||
|
|
||||||
<bindings node="//xsd:simpleType[@name='temporal-type']">
|
<bindings node="//xsd:simpleType[@name='temporal-type']">
|
||||||
<javaType name="jakarta.persistence.TemporalType"
|
<javaType name="jakarta.persistence.TemporalType"
|
||||||
parseMethod="org.hibernate.boot.jaxb.mapping.internal.TemporalTypeMarshalling.fromXml"
|
parseMethod="org.hibernate.boot.jaxb.mapping.marshall.TemporalTypeMarshalling.fromXml"
|
||||||
printMethod="org.hibernate.boot.jaxb.mapping.internal.TemporalTypeMarshalling.toXml" />
|
printMethod="org.hibernate.boot.jaxb.mapping.marshall.TemporalTypeMarshalling.toXml" />
|
||||||
</bindings>
|
</bindings>
|
||||||
|
|
||||||
<bindings node="//xsd:simpleType[@name='inheritance-type']">
|
<bindings node="//xsd:simpleType[@name='inheritance-type']">
|
||||||
<javaType name="jakarta.persistence.InheritanceType"
|
<javaType name="jakarta.persistence.InheritanceType"
|
||||||
parseMethod="org.hibernate.boot.jaxb.mapping.internal.InheritanceTypeMarshalling.fromXml"
|
parseMethod="org.hibernate.boot.jaxb.mapping.marshall.InheritanceTypeMarshalling.fromXml"
|
||||||
printMethod="org.hibernate.boot.jaxb.mapping.internal.InheritanceTypeMarshalling.toXml" />
|
printMethod="org.hibernate.boot.jaxb.mapping.marshall.InheritanceTypeMarshalling.toXml" />
|
||||||
</bindings>
|
</bindings>
|
||||||
|
|
||||||
<bindings node="//xsd:simpleType[@name='generation-type']">
|
<bindings node="//xsd:simpleType[@name='generation-type']">
|
||||||
<javaType name="jakarta.persistence.GenerationType"
|
<javaType name="jakarta.persistence.GenerationType"
|
||||||
parseMethod="org.hibernate.boot.jaxb.mapping.internal.GenerationTypeMarshalling.fromXml"
|
parseMethod="org.hibernate.boot.jaxb.mapping.marshall.GenerationTypeMarshalling.fromXml"
|
||||||
printMethod="org.hibernate.boot.jaxb.mapping.internal.GenerationTypeMarshalling.toXml" />
|
printMethod="org.hibernate.boot.jaxb.mapping.marshall.GenerationTypeMarshalling.toXml" />
|
||||||
|
</bindings>
|
||||||
|
|
||||||
|
<bindings node="//xsd:simpleType[@name='basic-generation-timing-type']">
|
||||||
|
<javaType name="org.hibernate.tuple.GenerationTiming"
|
||||||
|
parseMethod="org.hibernate.boot.jaxb.mapping.marshall.GenerationTimingMarshalling.fromXml"
|
||||||
|
printMethod="org.hibernate.boot.jaxb.mapping.marshall.GenerationTimingMarshalling.toXml" />
|
||||||
</bindings>
|
</bindings>
|
||||||
|
|
||||||
<bindings node="//xsd:simpleType[@name='constraint-mode']">
|
<bindings node="//xsd:simpleType[@name='constraint-mode']">
|
||||||
<javaType name="jakarta.persistence.ConstraintMode"
|
<javaType name="jakarta.persistence.ConstraintMode"
|
||||||
parseMethod="org.hibernate.boot.jaxb.mapping.internal.ConstraintModeMarshalling.fromXml"
|
parseMethod="org.hibernate.boot.jaxb.mapping.marshall.ConstraintModeMarshalling.fromXml"
|
||||||
printMethod="org.hibernate.boot.jaxb.mapping.internal.ConstraintModeMarshalling.toXml" />
|
printMethod="org.hibernate.boot.jaxb.mapping.marshall.ConstraintModeMarshalling.toXml" />
|
||||||
</bindings>
|
</bindings>
|
||||||
|
|
||||||
|
|
||||||
<bindings node="//xsd:complexType[@name='secondary-table']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.SchemaAware</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='table']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.SchemaAware</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='join-table']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.SchemaAware</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='collection-table']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.SchemaAware</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='table-generator']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.SchemaAware</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='sequence-generator']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.SchemaAware</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
|
|
||||||
<bindings node="//xsd:complexType[@name='entity']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.ManagedType</inheritance:implements>
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.EntityOrMappedSuperclass</inheritance:implements>
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.LifecycleCallbackContainer</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='embeddable']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.ManagedType</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='mapped-superclass']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.ManagedType</inheritance:implements>
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.EntityOrMappedSuperclass</inheritance:implements>
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.LifecycleCallbackContainer</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
|
|
||||||
<bindings node="//xsd:complexType[@name='entity-listener']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.LifecycleCallbackContainer</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
|
|
||||||
<bindings node="//xsd:complexType[@name='id']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.PersistentAttribute</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='version']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.PersistentAttribute</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='basic']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.PersistentAttribute</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='many-to-one']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.PersistentAttribute</inheritance:implements>
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.FetchableAttribute</inheritance:implements>
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.AssociationAttribute</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='one-to-many']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.PersistentAttribute</inheritance:implements>
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.CollectionAttribute</inheritance:implements>
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.AssociationAttribute</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='one-to-one']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.PersistentAttribute</inheritance:implements>
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.FetchableAttribute</inheritance:implements>
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.AssociationAttribute</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='embedded-id']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.PersistentAttribute</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='embedded']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.PersistentAttribute</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='many-to-many']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.PersistentAttribute</inheritance:implements>
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.CollectionAttribute</inheritance:implements>
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.AssociationAttribute</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='element-collection']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.PersistentAttribute</inheritance:implements>
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.CollectionAttribute</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
|
|
||||||
<bindings node="//xsd:complexType[@name='pre-persist']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.LifecycleCallback</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='pre-remove']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.LifecycleCallback</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='pre-update']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.LifecycleCallback</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='post-load']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.LifecycleCallback</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='post-remove']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.LifecycleCallback</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='post-update']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.LifecycleCallback</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='post-persist']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.LifecycleCallback</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
|
|
||||||
<bindings node="//xsd:complexType[@name='attributes']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.AttributesContainer</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
<bindings node="//xsd:complexType[@name='embeddable-attributes']">
|
|
||||||
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.AttributesContainer</inheritance:implements>
|
|
||||||
</bindings>
|
|
||||||
</bindings>
|
</bindings>
|
||||||
|
|
||||||
|
|
||||||
<!-- All bindings need to be serializable for cached metadata sources. -->
|
<!-- All bindings need to be serializable for cached metadata sources. -->
|
||||||
<globalBindings>
|
<globalBindings>
|
||||||
<serializable />
|
<serializable />
|
||||||
|
|
|
@ -2,29 +2,82 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.annotations.reflection;
|
package org.hibernate.orm.test.annotations.reflection;
|
||||||
|
|
||||||
import org.hibernate.annotations.Columns;
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappings;
|
|
||||||
import org.hibernate.cfg.annotations.reflection.internal.JPAXMLOverriddenAnnotationReader;
|
|
||||||
import org.hibernate.cfg.annotations.reflection.internal.XMLContext;
|
|
||||||
import org.hibernate.orm.test.internal.util.xml.XMLMappingHelper;
|
|
||||||
|
|
||||||
import org.hibernate.testing.boot.BootstrapContextImpl;
|
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import org.hibernate.annotations.Columns;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
|
||||||
|
import org.hibernate.cfg.annotations.reflection.internal.JPAXMLOverriddenAnnotationReader;
|
||||||
|
import org.hibernate.cfg.annotations.reflection.internal.XMLContext;
|
||||||
|
import org.hibernate.orm.test.internal.util.xml.XMLMappingHelper;
|
||||||
|
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.boot.BootstrapContextImpl;
|
||||||
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import jakarta.persistence.AssociationOverrides;
|
||||||
|
import jakarta.persistence.AttributeOverrides;
|
||||||
|
import jakarta.persistence.Basic;
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Converts;
|
||||||
|
import jakarta.persistence.DiscriminatorColumn;
|
||||||
|
import jakarta.persistence.DiscriminatorValue;
|
||||||
|
import jakarta.persistence.ElementCollection;
|
||||||
|
import jakarta.persistence.Embedded;
|
||||||
|
import jakarta.persistence.EmbeddedId;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.EntityListeners;
|
||||||
|
import jakarta.persistence.EnumType;
|
||||||
|
import jakarta.persistence.Enumerated;
|
||||||
|
import jakarta.persistence.ExcludeDefaultListeners;
|
||||||
|
import jakarta.persistence.ExcludeSuperclassListeners;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.IdClass;
|
||||||
|
import jakarta.persistence.Inheritance;
|
||||||
|
import jakarta.persistence.InheritanceType;
|
||||||
|
import jakarta.persistence.JoinColumns;
|
||||||
|
import jakarta.persistence.JoinTable;
|
||||||
|
import jakarta.persistence.Lob;
|
||||||
|
import jakarta.persistence.ManyToMany;
|
||||||
|
import jakarta.persistence.MapKey;
|
||||||
|
import jakarta.persistence.MappedSuperclass;
|
||||||
|
import jakarta.persistence.NamedNativeQueries;
|
||||||
|
import jakarta.persistence.NamedQueries;
|
||||||
|
import jakarta.persistence.OneToMany;
|
||||||
|
import jakarta.persistence.OneToOne;
|
||||||
|
import jakarta.persistence.OrderBy;
|
||||||
|
import jakarta.persistence.PostLoad;
|
||||||
|
import jakarta.persistence.PostPersist;
|
||||||
|
import jakarta.persistence.PrePersist;
|
||||||
|
import jakarta.persistence.PrimaryKeyJoinColumn;
|
||||||
|
import jakarta.persistence.PrimaryKeyJoinColumns;
|
||||||
|
import jakarta.persistence.SecondaryTable;
|
||||||
|
import jakarta.persistence.SecondaryTables;
|
||||||
|
import jakarta.persistence.SequenceGenerator;
|
||||||
|
import jakarta.persistence.SqlResultSetMappings;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import jakarta.persistence.TableGenerator;
|
||||||
|
import jakarta.persistence.Temporal;
|
||||||
|
import jakarta.persistence.TemporalType;
|
||||||
|
import jakarta.persistence.Transient;
|
||||||
|
import jakarta.persistence.Version;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.annotations.reflection;
|
package org.hibernate.orm.test.annotations.reflection;
|
||||||
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappings;
|
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
|
||||||
import org.hibernate.cfg.annotations.reflection.internal.XMLContext;
|
import org.hibernate.cfg.annotations.reflection.internal.XMLContext;
|
||||||
import org.hibernate.orm.test.internal.util.xml.XMLMappingHelper;
|
import org.hibernate.orm.test.internal.util.xml.XMLMappingHelper;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.annotations.xml.ejb3;
|
package org.hibernate.orm.test.annotations.xml.ejb3;
|
||||||
|
|
||||||
|
@ -10,14 +10,13 @@ import java.io.InputStream;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.AnnotatedElement;
|
import java.lang.reflect.AnnotatedElement;
|
||||||
|
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappings;
|
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
|
||||||
import org.hibernate.cfg.annotations.reflection.internal.JPAXMLOverriddenAnnotationReader;
|
import org.hibernate.cfg.annotations.reflection.internal.JPAXMLOverriddenAnnotationReader;
|
||||||
import org.hibernate.cfg.annotations.reflection.internal.XMLContext;
|
import org.hibernate.cfg.annotations.reflection.internal.XMLContext;
|
||||||
import org.hibernate.orm.test.internal.util.xml.XMLMappingHelper;
|
import org.hibernate.orm.test.internal.util.xml.XMLMappingHelper;
|
||||||
|
|
||||||
import org.hibernate.testing.boot.BootstrapContextImpl;
|
import org.hibernate.testing.boot.BootstrapContextImpl;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* 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.orm.test.boot.jaxb.mapping;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import javax.xml.stream.XMLEventFactory;
|
||||||
|
import javax.xml.stream.XMLEventReader;
|
||||||
|
|
||||||
|
import org.hibernate.boot.jaxb.internal.stax.MappingEventReader;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
|
||||||
|
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
|
import org.hibernate.boot.xsd.MappingXsdSupport;
|
||||||
|
|
||||||
|
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import jakarta.xml.bind.JAXBContext;
|
||||||
|
import jakarta.xml.bind.JAXBException;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.hibernate.orm.test.boot.jaxb.mapping.JaxbHelper.withStaxEventReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
@ServiceRegistry
|
||||||
|
public class BasicMappingJaxbTests {
|
||||||
|
@Test
|
||||||
|
public void simpleUnifiedJaxbTest(ServiceRegistryScope scope) {
|
||||||
|
scope.withService( ClassLoaderService.class, (cls) -> {
|
||||||
|
verify( "xml/jaxb/mapping/basic/unified.xml", cls, scope );
|
||||||
|
verify( "xml/jaxb/mapping/basic/orm.xml", cls, scope );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void verify(String resourceName, ClassLoaderService cls, ServiceRegistryScope scope) {
|
||||||
|
try ( final InputStream inputStream = cls.locateResourceStream( resourceName ) ) {
|
||||||
|
withStaxEventReader( inputStream, cls, (staxEventReader) -> {
|
||||||
|
final XMLEventFactory xmlEventFactory = XMLEventFactory.newInstance();
|
||||||
|
final XMLEventReader reader = new MappingEventReader( staxEventReader, xmlEventFactory );
|
||||||
|
try {
|
||||||
|
final JAXBContext jaxbCtx = JAXBContext.newInstance( org.hibernate.boot.jaxb.mapping.JaxbEntityMappings.class );
|
||||||
|
final JaxbEntityMappings entityMappings = JaxbHelper.VALIDATING.jaxb( reader, MappingXsdSupport._310.getSchema(), jaxbCtx );
|
||||||
|
assertThat( entityMappings ).isNotNull();
|
||||||
|
assertThat( entityMappings.getEntities() ).hasSize( 1 );
|
||||||
|
}
|
||||||
|
catch (JAXBException e) {
|
||||||
|
throw new RuntimeException( "Error during JAXB processing", e );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
throw new RuntimeException( "Error accessing mapping file", e );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* 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.orm.test.boot.jaxb.mapping;
|
||||||
|
|
||||||
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
import org.hibernate.testing.orm.junit.DomainModelScope;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
@DomainModel( annotatedClasses = SimpleEntity.class, xmlMappings = "xml/jaxb/mapping/partial/caching.xml" )
|
||||||
|
public class CachingOverrideTest {
|
||||||
|
@Test
|
||||||
|
public void verifyMapping(DomainModelScope scope) {
|
||||||
|
scope.withHierarchy( SimpleEntity.class, (entityDescriptor) -> {
|
||||||
|
assertThat( entityDescriptor.isCached() ).isTrue();
|
||||||
|
assertThat( entityDescriptor.getCacheRegionName() ).isEqualTo( "netherworld" );
|
||||||
|
assertThat( entityDescriptor.getCacheConcurrencyStrategy() ).isEqualTo( "transactional" );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
}
|
|
@ -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.orm.test.boot.jaxb.mapping;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import javax.xml.stream.XMLEventFactory;
|
||||||
|
import javax.xml.stream.XMLEventReader;
|
||||||
|
|
||||||
|
import org.hibernate.boot.jaxb.Origin;
|
||||||
|
import org.hibernate.boot.jaxb.SourceType;
|
||||||
|
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
|
||||||
|
import org.hibernate.boot.jaxb.hbm.transform.HbmXmlTransformer;
|
||||||
|
import org.hibernate.boot.jaxb.hbm.transform.UnsupportedFeatureHandling;
|
||||||
|
import org.hibernate.boot.jaxb.internal.stax.HbmEventReader;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbEntity;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
|
||||||
|
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
|
import org.hibernate.boot.xsd.MappingXsdSupport;
|
||||||
|
|
||||||
|
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import jakarta.xml.bind.JAXBContext;
|
||||||
|
import jakarta.xml.bind.JAXBException;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.hibernate.orm.test.boot.jaxb.mapping.JaxbHelper.withStaxEventReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
@ServiceRegistry
|
||||||
|
public class HbmTransformationJaxbTests {
|
||||||
|
@Test
|
||||||
|
public void hbmTransformationTest(ServiceRegistryScope scope) {
|
||||||
|
scope.withService( ClassLoaderService.class, (cls) -> {
|
||||||
|
verifyHbm( "xml/jaxb/mapping/basic/hbm.xml", cls, scope );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void verifyHbm(String resourceName, ClassLoaderService cls, ServiceRegistryScope scope) {
|
||||||
|
try ( final InputStream inputStream = cls.locateResourceStream( resourceName ) ) {
|
||||||
|
withStaxEventReader( inputStream, cls, (staxEventReader) -> {
|
||||||
|
final XMLEventReader reader = new HbmEventReader( staxEventReader, XMLEventFactory.newInstance() );
|
||||||
|
|
||||||
|
try {
|
||||||
|
final JAXBContext jaxbCtx = JAXBContext.newInstance( JaxbHbmHibernateMapping.class );
|
||||||
|
final JaxbHbmHibernateMapping hbmMapping = JaxbHelper.VALIDATING.jaxb( reader, MappingXsdSupport.hbmXml.getSchema(), jaxbCtx );
|
||||||
|
assertThat( hbmMapping ).isNotNull();
|
||||||
|
assertThat( hbmMapping.getClazz() ).hasSize( 1 );
|
||||||
|
|
||||||
|
final JaxbEntityMappings transformed = HbmXmlTransformer.transform(
|
||||||
|
hbmMapping,
|
||||||
|
new Origin( SourceType.RESOURCE, resourceName ),
|
||||||
|
() -> UnsupportedFeatureHandling.ERROR
|
||||||
|
);
|
||||||
|
|
||||||
|
assertThat( transformed ).isNotNull();
|
||||||
|
assertThat( transformed.getEntities() ).hasSize( 1 );
|
||||||
|
assertThat( transformed.getPackage() ).isEqualTo( "org.hibernate.orm.test.boot.jaxb.mapping" );
|
||||||
|
|
||||||
|
final JaxbEntity ormEntity = transformed.getEntities().get( 0 );
|
||||||
|
assertThat( ormEntity.getName() ).isNull();
|
||||||
|
assertThat( ormEntity.getClazz() ).isEqualTo( "SimpleEntity" );
|
||||||
|
|
||||||
|
assertThat( ormEntity.getAttributes().getId() ).hasSize( 1 );
|
||||||
|
assertThat( ormEntity.getAttributes().getBasicAttributes() ).hasSize( 1 );
|
||||||
|
assertThat( ormEntity.getAttributes().getEmbeddedAttributes() ).isEmpty();
|
||||||
|
assertThat( ormEntity.getAttributes().getOneToOneAttributes() ).isEmpty();
|
||||||
|
assertThat( ormEntity.getAttributes().getManyToOneAttributes() ).isEmpty();
|
||||||
|
assertThat( ormEntity.getAttributes().getDiscriminatedAssociations() ).isEmpty();
|
||||||
|
assertThat( ormEntity.getAttributes().getOneToManyAttributes() ).isEmpty();
|
||||||
|
assertThat( ormEntity.getAttributes().getManyToManyAttributes() ).isEmpty();
|
||||||
|
assertThat( ormEntity.getAttributes().getPluralDiscriminatedAssociations() ).isEmpty();
|
||||||
|
}
|
||||||
|
catch (JAXBException e) {
|
||||||
|
throw new RuntimeException( "Error during JAXB processing", e );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
throw new RuntimeException( "Error accessing mapping file", e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
/*
|
||||||
|
* 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.orm.test.boot.jaxb.mapping;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import javax.xml.stream.XMLEventReader;
|
||||||
|
import javax.xml.stream.XMLInputFactory;
|
||||||
|
import javax.xml.stream.XMLStreamException;
|
||||||
|
import javax.xml.validation.Schema;
|
||||||
|
|
||||||
|
import org.hibernate.boot.jaxb.internal.ContextProvidingValidationEventHandler;
|
||||||
|
import org.hibernate.boot.jaxb.internal.stax.BufferedXMLEventReader;
|
||||||
|
import org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver;
|
||||||
|
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
|
|
||||||
|
import jakarta.xml.bind.JAXBContext;
|
||||||
|
import jakarta.xml.bind.JAXBException;
|
||||||
|
import jakarta.xml.bind.Unmarshaller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class JaxbHelper {
|
||||||
|
public static final JaxbHelper INSTANCE = new JaxbHelper( false );
|
||||||
|
public static final JaxbHelper VALIDATING = new JaxbHelper( true );
|
||||||
|
|
||||||
|
private final boolean validationEnabled;
|
||||||
|
|
||||||
|
public JaxbHelper(boolean validationEnabled) {
|
||||||
|
this.validationEnabled = validationEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValidationEnabled() {
|
||||||
|
return validationEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void withStaxEventReader(InputStream inputStream, ClassLoaderService cls, Consumer<XMLEventReader> action) {
|
||||||
|
final XMLEventReader reader = createReader( inputStream, cls );
|
||||||
|
action.accept( reader );
|
||||||
|
try {
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
|
catch (XMLStreamException ignore) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static XMLEventReader createReader(InputStream stream, ClassLoaderService cls) {
|
||||||
|
final XMLInputFactory staxFactory = XMLInputFactory.newInstance();
|
||||||
|
staxFactory.setXMLResolver( new LocalXmlResourceResolver( cls ) );
|
||||||
|
|
||||||
|
try {
|
||||||
|
// create a standard StAX reader
|
||||||
|
final XMLEventReader staxReader = staxFactory.createXMLEventReader( stream );
|
||||||
|
// and wrap it in a buffered reader (keeping 100 element sized buffer)
|
||||||
|
return new BufferedXMLEventReader( staxReader, 100 );
|
||||||
|
}
|
||||||
|
catch (XMLStreamException e) {
|
||||||
|
throw new RuntimeException( "Unable to create StAX reader", e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
<T> T jaxb(XMLEventReader reader, Schema xsd, JAXBContext jaxbContext) throws JAXBException {
|
||||||
|
final ContextProvidingValidationEventHandler handler = new ContextProvidingValidationEventHandler();
|
||||||
|
|
||||||
|
final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
||||||
|
unmarshaller.setEventHandler( handler );
|
||||||
|
|
||||||
|
if ( isValidationEnabled() ) {
|
||||||
|
unmarshaller.setSchema( xsd );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
unmarshaller.setSchema( null );
|
||||||
|
}
|
||||||
|
|
||||||
|
return (T) unmarshaller.unmarshal( reader );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* 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.orm.test.boot.jaxb.mapping;
|
||||||
|
|
||||||
|
import org.hibernate.boot.jaxb.Origin;
|
||||||
|
import org.hibernate.boot.jaxb.SourceType;
|
||||||
|
import org.hibernate.boot.jaxb.internal.MappingBinder;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbEntity;
|
||||||
|
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
|
||||||
|
import org.hibernate.boot.jaxb.spi.Binding;
|
||||||
|
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
|
|
||||||
|
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
@ServiceRegistry
|
||||||
|
public class PartialJaxbTests {
|
||||||
|
@Test
|
||||||
|
public void cachingTest(ServiceRegistryScope scope) {
|
||||||
|
final MappingBinder mappingBinder = new MappingBinder( scope.getRegistry() );
|
||||||
|
scope.withService( ClassLoaderService.class, (cls) -> {
|
||||||
|
//noinspection unchecked
|
||||||
|
final Binding<JaxbEntityMappings> binding = mappingBinder.bind(
|
||||||
|
cls.locateResourceStream( "xml/jaxb/mapping/partial/caching.xml" ),
|
||||||
|
new Origin( SourceType.RESOURCE, "xml/jaxb/mapping/partial/caching.xml" )
|
||||||
|
);
|
||||||
|
|
||||||
|
final JaxbEntityMappings entityMappings = binding.getRoot();
|
||||||
|
assertThat( entityMappings ).isNotNull();
|
||||||
|
assertThat( entityMappings.getEntities() ).hasSize( 1 );
|
||||||
|
assertThat( entityMappings.getPackage() ).isEqualTo( "org.hibernate.orm.test.boot.jaxb.mapping" );
|
||||||
|
|
||||||
|
final JaxbEntity ormEntity = entityMappings.getEntities().get( 0 );
|
||||||
|
assertThat( ormEntity.getName() ).isNull();
|
||||||
|
assertThat( ormEntity.getClazz() ).isEqualTo( "SimpleEntity" );
|
||||||
|
assertThat( ormEntity.isCacheable() ).isTrue();
|
||||||
|
assertThat( ormEntity.getCaching() ).isNotNull();
|
||||||
|
assertThat( ormEntity.getCaching().getRegion() ).isEqualTo( "netherworld" );
|
||||||
|
|
||||||
|
assertThat( ormEntity.getAttributes() ).isNull();
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* 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.orm.test.boot.jaxb.mapping;
|
||||||
|
|
||||||
|
import jakarta.persistence.Basic;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table( name = "simple_entity_table" )
|
||||||
|
public class SimpleEntity {
|
||||||
|
@Id
|
||||||
|
private Integer id;
|
||||||
|
@Basic
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private SimpleEntity() {
|
||||||
|
// for Hibernate use
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleEntity(Integer id, String name) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
* 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
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.internal.util.xml;
|
package org.hibernate.orm.test.internal.util.xml;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import java.io.InputStream;
|
||||||
import org.hibernate.boot.jaxb.Origin;
|
import org.hibernate.boot.jaxb.Origin;
|
||||||
import org.hibernate.boot.jaxb.SourceType;
|
import org.hibernate.boot.jaxb.SourceType;
|
||||||
import org.hibernate.boot.jaxb.internal.MappingBinder;
|
import org.hibernate.boot.jaxb.internal.MappingBinder;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappings;
|
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
|
||||||
import org.hibernate.boot.jaxb.spi.Binding;
|
import org.hibernate.boot.jaxb.spi.Binding;
|
||||||
|
|
||||||
import org.hibernate.testing.boot.ClassLoaderServiceTestingImpl;
|
import org.hibernate.testing.boot.ClassLoaderServiceTestingImpl;
|
||||||
|
@ -25,11 +25,11 @@ public final class XMLMappingHelper {
|
||||||
private final MappingBinder binder;
|
private final MappingBinder binder;
|
||||||
|
|
||||||
public XMLMappingHelper() {
|
public XMLMappingHelper() {
|
||||||
binder = new MappingBinder( ClassLoaderServiceTestingImpl.INSTANCE, true );
|
binder = new MappingBinder( ClassLoaderServiceTestingImpl.INSTANCE, MappingBinder.VALIDATING );
|
||||||
}
|
}
|
||||||
|
|
||||||
public JaxbEntityMappings readOrmXmlMappings(String name) throws IOException {
|
public JaxbEntityMappings readOrmXmlMappings(String name) throws IOException {
|
||||||
try (InputStream is = ClassLoaderServiceTestingImpl.INSTANCE.locateResourceStream( name )) {
|
try ( InputStream is = ClassLoaderServiceTestingImpl.INSTANCE.locateResourceStream( name ) ) {
|
||||||
return readOrmXmlMappings( is, name );
|
return readOrmXmlMappings( is, name );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
* 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
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.jpa.jakarta;
|
package org.hibernate.orm.test.jpa.jakarta;
|
||||||
|
|
||||||
|
@ -16,11 +16,11 @@ import javax.xml.transform.stream.StreamSource;
|
||||||
import org.hibernate.boot.jaxb.Origin;
|
import org.hibernate.boot.jaxb.Origin;
|
||||||
import org.hibernate.boot.jaxb.SourceType;
|
import org.hibernate.boot.jaxb.SourceType;
|
||||||
import org.hibernate.boot.jaxb.internal.MappingBinder;
|
import org.hibernate.boot.jaxb.internal.MappingBinder;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntity;
|
import org.hibernate.boot.jaxb.mapping.JaxbEntity;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityListener;
|
import org.hibernate.boot.jaxb.mapping.JaxbEntityListener;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappings;
|
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPersistenceUnitDefaults;
|
import org.hibernate.boot.jaxb.mapping.JaxbPersistenceUnitDefaults;
|
||||||
import org.hibernate.boot.jaxb.mapping.spi.JaxbPersistenceUnitMetadata;
|
import org.hibernate.boot.jaxb.mapping.JaxbPersistenceUnitMetadata;
|
||||||
import org.hibernate.boot.jaxb.spi.Binding;
|
import org.hibernate.boot.jaxb.spi.Binding;
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
import org.hibernate.jpa.boot.internal.ParsedPersistenceXmlDescriptor;
|
import org.hibernate.jpa.boot.internal.ParsedPersistenceXmlDescriptor;
|
||||||
|
@ -40,12 +40,15 @@ public class JakartaXmlSmokeTests {
|
||||||
@Test
|
@Test
|
||||||
public void testLoadingOrmXml(ServiceRegistryScope scope) {
|
public void testLoadingOrmXml(ServiceRegistryScope scope) {
|
||||||
final ClassLoaderService cls = scope.getRegistry().getService( ClassLoaderService.class );
|
final ClassLoaderService cls = scope.getRegistry().getService( ClassLoaderService.class );
|
||||||
final MappingBinder mappingBinder = new MappingBinder( cls, true );
|
final MappingBinder mappingBinder = new MappingBinder( cls, MappingBinder.VALIDATING );
|
||||||
final InputStream inputStream = cls.locateResourceStream( "xml/jakarta/simple/orm.xml" );
|
final InputStream inputStream = cls.locateResourceStream( "xml/jakarta/simple/orm.xml" );
|
||||||
try {
|
try {
|
||||||
final Binding<JaxbEntityMappings> binding = mappingBinder.bind( new StreamSource( inputStream ), new Origin( SourceType.RESOURCE, "xml/jakarta/simple/orm.xml" ) );
|
final Binding<JaxbEntityMappings> binding = mappingBinder.bind( new StreamSource( inputStream ), new Origin( SourceType.RESOURCE, "xml/jakarta/simple/orm.xml" ) );
|
||||||
|
|
||||||
assertThat( binding.getRoot().getEntity().stream().map( JaxbEntity::getClazz ) ).containsOnly( "Lighter", "ApplicationServer" );
|
assertThat( binding.getRoot()
|
||||||
|
.getEntities()
|
||||||
|
.stream()
|
||||||
|
.map( JaxbEntity::getClazz ) ).containsOnly( "Lighter", "ApplicationServer" );
|
||||||
|
|
||||||
final JaxbPersistenceUnitMetadata puMetadata = binding.getRoot().getPersistenceUnitMetadata();
|
final JaxbPersistenceUnitMetadata puMetadata = binding.getRoot().getPersistenceUnitMetadata();
|
||||||
final JaxbPersistenceUnitDefaults puDefaults = puMetadata.getPersistenceUnitDefaults();
|
final JaxbPersistenceUnitDefaults puDefaults = puMetadata.getPersistenceUnitDefaults();
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
<hibernate-mapping xmlns="http://www.hibernate.org/xsd/orm/hbm" package="org.hibernate.orm.test.boot.jaxb.mapping">
|
||||||
|
<class name="SimpleEntity" >
|
||||||
|
<id/>
|
||||||
|
<property name="name"/>
|
||||||
|
</class>
|
||||||
|
</hibernate-mapping>
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
<entity-mappings xmlns="https://jakarta.ee/xml/ns/persistence/orm" version="3.1">
|
||||||
|
<package>org.hibernate.orm.test.boot.jaxb.mapping</package>
|
||||||
|
<entity class="SimpleEntity" access="FIELD" metadata-complete="true">
|
||||||
|
<attributes>
|
||||||
|
<id name="id"/>
|
||||||
|
<basic name="name"/>
|
||||||
|
</attributes>
|
||||||
|
</entity>
|
||||||
|
</entity-mappings>
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
<entity-mappings xmlns="http://www.hibernate.org/xsd/orm/mapping" version="3.1">
|
||||||
|
<package>org.hibernate.orm.test.boot.jaxb.mapping</package>
|
||||||
|
<entity class="SimpleEntity" access="FIELD" metadata-complete="true">
|
||||||
|
<attributes>
|
||||||
|
<id name="id"/>
|
||||||
|
<basic name="name"/>
|
||||||
|
</attributes>
|
||||||
|
</entity>
|
||||||
|
</entity-mappings>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue