mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-20 01:55:02 +00:00
HHH-7452 mix SchemaAware interface into orm.xml binding
This commit is contained in:
parent
3806705b82
commit
6ed7e9ee7f
@ -92,7 +92,7 @@ task jaxb {
|
||||
destdir: '${jaxbTargetDir}',
|
||||
package: 'org.hibernate.internal.jaxb.mapping.hbm',
|
||||
binding: hbmXjb.path,
|
||||
schema: hbmXsd.path,
|
||||
schema: hbmXsd.path,
|
||||
extension: 'true'
|
||||
) {
|
||||
arg line: '-Xinheritance -Xsimplify'
|
||||
@ -103,8 +103,11 @@ task jaxb {
|
||||
destdir: '${jaxbTargetDir}',
|
||||
package: 'org.hibernate.internal.jaxb.mapping.orm',
|
||||
binding: 'src/main/xjb/orm-bindings.xjb',
|
||||
schema: ormXsd.path
|
||||
)
|
||||
schema: ormXsd.path,
|
||||
extension: 'true'
|
||||
) {
|
||||
arg line: '-Xinheritance'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -73,10 +73,7 @@ protected AnnotationInstance parserJoinTable(JaxbJoinTable joinTable, Annotation
|
||||
if ( joinTable == null ) {
|
||||
return null;
|
||||
}
|
||||
DefaultConfigurationHelper.INSTANCE.applyDefaults(
|
||||
new SchemaAware.JoinTableSchemaAware( joinTable ),
|
||||
getDefaults()
|
||||
);
|
||||
DefaultConfigurationHelper.INSTANCE.applyDefaults(joinTable,getDefaults());
|
||||
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
|
||||
MockHelper.stringValue( "name", joinTable.getName(), annotationValueList );
|
||||
MockHelper.stringValue( "catalog", joinTable.getCatalog(), annotationValueList );
|
||||
@ -383,10 +380,7 @@ protected AnnotationInstance parserCollectionTable(JaxbCollectionTable collectio
|
||||
if ( collectionTable == null ) {
|
||||
return null;
|
||||
}
|
||||
DefaultConfigurationHelper.INSTANCE.applyDefaults(
|
||||
new SchemaAware.CollectionTableSchemaAware( collectionTable ),
|
||||
getDefaults()
|
||||
);
|
||||
DefaultConfigurationHelper.INSTANCE.applyDefaults(collectionTable,getDefaults());
|
||||
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
|
||||
MockHelper.stringValue( "name", collectionTable.getName(), annotationValueList );
|
||||
MockHelper.stringValue( "catalog", collectionTable.getCatalog(), annotationValueList );
|
||||
|
@ -114,10 +114,7 @@ private AnnotationInstance parserTable(JaxbTable table) {
|
||||
if ( table == null ) {
|
||||
return null;
|
||||
}
|
||||
DefaultConfigurationHelper.INSTANCE.applyDefaults(
|
||||
new SchemaAware.TableSchemaAware( table ),
|
||||
getDefaults()
|
||||
);
|
||||
DefaultConfigurationHelper.INSTANCE.applyDefaults(table,getDefaults());
|
||||
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
|
||||
MockHelper.stringValue( "name", table.getName(), annotationValueList );
|
||||
MockHelper.stringValue( "catalog", table.getCatalog(), annotationValueList );
|
||||
@ -266,10 +263,7 @@ protected AnnotationInstance parserSecondaryTable(JaxbSecondaryTable secondaryTa
|
||||
if ( secondaryTable == null ) {
|
||||
return null;
|
||||
}
|
||||
DefaultConfigurationHelper.INSTANCE.applyDefaults(
|
||||
new SchemaAware.SecondaryTableSchemaAware( secondaryTable ),
|
||||
getDefaults()
|
||||
);
|
||||
DefaultConfigurationHelper.INSTANCE.applyDefaults(secondaryTable,getDefaults());
|
||||
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
|
||||
MockHelper.stringValue( "name", secondaryTable.getName(), annotationValueList );
|
||||
MockHelper.stringValue( "catalog", secondaryTable.getCatalog(), annotationValueList );
|
||||
|
@ -31,7 +31,7 @@
|
||||
/**
|
||||
* @author Strong Liu
|
||||
*/
|
||||
interface SchemaAware {
|
||||
public interface SchemaAware {
|
||||
String getSchema();
|
||||
|
||||
void setSchema(String schema);
|
||||
@ -39,116 +39,4 @@ interface SchemaAware {
|
||||
String getCatalog();
|
||||
|
||||
void setCatalog(String catalog);
|
||||
|
||||
static class SecondaryTableSchemaAware implements SchemaAware {
|
||||
private JaxbSecondaryTable table;
|
||||
|
||||
SecondaryTableSchemaAware(JaxbSecondaryTable table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCatalog() {
|
||||
return table.getCatalog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchema() {
|
||||
return table.getSchema();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSchema(String schema) {
|
||||
table.setSchema( schema );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCatalog(String catalog) {
|
||||
table.setCatalog( catalog );
|
||||
}
|
||||
}
|
||||
|
||||
static class TableSchemaAware implements SchemaAware {
|
||||
private JaxbTable table;
|
||||
|
||||
public TableSchemaAware(JaxbTable table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCatalog() {
|
||||
return table.getCatalog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchema() {
|
||||
return table.getSchema();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSchema(String schema) {
|
||||
table.setSchema( schema );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCatalog(String catalog) {
|
||||
table.setCatalog( catalog );
|
||||
}
|
||||
}
|
||||
|
||||
static class JoinTableSchemaAware implements SchemaAware {
|
||||
private JaxbJoinTable table;
|
||||
|
||||
public JoinTableSchemaAware(JaxbJoinTable table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCatalog() {
|
||||
return table.getCatalog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchema() {
|
||||
return table.getSchema();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSchema(String schema) {
|
||||
table.setSchema( schema );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCatalog(String catalog) {
|
||||
table.setCatalog( catalog );
|
||||
}
|
||||
}
|
||||
|
||||
static class CollectionTableSchemaAware implements SchemaAware {
|
||||
private JaxbCollectionTable table;
|
||||
|
||||
public CollectionTableSchemaAware(JaxbCollectionTable table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCatalog() {
|
||||
return table.getCatalog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchema() {
|
||||
return table.getSchema();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSchema(String schema) {
|
||||
table.setSchema( schema );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCatalog(String catalog) {
|
||||
table.setCatalog( catalog );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"
|
||||
jaxb:extensionBindingPrefixes="inheritance"
|
||||
version="2.1">
|
||||
|
||||
<jaxb:bindings schemaLocation="../resources/org/hibernate/ejb/orm_2_0.xsd" node="/xsd:schema">
|
||||
@ -13,6 +15,18 @@
|
||||
<jaxb:anonymousTypeName prefix="Jaxb"/>
|
||||
</jaxb:nameXmlTransform>
|
||||
</jaxb:schemaBindings>
|
||||
<jaxb:bindings node="//xsd:complexType[@name='secondary-table']">
|
||||
<inheritance:implements>org.hibernate.metamodel.internal.source.annotations.xml.mocker.SchemaAware</inheritance:implements>
|
||||
</jaxb:bindings>
|
||||
<jaxb:bindings node="//xsd:complexType[@name='table']">
|
||||
<inheritance:implements>org.hibernate.metamodel.internal.source.annotations.xml.mocker.SchemaAware</inheritance:implements>
|
||||
</jaxb:bindings>
|
||||
<jaxb:bindings node="//xsd:complexType[@name='join-table']">
|
||||
<inheritance:implements>org.hibernate.metamodel.internal.source.annotations.xml.mocker.SchemaAware</inheritance:implements>
|
||||
</jaxb:bindings>
|
||||
<jaxb:bindings node="//xsd:complexType[@name='collection-table']">
|
||||
<inheritance:implements>org.hibernate.metamodel.internal.source.annotations.xml.mocker.SchemaAware</inheritance:implements>
|
||||
</jaxb:bindings>
|
||||
</jaxb:bindings>
|
||||
|
||||
</jaxb:bindings>
|
@ -54,8 +54,7 @@ public void applyDefaultToEntity() {
|
||||
assertNull( entity.getTable().getCatalog() );
|
||||
assertTrue( entity.isMetadataComplete() );
|
||||
assertEquals( "org.test.Entity", entity.getClazz() );
|
||||
DefaultConfigurationHelper.INSTANCE
|
||||
.applyDefaults( new SchemaAware.TableSchemaAware( entity.getTable() ), defaults );
|
||||
DefaultConfigurationHelper.INSTANCE.applyDefaults( entity.getTable(), defaults );
|
||||
assertEquals( "schema", entity.getTable().getSchema() );
|
||||
assertNull( entity.getTable().getCatalog() );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user