get rid of things named Ejb3
This commit is contained in:
parent
ef4b2732d3
commit
80b5c1e085
|
@ -42,9 +42,9 @@ import org.jboss.logging.Logger;
|
||||||
*
|
*
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
*/
|
*/
|
||||||
public class Ejb3Column {
|
public class AnnotatedColumn {
|
||||||
|
|
||||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, Ejb3Column.class.getName());
|
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, AnnotatedColumn.class.getName());
|
||||||
|
|
||||||
private MetadataBuildingContext context;
|
private MetadataBuildingContext context;
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ public class Ejb3Column {
|
||||||
this.generatedAs = as;
|
this.generatedAs = as;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ejb3Column() {
|
public AnnotatedColumn() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bind() {
|
public void bind() {
|
||||||
|
@ -502,7 +502,7 @@ public class Ejb3Column {
|
||||||
mappingColumn.setNullable( false );
|
mappingColumn.setNullable( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Ejb3Column[] buildColumnFromAnnotation(
|
public static AnnotatedColumn[] buildColumnFromAnnotation(
|
||||||
jakarta.persistence.Column[] anns,
|
jakarta.persistence.Column[] anns,
|
||||||
org.hibernate.annotations.Formula formulaAnn,
|
org.hibernate.annotations.Formula formulaAnn,
|
||||||
Comment commentAnn,
|
Comment commentAnn,
|
||||||
|
@ -523,7 +523,7 @@ public class Ejb3Column {
|
||||||
context
|
context
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
public static Ejb3Column[] buildColumnFromAnnotation(
|
public static AnnotatedColumn[] buildColumnFromAnnotation(
|
||||||
jakarta.persistence.Column[] anns,
|
jakarta.persistence.Column[] anns,
|
||||||
org.hibernate.annotations.Formula formulaAnn,
|
org.hibernate.annotations.Formula formulaAnn,
|
||||||
Comment commentAnn,
|
Comment commentAnn,
|
||||||
|
@ -533,15 +533,15 @@ public class Ejb3Column {
|
||||||
String suffixForDefaultColumnName,
|
String suffixForDefaultColumnName,
|
||||||
Map<String, Join> secondaryTables,
|
Map<String, Join> secondaryTables,
|
||||||
MetadataBuildingContext context) {
|
MetadataBuildingContext context) {
|
||||||
Ejb3Column[] columns;
|
AnnotatedColumn[] columns;
|
||||||
if ( formulaAnn != null ) {
|
if ( formulaAnn != null ) {
|
||||||
Ejb3Column formulaColumn = new Ejb3Column();
|
AnnotatedColumn formulaColumn = new AnnotatedColumn();
|
||||||
formulaColumn.setFormula( formulaAnn.value() );
|
formulaColumn.setFormula( formulaAnn.value() );
|
||||||
formulaColumn.setImplicit( false );
|
formulaColumn.setImplicit( false );
|
||||||
formulaColumn.setBuildingContext( context );
|
formulaColumn.setBuildingContext( context );
|
||||||
formulaColumn.setPropertyHolder( propertyHolder );
|
formulaColumn.setPropertyHolder( propertyHolder );
|
||||||
formulaColumn.bind();
|
formulaColumn.bind();
|
||||||
columns = new Ejb3Column[] { formulaColumn };
|
columns = new AnnotatedColumn[] { formulaColumn };
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
jakarta.persistence.Column[] actualCols = anns;
|
jakarta.persistence.Column[] actualCols = anns;
|
||||||
|
@ -569,7 +569,7 @@ public class Ejb3Column {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final int length = actualCols.length;
|
final int length = actualCols.length;
|
||||||
columns = new Ejb3Column[length];
|
columns = new AnnotatedColumn[length];
|
||||||
for (int index = 0; index < length; index++) {
|
for (int index = 0; index < length; index++) {
|
||||||
|
|
||||||
final ObjectNameNormalizer normalizer = context.getObjectNameNormalizer();
|
final ObjectNameNormalizer normalizer = context.getObjectNameNormalizer();
|
||||||
|
@ -613,7 +613,7 @@ public class Ejb3Column {
|
||||||
.render();
|
.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ejb3Column column = new Ejb3Column();
|
AnnotatedColumn column = new AnnotatedColumn();
|
||||||
|
|
||||||
column.setImplicit( false );
|
column.setImplicit( false );
|
||||||
column.setSqlType( sqlType );
|
column.setSqlType( sqlType );
|
||||||
|
@ -723,7 +723,7 @@ public class Ejb3Column {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Ejb3Column[] buildImplicitColumn(
|
private static AnnotatedColumn[] buildImplicitColumn(
|
||||||
PropertyData inferredData,
|
PropertyData inferredData,
|
||||||
String suffixForDefaultColumnName,
|
String suffixForDefaultColumnName,
|
||||||
Map<String, Join> secondaryTables,
|
Map<String, Join> secondaryTables,
|
||||||
|
@ -731,8 +731,8 @@ public class Ejb3Column {
|
||||||
Comment comment,
|
Comment comment,
|
||||||
Nullability nullability,
|
Nullability nullability,
|
||||||
MetadataBuildingContext context) {
|
MetadataBuildingContext context) {
|
||||||
Ejb3Column column = new Ejb3Column();
|
AnnotatedColumn column = new AnnotatedColumn();
|
||||||
Ejb3Column[] columns = new Ejb3Column[1];
|
AnnotatedColumn[] columns = new AnnotatedColumn[1];
|
||||||
columns[0] = column;
|
columns[0] = column;
|
||||||
|
|
||||||
if ( comment != null ) {
|
if ( comment != null ) {
|
||||||
|
@ -767,7 +767,7 @@ public class Ejb3Column {
|
||||||
return columns;
|
return columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkPropertyConsistency(Ejb3Column[] columns, String propertyName) {
|
public static void checkPropertyConsistency(AnnotatedColumn[] columns, String propertyName) {
|
||||||
int nbrOfColumns = columns.length;
|
int nbrOfColumns = columns.length;
|
||||||
|
|
||||||
if ( nbrOfColumns > 1 ) {
|
if ( nbrOfColumns > 1 ) {
|
|
@ -17,14 +17,14 @@ import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
*
|
*
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
*/
|
*/
|
||||||
public class Ejb3DiscriminatorColumn extends Ejb3Column {
|
public class AnnotatedDiscriminatorColumn extends AnnotatedColumn {
|
||||||
public static final String DEFAULT_DISCRIMINATOR_COLUMN_NAME = "DTYPE";
|
public static final String DEFAULT_DISCRIMINATOR_COLUMN_NAME = "DTYPE";
|
||||||
public static final String DEFAULT_DISCRIMINATOR_TYPE = "string";
|
public static final String DEFAULT_DISCRIMINATOR_TYPE = "string";
|
||||||
private static final long DEFAULT_DISCRIMINATOR_LENGTH = 31;
|
private static final long DEFAULT_DISCRIMINATOR_LENGTH = 31;
|
||||||
|
|
||||||
private String discriminatorTypeName;
|
private String discriminatorTypeName;
|
||||||
|
|
||||||
public Ejb3DiscriminatorColumn() {
|
public AnnotatedDiscriminatorColumn() {
|
||||||
//discriminator default value
|
//discriminator default value
|
||||||
super();
|
super();
|
||||||
setLogicalColumnName( DEFAULT_DISCRIMINATOR_COLUMN_NAME );
|
setLogicalColumnName( DEFAULT_DISCRIMINATOR_COLUMN_NAME );
|
||||||
|
@ -41,11 +41,11 @@ public class Ejb3DiscriminatorColumn extends Ejb3Column {
|
||||||
this.discriminatorTypeName = discriminatorTypeName;
|
this.discriminatorTypeName = discriminatorTypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Ejb3DiscriminatorColumn buildDiscriminatorColumn(
|
public static AnnotatedDiscriminatorColumn buildDiscriminatorColumn(
|
||||||
DiscriminatorType type, DiscriminatorColumn discAnn,
|
DiscriminatorType type, DiscriminatorColumn discAnn,
|
||||||
DiscriminatorFormula discFormulaAnn,
|
DiscriminatorFormula discFormulaAnn,
|
||||||
MetadataBuildingContext context) {
|
MetadataBuildingContext context) {
|
||||||
Ejb3DiscriminatorColumn discriminatorColumn = new Ejb3DiscriminatorColumn();
|
AnnotatedDiscriminatorColumn discriminatorColumn = new AnnotatedDiscriminatorColumn();
|
||||||
discriminatorColumn.setBuildingContext( context );
|
discriminatorColumn.setBuildingContext( context );
|
||||||
discriminatorColumn.setImplicit( true );
|
discriminatorColumn.setImplicit( true );
|
||||||
if ( discFormulaAnn != null ) {
|
if ( discFormulaAnn != null ) {
|
|
@ -47,7 +47,7 @@ import org.hibernate.mapping.Value;
|
||||||
*
|
*
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
*/
|
*/
|
||||||
public class Ejb3JoinColumn extends Ejb3Column {
|
public class AnnotatedJoinColumn extends AnnotatedColumn {
|
||||||
/**
|
/**
|
||||||
* property name related to this column
|
* property name related to this column
|
||||||
*/
|
*/
|
||||||
|
@ -89,13 +89,13 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Due to @AnnotationOverride overriding rules, I don't want the constructor to be public
|
//Due to @AnnotationOverride overriding rules, I don't want the constructor to be public
|
||||||
private Ejb3JoinColumn() {
|
private AnnotatedJoinColumn() {
|
||||||
setMappedBy( BinderHelper.ANNOTATION_STRING_DEFAULT );
|
setMappedBy( BinderHelper.ANNOTATION_STRING_DEFAULT );
|
||||||
}
|
}
|
||||||
|
|
||||||
//Due to @AnnotationOverride overriding rules, I don't want the constructor to be public
|
//Due to @AnnotationOverride overriding rules, I don't want the constructor to be public
|
||||||
//TODO get rid of it and use setters
|
//TODO get rid of it and use setters
|
||||||
private Ejb3JoinColumn(
|
private AnnotatedJoinColumn(
|
||||||
String sqlType,
|
String sqlType,
|
||||||
String name,
|
String name,
|
||||||
String comment,
|
String comment,
|
||||||
|
@ -134,14 +134,14 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
return referencedColumn;
|
return referencedColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Ejb3JoinColumn[] buildJoinColumnsOrFormulas(
|
public static AnnotatedJoinColumn[] buildJoinColumnsOrFormulas(
|
||||||
JoinColumnOrFormula[] anns,
|
JoinColumnOrFormula[] anns,
|
||||||
String mappedBy,
|
String mappedBy,
|
||||||
Map<String, Join> joins,
|
Map<String, Join> joins,
|
||||||
PropertyHolder propertyHolder,
|
PropertyHolder propertyHolder,
|
||||||
String propertyName,
|
String propertyName,
|
||||||
MetadataBuildingContext buildingContext) {
|
MetadataBuildingContext buildingContext) {
|
||||||
Ejb3JoinColumn [] joinColumns = new Ejb3JoinColumn[anns.length];
|
AnnotatedJoinColumn[] joinColumns = new AnnotatedJoinColumn[anns.length];
|
||||||
for (int i = 0; i < anns.length; i++) {
|
for (int i = 0; i < anns.length; i++) {
|
||||||
JoinColumnOrFormula join = anns[i];
|
JoinColumnOrFormula join = anns[i];
|
||||||
JoinFormula formula = join.formula();
|
JoinFormula formula = join.formula();
|
||||||
|
@ -163,14 +163,14 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
/**
|
/**
|
||||||
* build join formula
|
* build join formula
|
||||||
*/
|
*/
|
||||||
public static Ejb3JoinColumn buildJoinFormula(
|
public static AnnotatedJoinColumn buildJoinFormula(
|
||||||
JoinFormula ann,
|
JoinFormula ann,
|
||||||
String mappedBy,
|
String mappedBy,
|
||||||
Map<String, Join> joins,
|
Map<String, Join> joins,
|
||||||
PropertyHolder propertyHolder,
|
PropertyHolder propertyHolder,
|
||||||
String propertyName,
|
String propertyName,
|
||||||
MetadataBuildingContext buildingContext) {
|
MetadataBuildingContext buildingContext) {
|
||||||
Ejb3JoinColumn formulaColumn = new Ejb3JoinColumn();
|
AnnotatedJoinColumn formulaColumn = new AnnotatedJoinColumn();
|
||||||
formulaColumn.setFormula( ann.value() );
|
formulaColumn.setFormula( ann.value() );
|
||||||
formulaColumn.setReferencedColumn(ann.referencedColumnName());
|
formulaColumn.setReferencedColumn(ann.referencedColumnName());
|
||||||
formulaColumn.setBuildingContext( buildingContext );
|
formulaColumn.setBuildingContext( buildingContext );
|
||||||
|
@ -181,7 +181,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
return formulaColumn;
|
return formulaColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Ejb3JoinColumn[] buildJoinColumns(
|
public static AnnotatedJoinColumn[] buildJoinColumns(
|
||||||
JoinColumn[] anns,
|
JoinColumn[] anns,
|
||||||
Comment comment,
|
Comment comment,
|
||||||
String mappedBy,
|
String mappedBy,
|
||||||
|
@ -194,7 +194,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Ejb3JoinColumn[] buildJoinColumnsWithDefaultColumnSuffix(
|
public static AnnotatedJoinColumn[] buildJoinColumnsWithDefaultColumnSuffix(
|
||||||
JoinColumn[] anns,
|
JoinColumn[] anns,
|
||||||
Comment comment,
|
Comment comment,
|
||||||
String mappedBy,
|
String mappedBy,
|
||||||
|
@ -208,7 +208,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
);
|
);
|
||||||
if ( actualColumns == null ) actualColumns = anns;
|
if ( actualColumns == null ) actualColumns = anns;
|
||||||
if ( actualColumns == null || actualColumns.length == 0 ) {
|
if ( actualColumns == null || actualColumns.length == 0 ) {
|
||||||
return new Ejb3JoinColumn[] {
|
return new AnnotatedJoinColumn[] {
|
||||||
buildJoinColumn(
|
buildJoinColumn(
|
||||||
null,
|
null,
|
||||||
comment,
|
comment,
|
||||||
|
@ -223,7 +223,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int size = actualColumns.length;
|
int size = actualColumns.length;
|
||||||
Ejb3JoinColumn[] result = new Ejb3JoinColumn[size];
|
AnnotatedJoinColumn[] result = new AnnotatedJoinColumn[size];
|
||||||
for (int index = 0; index < size; index++) {
|
for (int index = 0; index < size; index++) {
|
||||||
result[index] = buildJoinColumn(
|
result[index] = buildJoinColumn(
|
||||||
actualColumns[index],
|
actualColumns[index],
|
||||||
|
@ -243,7 +243,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
/**
|
/**
|
||||||
* build join column for SecondaryTables
|
* build join column for SecondaryTables
|
||||||
*/
|
*/
|
||||||
private static Ejb3JoinColumn buildJoinColumn(
|
private static AnnotatedJoinColumn buildJoinColumn(
|
||||||
JoinColumn ann,
|
JoinColumn ann,
|
||||||
Comment comment,
|
Comment comment,
|
||||||
String mappedBy, Map<String, Join> joins,
|
String mappedBy, Map<String, Join> joins,
|
||||||
|
@ -258,7 +258,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
+ BinderHelper.getRelativePath( propertyHolder, propertyName )
|
+ BinderHelper.getRelativePath( propertyHolder, propertyName )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Ejb3JoinColumn joinColumn = new Ejb3JoinColumn();
|
AnnotatedJoinColumn joinColumn = new AnnotatedJoinColumn();
|
||||||
joinColumn.setComment( comment != null ? comment.value() : null );
|
joinColumn.setComment( comment != null ? comment.value() : null );
|
||||||
joinColumn.setBuildingContext( buildingContext );
|
joinColumn.setBuildingContext( buildingContext );
|
||||||
joinColumn.setJoinAnnotation( ann, null );
|
joinColumn.setJoinAnnotation( ann, null );
|
||||||
|
@ -274,7 +274,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
return joinColumn;
|
return joinColumn;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Ejb3JoinColumn joinColumn = new Ejb3JoinColumn();
|
AnnotatedJoinColumn joinColumn = new AnnotatedJoinColumn();
|
||||||
joinColumn.setMappedBy( mappedBy );
|
joinColumn.setMappedBy( mappedBy );
|
||||||
joinColumn.setJoins( joins );
|
joinColumn.setJoins( joins );
|
||||||
joinColumn.setPropertyHolder( propertyHolder );
|
joinColumn.setPropertyHolder( propertyHolder );
|
||||||
|
@ -335,7 +335,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
/**
|
/**
|
||||||
* Build JoinColumn for a JOINED hierarchy
|
* Build JoinColumn for a JOINED hierarchy
|
||||||
*/
|
*/
|
||||||
public static Ejb3JoinColumn buildJoinColumn(
|
public static AnnotatedJoinColumn buildJoinColumn(
|
||||||
PrimaryKeyJoinColumn pkJoinAnn,
|
PrimaryKeyJoinColumn pkJoinAnn,
|
||||||
JoinColumn joinAnn,
|
JoinColumn joinAnn,
|
||||||
Value identifier,
|
Value identifier,
|
||||||
|
@ -381,7 +381,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
else {
|
else {
|
||||||
name = context.getObjectNameNormalizer().normalizeIdentifierQuotingAsString( colName );
|
name = context.getObjectNameNormalizer().normalizeIdentifierQuotingAsString( colName );
|
||||||
}
|
}
|
||||||
return new Ejb3JoinColumn(
|
return new AnnotatedJoinColumn(
|
||||||
sqlType,
|
sqlType,
|
||||||
name,
|
name,
|
||||||
null,
|
null,
|
||||||
|
@ -401,7 +401,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
defaultName = context.getObjectNameNormalizer().normalizeIdentifierQuotingAsString( defaultName );
|
defaultName = context.getObjectNameNormalizer().normalizeIdentifierQuotingAsString( defaultName );
|
||||||
return new Ejb3JoinColumn(
|
return new AnnotatedJoinColumn(
|
||||||
null,
|
null,
|
||||||
defaultName,
|
defaultName,
|
||||||
null,
|
null,
|
||||||
|
@ -439,7 +439,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkIfJoinColumn(Object columns, PropertyHolder holder, PropertyData property) {
|
public static void checkIfJoinColumn(Object columns, PropertyHolder holder, PropertyData property) {
|
||||||
if ( !( columns instanceof Ejb3JoinColumn[] ) ) {
|
if ( !( columns instanceof AnnotatedJoinColumn[] ) ) {
|
||||||
throw new AnnotationException(
|
throw new AnnotationException(
|
||||||
"@Column cannot be used on an association property: "
|
"@Column cannot be used on an association property: "
|
||||||
+ holder.getEntityName()
|
+ holder.getEntityName()
|
||||||
|
@ -625,7 +625,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MetadataBuildingContext getBuildingContext() {
|
public MetadataBuildingContext getBuildingContext() {
|
||||||
return Ejb3JoinColumn.this.getBuildingContext();
|
return AnnotatedJoinColumn.this.getBuildingContext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -705,7 +705,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MetadataBuildingContext getBuildingContext() {
|
public MetadataBuildingContext getBuildingContext() {
|
||||||
return Ejb3JoinColumn.this.getBuildingContext();
|
return AnnotatedJoinColumn.this.getBuildingContext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -731,7 +731,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
new ImplicitPrimaryKeyJoinColumnNameSource() {
|
new ImplicitPrimaryKeyJoinColumnNameSource() {
|
||||||
@Override
|
@Override
|
||||||
public MetadataBuildingContext getBuildingContext() {
|
public MetadataBuildingContext getBuildingContext() {
|
||||||
return Ejb3JoinColumn.this.getBuildingContext();
|
return AnnotatedJoinColumn.this.getBuildingContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -812,7 +812,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
public static final int NON_PK_REFERENCE = 2;
|
public static final int NON_PK_REFERENCE = 2;
|
||||||
|
|
||||||
public static int checkReferencedColumnsType(
|
public static int checkReferencedColumnsType(
|
||||||
Ejb3JoinColumn[] columns,
|
AnnotatedJoinColumn[] columns,
|
||||||
PersistentClass referencedEntity,
|
PersistentClass referencedEntity,
|
||||||
MetadataBuildingContext context) {
|
MetadataBuildingContext context) {
|
||||||
//convenient container to find whether a column is an id one or not
|
//convenient container to find whether a column is an id one or not
|
||||||
|
@ -847,7 +847,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
( (PersistentClass) columnOwner ).getTable() :
|
( (PersistentClass) columnOwner ).getTable() :
|
||||||
( (Join) columnOwner ).getTable();
|
( (Join) columnOwner ).getTable();
|
||||||
//check each referenced column
|
//check each referenced column
|
||||||
for (Ejb3JoinColumn ejb3Column : columns) {
|
for (AnnotatedJoinColumn ejb3Column : columns) {
|
||||||
String logicalReferencedColumnName = ejb3Column.getReferencedColumn();
|
String logicalReferencedColumnName = ejb3Column.getReferencedColumn();
|
||||||
if ( StringHelper.isNotEmpty( logicalReferencedColumnName ) ) {
|
if ( StringHelper.isNotEmpty( logicalReferencedColumnName ) ) {
|
||||||
String referencedColumnName;
|
String referencedColumnName;
|
||||||
|
@ -914,16 +914,16 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
super.redefineColumnName( columnName, null, applyNamingStrategy );
|
super.redefineColumnName( columnName, null, applyNamingStrategy );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Ejb3JoinColumn[] buildJoinTableJoinColumns(
|
public static AnnotatedJoinColumn[] buildJoinTableJoinColumns(
|
||||||
JoinColumn[] annJoins,
|
JoinColumn[] annJoins,
|
||||||
Map<String, Join> secondaryTables,
|
Map<String, Join> secondaryTables,
|
||||||
PropertyHolder propertyHolder,
|
PropertyHolder propertyHolder,
|
||||||
String propertyName,
|
String propertyName,
|
||||||
String mappedBy,
|
String mappedBy,
|
||||||
MetadataBuildingContext buildingContext) {
|
MetadataBuildingContext buildingContext) {
|
||||||
Ejb3JoinColumn[] joinColumns;
|
AnnotatedJoinColumn[] joinColumns;
|
||||||
if ( annJoins == null ) {
|
if ( annJoins == null ) {
|
||||||
Ejb3JoinColumn currentJoinColumn = new Ejb3JoinColumn();
|
AnnotatedJoinColumn currentJoinColumn = new AnnotatedJoinColumn();
|
||||||
currentJoinColumn.setImplicit( true );
|
currentJoinColumn.setImplicit( true );
|
||||||
currentJoinColumn.setNullable( false ); //I break the spec, but it's for good
|
currentJoinColumn.setNullable( false ); //I break the spec, but it's for good
|
||||||
currentJoinColumn.setPropertyHolder( propertyHolder );
|
currentJoinColumn.setPropertyHolder( propertyHolder );
|
||||||
|
@ -935,18 +935,18 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
currentJoinColumn.setMappedBy( mappedBy );
|
currentJoinColumn.setMappedBy( mappedBy );
|
||||||
currentJoinColumn.bind();
|
currentJoinColumn.bind();
|
||||||
|
|
||||||
joinColumns = new Ejb3JoinColumn[] {
|
joinColumns = new AnnotatedJoinColumn[] {
|
||||||
currentJoinColumn
|
currentJoinColumn
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
joinColumns = new Ejb3JoinColumn[annJoins.length];
|
joinColumns = new AnnotatedJoinColumn[annJoins.length];
|
||||||
JoinColumn annJoin;
|
JoinColumn annJoin;
|
||||||
int length = annJoins.length;
|
int length = annJoins.length;
|
||||||
for (int index = 0; index < length; index++) {
|
for (int index = 0; index < length; index++) {
|
||||||
annJoin = annJoins[index];
|
annJoin = annJoins[index];
|
||||||
Ejb3JoinColumn currentJoinColumn = new Ejb3JoinColumn();
|
AnnotatedJoinColumn currentJoinColumn = new AnnotatedJoinColumn();
|
||||||
currentJoinColumn.setImplicit( true );
|
currentJoinColumn.setImplicit( true );
|
||||||
currentJoinColumn.setPropertyHolder( propertyHolder );
|
currentJoinColumn.setPropertyHolder( propertyHolder );
|
||||||
currentJoinColumn.setJoins( secondaryTables );
|
currentJoinColumn.setJoins( secondaryTables );
|
|
@ -601,14 +601,14 @@ public final class AnnotationBinder {
|
||||||
uniqueConstraints = TableBinder.buildUniqueConstraintHolders( tabAnn.uniqueConstraints() );
|
uniqueConstraints = TableBinder.buildUniqueConstraintHolders( tabAnn.uniqueConstraints() );
|
||||||
}
|
}
|
||||||
|
|
||||||
Ejb3JoinColumn[] inheritanceJoinedColumns = makeInheritanceJoinColumns(
|
AnnotatedJoinColumn[] inheritanceJoinedColumns = makeInheritanceJoinColumns(
|
||||||
clazzToProcess,
|
clazzToProcess,
|
||||||
context,
|
context,
|
||||||
inheritanceState,
|
inheritanceState,
|
||||||
superEntity
|
superEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
final Ejb3DiscriminatorColumn discriminatorColumn;
|
final AnnotatedDiscriminatorColumn discriminatorColumn;
|
||||||
if ( InheritanceType.SINGLE_TABLE.equals( inheritanceState.getType() ) ) {
|
if ( InheritanceType.SINGLE_TABLE.equals( inheritanceState.getType() ) ) {
|
||||||
discriminatorColumn = processSingleTableDiscriminatorProperties(
|
discriminatorColumn = processSingleTableDiscriminatorProperties(
|
||||||
clazzToProcess,
|
clazzToProcess,
|
||||||
|
@ -940,14 +940,14 @@ public final class AnnotationBinder {
|
||||||
/**
|
/**
|
||||||
* Process all discriminator-related metadata per rules for "single table" inheritance
|
* Process all discriminator-related metadata per rules for "single table" inheritance
|
||||||
*/
|
*/
|
||||||
private static Ejb3DiscriminatorColumn processSingleTableDiscriminatorProperties(
|
private static AnnotatedDiscriminatorColumn processSingleTableDiscriminatorProperties(
|
||||||
XClass clazzToProcess,
|
XClass clazzToProcess,
|
||||||
MetadataBuildingContext context,
|
MetadataBuildingContext context,
|
||||||
InheritanceState inheritanceState,
|
InheritanceState inheritanceState,
|
||||||
EntityBinder entityBinder) {
|
EntityBinder entityBinder) {
|
||||||
final boolean isRoot = !inheritanceState.hasParents();
|
final boolean isRoot = !inheritanceState.hasParents();
|
||||||
|
|
||||||
Ejb3DiscriminatorColumn discriminatorColumn = null;
|
AnnotatedDiscriminatorColumn discriminatorColumn = null;
|
||||||
jakarta.persistence.DiscriminatorColumn discAnn = clazzToProcess.getAnnotation(
|
jakarta.persistence.DiscriminatorColumn discAnn = clazzToProcess.getAnnotation(
|
||||||
jakarta.persistence.DiscriminatorColumn.class
|
jakarta.persistence.DiscriminatorColumn.class
|
||||||
);
|
);
|
||||||
|
@ -959,7 +959,7 @@ public final class AnnotationBinder {
|
||||||
DiscriminatorFormula.class
|
DiscriminatorFormula.class
|
||||||
);
|
);
|
||||||
if ( isRoot ) {
|
if ( isRoot ) {
|
||||||
discriminatorColumn = Ejb3DiscriminatorColumn.buildDiscriminatorColumn(
|
discriminatorColumn = AnnotatedDiscriminatorColumn.buildDiscriminatorColumn(
|
||||||
discriminatorType,
|
discriminatorType,
|
||||||
discAnn,
|
discAnn,
|
||||||
discFormulaAnn,
|
discFormulaAnn,
|
||||||
|
@ -987,7 +987,7 @@ public final class AnnotationBinder {
|
||||||
/**
|
/**
|
||||||
* Process all discriminator-related metadata per rules for "joined" inheritance
|
* Process all discriminator-related metadata per rules for "joined" inheritance
|
||||||
*/
|
*/
|
||||||
private static Ejb3DiscriminatorColumn processJoinedDiscriminatorProperties(
|
private static AnnotatedDiscriminatorColumn processJoinedDiscriminatorProperties(
|
||||||
XClass clazzToProcess,
|
XClass clazzToProcess,
|
||||||
MetadataBuildingContext context,
|
MetadataBuildingContext context,
|
||||||
InheritanceState inheritanceState,
|
InheritanceState inheritanceState,
|
||||||
|
@ -1042,7 +1042,7 @@ public final class AnnotationBinder {
|
||||||
final DiscriminatorType discriminatorType = discriminatorColumnAnnotation != null
|
final DiscriminatorType discriminatorType = discriminatorColumnAnnotation != null
|
||||||
? discriminatorColumnAnnotation.discriminatorType()
|
? discriminatorColumnAnnotation.discriminatorType()
|
||||||
: DiscriminatorType.STRING;
|
: DiscriminatorType.STRING;
|
||||||
return Ejb3DiscriminatorColumn.buildDiscriminatorColumn(
|
return AnnotatedDiscriminatorColumn.buildDiscriminatorColumn(
|
||||||
discriminatorType,
|
discriminatorType,
|
||||||
discriminatorColumnAnnotation,
|
discriminatorColumnAnnotation,
|
||||||
null,
|
null,
|
||||||
|
@ -1302,12 +1302,12 @@ public final class AnnotationBinder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Ejb3JoinColumn[] makeInheritanceJoinColumns(
|
private static AnnotatedJoinColumn[] makeInheritanceJoinColumns(
|
||||||
XClass clazzToProcess,
|
XClass clazzToProcess,
|
||||||
MetadataBuildingContext context,
|
MetadataBuildingContext context,
|
||||||
InheritanceState inheritanceState,
|
InheritanceState inheritanceState,
|
||||||
PersistentClass superEntity) {
|
PersistentClass superEntity) {
|
||||||
Ejb3JoinColumn[] inheritanceJoinedColumns = null;
|
AnnotatedJoinColumn[] inheritanceJoinedColumns = null;
|
||||||
final boolean hasJoinedColumns = inheritanceState.hasParents()
|
final boolean hasJoinedColumns = inheritanceState.hasParents()
|
||||||
&& InheritanceType.JOINED.equals( inheritanceState.getType() );
|
&& InheritanceType.JOINED.equals( inheritanceState.getType() );
|
||||||
if ( hasJoinedColumns ) {
|
if ( hasJoinedColumns ) {
|
||||||
|
@ -1317,10 +1317,10 @@ public final class AnnotationBinder {
|
||||||
if ( explicitInheritanceJoinedColumns ) {
|
if ( explicitInheritanceJoinedColumns ) {
|
||||||
int nbrOfInhJoinedColumns = jcsAnn.value().length;
|
int nbrOfInhJoinedColumns = jcsAnn.value().length;
|
||||||
PrimaryKeyJoinColumn jcAnn;
|
PrimaryKeyJoinColumn jcAnn;
|
||||||
inheritanceJoinedColumns = new Ejb3JoinColumn[nbrOfInhJoinedColumns];
|
inheritanceJoinedColumns = new AnnotatedJoinColumn[nbrOfInhJoinedColumns];
|
||||||
for ( int colIndex = 0; colIndex < nbrOfInhJoinedColumns; colIndex++ ) {
|
for ( int colIndex = 0; colIndex < nbrOfInhJoinedColumns; colIndex++ ) {
|
||||||
jcAnn = jcsAnn.value()[colIndex];
|
jcAnn = jcsAnn.value()[colIndex];
|
||||||
inheritanceJoinedColumns[colIndex] = Ejb3JoinColumn.buildJoinColumn(
|
inheritanceJoinedColumns[colIndex] = AnnotatedJoinColumn.buildJoinColumn(
|
||||||
jcAnn,
|
jcAnn,
|
||||||
null,
|
null,
|
||||||
superEntity.getIdentifier(),
|
superEntity.getIdentifier(),
|
||||||
|
@ -1332,8 +1332,8 @@ public final class AnnotationBinder {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PrimaryKeyJoinColumn jcAnn = clazzToProcess.getAnnotation( PrimaryKeyJoinColumn.class );
|
PrimaryKeyJoinColumn jcAnn = clazzToProcess.getAnnotation( PrimaryKeyJoinColumn.class );
|
||||||
inheritanceJoinedColumns = new Ejb3JoinColumn[1];
|
inheritanceJoinedColumns = new AnnotatedJoinColumn[1];
|
||||||
inheritanceJoinedColumns[0] = Ejb3JoinColumn.buildJoinColumn(
|
inheritanceJoinedColumns[0] = AnnotatedJoinColumn.buildJoinColumn(
|
||||||
jcAnn,
|
jcAnn,
|
||||||
null,
|
null,
|
||||||
superEntity.getIdentifier(),
|
superEntity.getIdentifier(),
|
||||||
|
@ -1537,7 +1537,7 @@ public final class AnnotationBinder {
|
||||||
|
|
||||||
private static void bindDiscriminatorColumnToRootPersistentClass(
|
private static void bindDiscriminatorColumnToRootPersistentClass(
|
||||||
RootClass rootClass,
|
RootClass rootClass,
|
||||||
Ejb3DiscriminatorColumn discriminatorColumn,
|
AnnotatedDiscriminatorColumn discriminatorColumn,
|
||||||
Map<String, Join> secondaryTables,
|
Map<String, Join> secondaryTables,
|
||||||
PropertyHolder propertyHolder,
|
PropertyHolder propertyHolder,
|
||||||
MetadataBuildingContext context) {
|
MetadataBuildingContext context) {
|
||||||
|
@ -1754,8 +1754,8 @@ public final class AnnotationBinder {
|
||||||
entityBinder,
|
entityBinder,
|
||||||
context
|
context
|
||||||
).extractMetadata();
|
).extractMetadata();
|
||||||
Ejb3Column[] columns = columnsBuilder.getColumns();
|
AnnotatedColumn[] columns = columnsBuilder.getColumns();
|
||||||
Ejb3JoinColumn[] joinColumns = columnsBuilder.getJoinColumns();
|
AnnotatedJoinColumn[] joinColumns = columnsBuilder.getJoinColumns();
|
||||||
|
|
||||||
final XClass returnedClass = inferredData.getClassOrElement();
|
final XClass returnedClass = inferredData.getClassOrElement();
|
||||||
|
|
||||||
|
@ -1859,7 +1859,7 @@ public final class AnnotationBinder {
|
||||||
JoinTable assocTable = propertyHolder.getJoinTable( property );
|
JoinTable assocTable = propertyHolder.getJoinTable( property );
|
||||||
if ( assocTable != null ) {
|
if ( assocTable != null ) {
|
||||||
Join join = propertyHolder.addJoin( assocTable, false );
|
Join join = propertyHolder.addJoin( assocTable, false );
|
||||||
for ( Ejb3JoinColumn joinColumn : joinColumns ) {
|
for ( AnnotatedJoinColumn joinColumn : joinColumns ) {
|
||||||
joinColumn.setExplicitTableName( join.getTable().getName() );
|
joinColumn.setExplicitTableName( join.getTable().getName() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1925,7 +1925,7 @@ public final class AnnotationBinder {
|
||||||
JoinTable assocTable = propertyHolder.getJoinTable( property );
|
JoinTable assocTable = propertyHolder.getJoinTable( property );
|
||||||
if ( assocTable != null ) {
|
if ( assocTable != null ) {
|
||||||
Join join = propertyHolder.addJoin( assocTable, false );
|
Join join = propertyHolder.addJoin( assocTable, false );
|
||||||
for ( Ejb3JoinColumn joinColumn : joinColumns ) {
|
for ( AnnotatedJoinColumn joinColumn : joinColumns ) {
|
||||||
joinColumn.setExplicitTableName( join.getTable().getName() );
|
joinColumn.setExplicitTableName( join.getTable().getName() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1966,7 +1966,7 @@ public final class AnnotationBinder {
|
||||||
JoinTable assocTable = propertyHolder.getJoinTable( property );
|
JoinTable assocTable = propertyHolder.getJoinTable( property );
|
||||||
if ( assocTable != null ) {
|
if ( assocTable != null ) {
|
||||||
Join join = propertyHolder.addJoin( assocTable, false );
|
Join join = propertyHolder.addJoin( assocTable, false );
|
||||||
for ( Ejb3JoinColumn joinColumn : joinColumns ) {
|
for ( AnnotatedJoinColumn joinColumn : joinColumns ) {
|
||||||
joinColumn.setExplicitTableName( join.getTable().getName() );
|
joinColumn.setExplicitTableName( join.getTable().getName() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2050,7 +2050,7 @@ public final class AnnotationBinder {
|
||||||
collectionBinder.setCollectionType( inferredData.getProperty().getElementClass() );
|
collectionBinder.setCollectionType( inferredData.getProperty().getElementClass() );
|
||||||
collectionBinder.setAccessType( inferredData.getDefaultAccess() );
|
collectionBinder.setAccessType( inferredData.getDefaultAccess() );
|
||||||
|
|
||||||
Ejb3Column[] elementColumns;
|
AnnotatedColumn[] elementColumns;
|
||||||
//do not use "element" if you are a JPA 2 @ElementCollection only for legacy Hibernate mappings
|
//do not use "element" if you are a JPA 2 @ElementCollection only for legacy Hibernate mappings
|
||||||
boolean isJPA2ForValueMapping = property.isAnnotationPresent( ElementCollection.class );
|
boolean isJPA2ForValueMapping = property.isAnnotationPresent( ElementCollection.class );
|
||||||
PropertyData virtualProperty = isJPA2ForValueMapping ? inferredData : new WrappedInferredData(
|
PropertyData virtualProperty = isJPA2ForValueMapping ? inferredData : new WrappedInferredData(
|
||||||
|
@ -2061,7 +2061,7 @@ public final class AnnotationBinder {
|
||||||
) ) {
|
) ) {
|
||||||
Column ann = property.getAnnotation( Column.class );
|
Column ann = property.getAnnotation( Column.class );
|
||||||
Formula formulaAnn = property.getAnnotation( Formula.class );
|
Formula formulaAnn = property.getAnnotation( Formula.class );
|
||||||
elementColumns = Ejb3Column.buildColumnFromAnnotation(
|
elementColumns = AnnotatedColumn.buildColumnFromAnnotation(
|
||||||
new Column[] { ann },
|
new Column[] { ann },
|
||||||
formulaAnn,
|
formulaAnn,
|
||||||
property.getAnnotation( Comment.class ),
|
property.getAnnotation( Comment.class ),
|
||||||
|
@ -2074,7 +2074,7 @@ public final class AnnotationBinder {
|
||||||
}
|
}
|
||||||
else if ( property.isAnnotationPresent( Columns.class ) ) {
|
else if ( property.isAnnotationPresent( Columns.class ) ) {
|
||||||
Columns anns = property.getAnnotation( Columns.class );
|
Columns anns = property.getAnnotation( Columns.class );
|
||||||
elementColumns = Ejb3Column.buildColumnFromAnnotation(
|
elementColumns = AnnotatedColumn.buildColumnFromAnnotation(
|
||||||
anns.columns(),
|
anns.columns(),
|
||||||
null,
|
null,
|
||||||
property.getAnnotation( Comment.class ),
|
property.getAnnotation( Comment.class ),
|
||||||
|
@ -2086,7 +2086,7 @@ public final class AnnotationBinder {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
elementColumns = Ejb3Column.buildColumnFromAnnotation(
|
elementColumns = AnnotatedColumn.buildColumnFromAnnotation(
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
property.getAnnotation( Comment.class ),
|
property.getAnnotation( Comment.class ),
|
||||||
|
@ -2106,7 +2106,7 @@ public final class AnnotationBinder {
|
||||||
keyColumns = null;
|
keyColumns = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ejb3Column[] mapColumns = Ejb3Column.buildColumnFromAnnotation(
|
AnnotatedColumn[] mapColumns = AnnotatedColumn.buildColumnFromAnnotation(
|
||||||
keyColumns,
|
keyColumns,
|
||||||
null,
|
null,
|
||||||
property.getAnnotation( Comment.class ),
|
property.getAnnotation( Comment.class ),
|
||||||
|
@ -2147,7 +2147,7 @@ public final class AnnotationBinder {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Ejb3JoinColumn[] mapJoinColumns = Ejb3JoinColumn.buildJoinColumnsWithDefaultColumnSuffix(
|
AnnotatedJoinColumn[] mapJoinColumns = AnnotatedJoinColumn.buildJoinColumnsWithDefaultColumnSuffix(
|
||||||
joinKeyColumns,
|
joinKeyColumns,
|
||||||
property.getAnnotation( Comment.class ),
|
property.getAnnotation( Comment.class ),
|
||||||
null,
|
null,
|
||||||
|
@ -2174,7 +2174,7 @@ public final class AnnotationBinder {
|
||||||
}
|
}
|
||||||
String mappedBy = null;
|
String mappedBy = null;
|
||||||
if ( oneToManyAnn != null ) {
|
if ( oneToManyAnn != null ) {
|
||||||
for ( Ejb3JoinColumn column : joinColumns ) {
|
for ( AnnotatedJoinColumn column : joinColumns ) {
|
||||||
if ( column.isSecondary() ) {
|
if ( column.isSecondary() ) {
|
||||||
throw new NotYetImplementedException( "Collections having FK in secondary table" );
|
throw new NotYetImplementedException( "Collections having FK in secondary table" );
|
||||||
}
|
}
|
||||||
|
@ -2192,7 +2192,7 @@ public final class AnnotationBinder {
|
||||||
collectionBinder.setOneToMany( true );
|
collectionBinder.setOneToMany( true );
|
||||||
}
|
}
|
||||||
else if ( elementCollectionAnn != null ) {
|
else if ( elementCollectionAnn != null ) {
|
||||||
for ( Ejb3JoinColumn column : joinColumns ) {
|
for ( AnnotatedJoinColumn column : joinColumns ) {
|
||||||
if ( column.isSecondary() ) {
|
if ( column.isSecondary() ) {
|
||||||
throw new NotYetImplementedException( "Collections having FK in secondary table" );
|
throw new NotYetImplementedException( "Collections having FK in secondary table" );
|
||||||
}
|
}
|
||||||
|
@ -2318,7 +2318,7 @@ public final class AnnotationBinder {
|
||||||
inheritanceStatePerClass,
|
inheritanceStatePerClass,
|
||||||
referencedEntityName,
|
referencedEntityName,
|
||||||
customInstantiatorImpl,
|
customInstantiatorImpl,
|
||||||
isOverridden ? ( Ejb3JoinColumn[] ) columns : null
|
isOverridden ? ( AnnotatedJoinColumn[] ) columns : null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2333,7 +2333,7 @@ public final class AnnotationBinder {
|
||||||
//implicit type will check basic types and Serializable classes
|
//implicit type will check basic types and Serializable classes
|
||||||
if ( isId || ( !optional && nullability != Nullability.FORCED_NULL ) ) {
|
if ( isId || ( !optional && nullability != Nullability.FORCED_NULL ) ) {
|
||||||
//force columns to not null
|
//force columns to not null
|
||||||
for ( Ejb3Column col : columns ) {
|
for ( AnnotatedColumn col : columns ) {
|
||||||
if ( isId && col.isFormula() ) {
|
if ( isId && col.isFormula() ) {
|
||||||
throw new CannotForceNonNullableException(
|
throw new CannotForceNonNullableException(
|
||||||
String.format(
|
String.format(
|
||||||
|
@ -2418,13 +2418,13 @@ public final class AnnotationBinder {
|
||||||
if ( index != null ) {
|
if ( index != null ) {
|
||||||
if ( joinColumns != null ) {
|
if ( joinColumns != null ) {
|
||||||
|
|
||||||
for ( Ejb3Column column : joinColumns ) {
|
for ( AnnotatedColumn column : joinColumns ) {
|
||||||
column.addIndex( index, inSecondPass );
|
column.addIndex( index, inSecondPass );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( columns != null ) {
|
if ( columns != null ) {
|
||||||
for ( Ejb3Column column : columns ) {
|
for ( AnnotatedColumn column : columns ) {
|
||||||
column.addIndex( index, inSecondPass );
|
column.addIndex( index, inSecondPass );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2438,13 +2438,13 @@ public final class AnnotationBinder {
|
||||||
NaturalId naturalIdAnn = property.getAnnotation( NaturalId.class );
|
NaturalId naturalIdAnn = property.getAnnotation( NaturalId.class );
|
||||||
if ( naturalIdAnn != null ) {
|
if ( naturalIdAnn != null ) {
|
||||||
if ( joinColumns != null ) {
|
if ( joinColumns != null ) {
|
||||||
for ( Ejb3Column column : joinColumns ) {
|
for ( AnnotatedColumn column : joinColumns ) {
|
||||||
String keyName = "UK_" + Constraint.hashedName( column.getTable().getName() + "_NaturalID" );
|
String keyName = "UK_" + Constraint.hashedName( column.getTable().getName() + "_NaturalID" );
|
||||||
column.addUniqueKey( keyName, inSecondPass );
|
column.addUniqueKey( keyName, inSecondPass );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for ( Ejb3Column column : columns ) {
|
for ( AnnotatedColumn column : columns ) {
|
||||||
String keyName = "UK_" + Constraint.hashedName( column.getTable().getName() + "_NaturalID" );
|
String keyName = "UK_" + Constraint.hashedName( column.getTable().getName() + "_NaturalID" );
|
||||||
column.addUniqueKey( keyName, inSecondPass );
|
column.addUniqueKey( keyName, inSecondPass );
|
||||||
}
|
}
|
||||||
|
@ -2666,7 +2666,7 @@ public final class AnnotationBinder {
|
||||||
annJoins = null;
|
annJoins = null;
|
||||||
annInverseJoins = null;
|
annInverseJoins = null;
|
||||||
}
|
}
|
||||||
Ejb3JoinColumn[] joinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
|
AnnotatedJoinColumn[] joinColumns = AnnotatedJoinColumn.buildJoinTableJoinColumns(
|
||||||
annJoins,
|
annJoins,
|
||||||
entityBinder.getSecondaryTables(),
|
entityBinder.getSecondaryTables(),
|
||||||
propertyHolder,
|
propertyHolder,
|
||||||
|
@ -2674,7 +2674,7 @@ public final class AnnotationBinder {
|
||||||
mappedBy,
|
mappedBy,
|
||||||
buildingContext
|
buildingContext
|
||||||
);
|
);
|
||||||
Ejb3JoinColumn[] inverseJoinColumns = Ejb3JoinColumn.buildJoinTableJoinColumns(
|
AnnotatedJoinColumn[] inverseJoinColumns = AnnotatedJoinColumn.buildJoinTableJoinColumns(
|
||||||
annInverseJoins,
|
annInverseJoins,
|
||||||
entityBinder.getSecondaryTables(),
|
entityBinder.getSecondaryTables(),
|
||||||
propertyHolder,
|
propertyHolder,
|
||||||
|
@ -2700,7 +2700,7 @@ public final class AnnotationBinder {
|
||||||
Map<XClass, InheritanceState> inheritanceStatePerClass,
|
Map<XClass, InheritanceState> inheritanceStatePerClass,
|
||||||
String referencedEntityName, //is a component who is overridden by a @MapsId
|
String referencedEntityName, //is a component who is overridden by a @MapsId
|
||||||
Class<? extends EmbeddableInstantiator> customInstantiatorImpl,
|
Class<? extends EmbeddableInstantiator> customInstantiatorImpl,
|
||||||
Ejb3JoinColumn[] columns) {
|
AnnotatedJoinColumn[] columns) {
|
||||||
Component comp;
|
Component comp;
|
||||||
if ( referencedEntityName != null ) {
|
if ( referencedEntityName != null ) {
|
||||||
comp = createComponent( propertyHolder, inferredData, isComponentEmbedded, isIdentifierMapper, customInstantiatorImpl, buildingContext );
|
comp = createComponent( propertyHolder, inferredData, isComponentEmbedded, isIdentifierMapper, customInstantiatorImpl, buildingContext );
|
||||||
|
@ -2967,7 +2967,7 @@ public final class AnnotationBinder {
|
||||||
String generatorName,
|
String generatorName,
|
||||||
PropertyData inferredData,
|
PropertyData inferredData,
|
||||||
PropertyData baseInferredData,
|
PropertyData baseInferredData,
|
||||||
Ejb3Column[] columns,
|
AnnotatedColumn[] columns,
|
||||||
PropertyHolder propertyHolder,
|
PropertyHolder propertyHolder,
|
||||||
boolean isComposite,
|
boolean isComposite,
|
||||||
AccessType propertyAccessor,
|
AccessType propertyAccessor,
|
||||||
|
@ -3020,7 +3020,7 @@ public final class AnnotationBinder {
|
||||||
else {
|
else {
|
||||||
//TODO I think this branch is never used. Remove.
|
//TODO I think this branch is never used. Remove.
|
||||||
|
|
||||||
for ( Ejb3Column column : columns ) {
|
for ( AnnotatedColumn column : columns ) {
|
||||||
column.forceNotNull(); //this is an id
|
column.forceNotNull(); //this is an id
|
||||||
}
|
}
|
||||||
final BasicValueBinder value = new BasicValueBinder( BasicValueBinder.Kind.ATTRIBUTE, buildingContext );
|
final BasicValueBinder value = new BasicValueBinder( BasicValueBinder.Kind.ATTRIBUTE, buildingContext );
|
||||||
|
@ -3100,7 +3100,7 @@ public final class AnnotationBinder {
|
||||||
|
|
||||||
private static void bindManyToOne(
|
private static void bindManyToOne(
|
||||||
String cascadeStrategy,
|
String cascadeStrategy,
|
||||||
Ejb3JoinColumn[] columns,
|
AnnotatedJoinColumn[] columns,
|
||||||
boolean optional,
|
boolean optional,
|
||||||
boolean ignoreNotFound,
|
boolean ignoreNotFound,
|
||||||
boolean cascadeOnDelete,
|
boolean cascadeOnDelete,
|
||||||
|
@ -3126,13 +3126,13 @@ public final class AnnotationBinder {
|
||||||
value.setCascadeDeleteEnabled( cascadeOnDelete );
|
value.setCascadeDeleteEnabled( cascadeOnDelete );
|
||||||
//value.setLazy( fetchMode != FetchMode.JOIN );
|
//value.setLazy( fetchMode != FetchMode.JOIN );
|
||||||
if ( !optional ) {
|
if ( !optional ) {
|
||||||
for ( Ejb3JoinColumn column : columns ) {
|
for ( AnnotatedJoinColumn column : columns ) {
|
||||||
column.setNullable( false );
|
column.setNullable( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( property.isAnnotationPresent( MapsId.class ) ) {
|
if ( property.isAnnotationPresent( MapsId.class ) ) {
|
||||||
//read only
|
//read only
|
||||||
for ( Ejb3JoinColumn column : columns ) {
|
for ( AnnotatedJoinColumn column : columns ) {
|
||||||
column.setInsertable( false );
|
column.setInsertable( false );
|
||||||
column.setUpdatable( false );
|
column.setUpdatable( false );
|
||||||
}
|
}
|
||||||
|
@ -3156,7 +3156,7 @@ public final class AnnotationBinder {
|
||||||
&& joinColumn.name().equals( columnName )
|
&& joinColumn.name().equals( columnName )
|
||||||
&& !property.isAnnotationPresent( MapsId.class ) ) {
|
&& !property.isAnnotationPresent( MapsId.class ) ) {
|
||||||
hasSpecjManyToOne = true;
|
hasSpecjManyToOne = true;
|
||||||
for ( Ejb3JoinColumn column : columns ) {
|
for ( AnnotatedJoinColumn column : columns ) {
|
||||||
column.setInsertable( false );
|
column.setInsertable( false );
|
||||||
column.setUpdatable( false );
|
column.setUpdatable( false );
|
||||||
}
|
}
|
||||||
|
@ -3191,7 +3191,7 @@ public final class AnnotationBinder {
|
||||||
else {
|
else {
|
||||||
context.getMetadataCollector().addSecondPass( secondPass );
|
context.getMetadataCollector().addSecondPass( secondPass );
|
||||||
}
|
}
|
||||||
Ejb3Column.checkPropertyConsistency( columns, propertyHolder.getEntityName() + "." + propertyName );
|
AnnotatedColumn.checkPropertyConsistency( columns, propertyHolder.getEntityName() + "." + propertyName );
|
||||||
//PropertyBinder binder = new PropertyBinder();
|
//PropertyBinder binder = new PropertyBinder();
|
||||||
propertyBinder.setName( propertyName );
|
propertyBinder.setName( propertyName );
|
||||||
propertyBinder.setValue( value );
|
propertyBinder.setValue( value );
|
||||||
|
@ -3272,7 +3272,7 @@ public final class AnnotationBinder {
|
||||||
|
|
||||||
private static void bindOneToOne(
|
private static void bindOneToOne(
|
||||||
String cascadeStrategy,
|
String cascadeStrategy,
|
||||||
Ejb3JoinColumn[] joinColumns,
|
AnnotatedJoinColumn[] joinColumns,
|
||||||
boolean optional,
|
boolean optional,
|
||||||
FetchMode fetchMode,
|
FetchMode fetchMode,
|
||||||
boolean ignoreNotFound,
|
boolean ignoreNotFound,
|
||||||
|
@ -3310,7 +3310,7 @@ public final class AnnotationBinder {
|
||||||
currentColumn = ( org.hibernate.mapping.Column ) idColumns.next();
|
currentColumn = ( org.hibernate.mapping.Column ) idColumns.next();
|
||||||
idColumnNames.add( currentColumn.getName() );
|
idColumnNames.add( currentColumn.getName() );
|
||||||
}
|
}
|
||||||
for ( Ejb3JoinColumn col : joinColumns ) {
|
for ( AnnotatedJoinColumn col : joinColumns ) {
|
||||||
if ( !idColumnNames.contains( col.getMappingColumn().getName() ) ) {
|
if ( !idColumnNames.contains( col.getMappingColumn().getName() ) ) {
|
||||||
mapToPK = false;
|
mapToPK = false;
|
||||||
break;
|
break;
|
||||||
|
@ -3359,7 +3359,7 @@ public final class AnnotationBinder {
|
||||||
|
|
||||||
private static void bindAny(
|
private static void bindAny(
|
||||||
String cascadeStrategy,
|
String cascadeStrategy,
|
||||||
Ejb3JoinColumn[] columns,
|
AnnotatedJoinColumn[] columns,
|
||||||
boolean cascadeOnDelete,
|
boolean cascadeOnDelete,
|
||||||
Nullability nullability,
|
Nullability nullability,
|
||||||
PropertyHolder propertyHolder,
|
PropertyHolder propertyHolder,
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class BinderHelper {
|
||||||
|
|
||||||
|
|
||||||
public static void createSyntheticPropertyReference(
|
public static void createSyntheticPropertyReference(
|
||||||
Ejb3JoinColumn[] columns,
|
AnnotatedJoinColumn[] columns,
|
||||||
PersistentClass ownerEntity,
|
PersistentClass ownerEntity,
|
||||||
PersistentClass associatedEntity,
|
PersistentClass associatedEntity,
|
||||||
Value value,
|
Value value,
|
||||||
|
@ -121,11 +121,11 @@ public class BinderHelper {
|
||||||
if ( columns[0].isImplicit() || StringHelper.isNotEmpty( columns[0].getMappedBy() ) ) {
|
if ( columns[0].isImplicit() || StringHelper.isNotEmpty( columns[0].getMappedBy() ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int fkEnum = Ejb3JoinColumn.checkReferencedColumnsType( columns, ownerEntity, context );
|
int fkEnum = AnnotatedJoinColumn.checkReferencedColumnsType( columns, ownerEntity, context );
|
||||||
PersistentClass associatedClass = columns[0].getPropertyHolder() != null ?
|
PersistentClass associatedClass = columns[0].getPropertyHolder() != null ?
|
||||||
columns[0].getPropertyHolder().getPersistentClass() :
|
columns[0].getPropertyHolder().getPersistentClass() :
|
||||||
null;
|
null;
|
||||||
if ( Ejb3JoinColumn.NON_PK_REFERENCE == fkEnum ) {
|
if ( AnnotatedJoinColumn.NON_PK_REFERENCE == fkEnum ) {
|
||||||
/**
|
/**
|
||||||
* Create a synthetic property to refer to including an
|
* Create a synthetic property to refer to including an
|
||||||
* embedded component value containing all the properties
|
* embedded component value containing all the properties
|
||||||
|
@ -172,7 +172,7 @@ public class BinderHelper {
|
||||||
//TODO use a ToOne type doing a second select
|
//TODO use a ToOne type doing a second select
|
||||||
StringBuilder columnsList = new StringBuilder();
|
StringBuilder columnsList = new StringBuilder();
|
||||||
columnsList.append( "referencedColumnNames(" );
|
columnsList.append( "referencedColumnNames(" );
|
||||||
for (Ejb3JoinColumn column : columns) {
|
for (AnnotatedJoinColumn column : columns) {
|
||||||
columnsList.append( column.getReferencedColumn() ).append( ", " );
|
columnsList.append( column.getReferencedColumn() ).append( ", " );
|
||||||
}
|
}
|
||||||
columnsList.setLength( columnsList.length() - 2 );
|
columnsList.setLength( columnsList.length() - 2 );
|
||||||
|
@ -237,7 +237,7 @@ public class BinderHelper {
|
||||||
|
|
||||||
private static List<Property> findPropertiesByColumns(
|
private static List<Property> findPropertiesByColumns(
|
||||||
Object columnOwner,
|
Object columnOwner,
|
||||||
Ejb3JoinColumn[] columns,
|
AnnotatedJoinColumn[] columns,
|
||||||
MetadataBuildingContext context) {
|
MetadataBuildingContext context) {
|
||||||
Map<Column, Set<Property>> columnsToProperty = new HashMap<>();
|
Map<Column, Set<Property>> columnsToProperty = new HashMap<>();
|
||||||
List<Column> orderedColumns = new ArrayList<>( columns.length );
|
List<Column> orderedColumns = new ArrayList<>( columns.length );
|
||||||
|
@ -256,7 +256,7 @@ public class BinderHelper {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
//build the list of column names
|
//build the list of column names
|
||||||
for (Ejb3JoinColumn column1 : columns) {
|
for (AnnotatedJoinColumn column1 : columns) {
|
||||||
Column column = new Column(
|
Column column = new Column(
|
||||||
context.getMetadataCollector().getPhysicalColumnName(
|
context.getMetadataCollector().getPhysicalColumnName(
|
||||||
referencedTable,
|
referencedTable,
|
||||||
|
@ -801,7 +801,7 @@ public class BinderHelper {
|
||||||
public static Any buildAnyValue(
|
public static Any buildAnyValue(
|
||||||
jakarta.persistence.Column discriminatorColumn,
|
jakarta.persistence.Column discriminatorColumn,
|
||||||
Formula discriminatorFormula,
|
Formula discriminatorFormula,
|
||||||
Ejb3JoinColumn[] keyColumns,
|
AnnotatedJoinColumn[] keyColumns,
|
||||||
PropertyData inferredData,
|
PropertyData inferredData,
|
||||||
boolean cascadeOnDelete,
|
boolean cascadeOnDelete,
|
||||||
boolean lazy,
|
boolean lazy,
|
||||||
|
@ -818,7 +818,7 @@ public class BinderHelper {
|
||||||
|
|
||||||
final BasicValueBinder discriminatorValueBinder = new BasicValueBinder( BasicValueBinder.Kind.ANY_DISCRIMINATOR, context );
|
final BasicValueBinder discriminatorValueBinder = new BasicValueBinder( BasicValueBinder.Kind.ANY_DISCRIMINATOR, context );
|
||||||
|
|
||||||
final Ejb3Column[] discriminatorColumns = Ejb3Column.buildColumnFromAnnotation(
|
final AnnotatedColumn[] discriminatorColumns = AnnotatedColumn.buildColumnFromAnnotation(
|
||||||
new jakarta.persistence.Column[] { discriminatorColumn },
|
new jakarta.persistence.Column[] { discriminatorColumn },
|
||||||
discriminatorFormula,
|
discriminatorFormula,
|
||||||
null,
|
null,
|
||||||
|
@ -860,7 +860,7 @@ public class BinderHelper {
|
||||||
keyValueBinder.setColumns( keyColumns );
|
keyValueBinder.setColumns( keyColumns );
|
||||||
|
|
||||||
if ( !optional ) {
|
if ( !optional ) {
|
||||||
for (Ejb3JoinColumn column : keyColumns) {
|
for (AnnotatedJoinColumn column : keyColumns) {
|
||||||
column.setNullable( false );
|
column.setNullable( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -868,7 +868,7 @@ public class BinderHelper {
|
||||||
final BasicValue keyDescriptor = keyValueBinder.make();
|
final BasicValue keyDescriptor = keyValueBinder.make();
|
||||||
value.setKey( keyDescriptor );
|
value.setKey( keyDescriptor );
|
||||||
keyValueBinder.fillSimpleValue();
|
keyValueBinder.fillSimpleValue();
|
||||||
Ejb3Column.checkPropertyConsistency( keyColumns, propertyHolder.getEntityName() + "." + inferredData.getPropertyName() );
|
AnnotatedColumn.checkPropertyConsistency( keyColumns, propertyHolder.getEntityName() + "." + inferredData.getPropertyName() );
|
||||||
keyColumns[0].linkWithValue( keyDescriptor );
|
keyColumns[0].linkWithValue( keyDescriptor );
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
|
|
@ -175,7 +175,7 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
|
||||||
return persistentClass.getEntityName();
|
return persistentClass.getEntityName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addProperty(Property prop, Ejb3Column[] columns, XClass declaringClass) {
|
public void addProperty(Property prop, AnnotatedColumn[] columns, XClass declaringClass) {
|
||||||
//Ejb3Column.checkPropertyConsistency( ); //already called earlier
|
//Ejb3Column.checkPropertyConsistency( ); //already called earlier
|
||||||
if ( columns != null && columns[0].isSecondary() ) {
|
if ( columns != null && columns[0].isSecondary() ) {
|
||||||
//TODO move the getJoin() code here?
|
//TODO move the getJoin() code here?
|
||||||
|
|
|
@ -309,7 +309,7 @@ public class CollectionPropertyHolder extends AbstractPropertyHolder {
|
||||||
return collection.getOwner().getEntityName();
|
return collection.getOwner().getEntityName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addProperty(Property prop, Ejb3Column[] columns, XClass declaringClass) {
|
public void addProperty(Property prop, AnnotatedColumn[] columns, XClass declaringClass) {
|
||||||
//Ejb3Column.checkPropertyConsistency( ); //already called earlier
|
//Ejb3Column.checkPropertyConsistency( ); //already called earlier
|
||||||
throw new AssertionFailure( "addProperty to a join table of a collection: does it make sense?" );
|
throw new AssertionFailure( "addProperty to a join table of a collection: does it make sense?" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,8 @@ class ColumnsBuilder {
|
||||||
private PropertyData inferredData;
|
private PropertyData inferredData;
|
||||||
private EntityBinder entityBinder;
|
private EntityBinder entityBinder;
|
||||||
private MetadataBuildingContext buildingContext;
|
private MetadataBuildingContext buildingContext;
|
||||||
private Ejb3Column[] columns;
|
private AnnotatedColumn[] columns;
|
||||||
private Ejb3JoinColumn[] joinColumns;
|
private AnnotatedJoinColumn[] joinColumns;
|
||||||
|
|
||||||
public ColumnsBuilder(
|
public ColumnsBuilder(
|
||||||
PropertyHolder propertyHolder,
|
PropertyHolder propertyHolder,
|
||||||
|
@ -60,11 +60,11 @@ class ColumnsBuilder {
|
||||||
this.buildingContext = buildingContext;
|
this.buildingContext = buildingContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ejb3Column[] getColumns() {
|
public AnnotatedColumn[] getColumns() {
|
||||||
return columns;
|
return columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ejb3JoinColumn[] getJoinColumns() {
|
public AnnotatedJoinColumn[] getJoinColumns() {
|
||||||
return joinColumns;
|
return joinColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class ColumnsBuilder {
|
||||||
if ( property.isAnnotationPresent( Column.class ) || property.isAnnotationPresent( Formula.class ) ) {
|
if ( property.isAnnotationPresent( Column.class ) || property.isAnnotationPresent( Formula.class ) ) {
|
||||||
Column ann = property.getAnnotation( Column.class );
|
Column ann = property.getAnnotation( Column.class );
|
||||||
Formula formulaAnn = property.getAnnotation( Formula.class );
|
Formula formulaAnn = property.getAnnotation( Formula.class );
|
||||||
columns = Ejb3Column.buildColumnFromAnnotation(
|
columns = AnnotatedColumn.buildColumnFromAnnotation(
|
||||||
new Column[] { ann },
|
new Column[] { ann },
|
||||||
formulaAnn,
|
formulaAnn,
|
||||||
property.getAnnotation( Comment.class ),
|
property.getAnnotation( Comment.class ),
|
||||||
|
@ -89,7 +89,7 @@ class ColumnsBuilder {
|
||||||
}
|
}
|
||||||
else if ( property.isAnnotationPresent( Columns.class ) ) {
|
else if ( property.isAnnotationPresent( Columns.class ) ) {
|
||||||
Columns anns = property.getAnnotation( Columns.class );
|
Columns anns = property.getAnnotation( Columns.class );
|
||||||
columns = Ejb3Column.buildColumnFromAnnotation(
|
columns = AnnotatedColumn.buildColumnFromAnnotation(
|
||||||
anns.columns(),
|
anns.columns(),
|
||||||
null,
|
null,
|
||||||
property.getAnnotation( Comment.class ),
|
property.getAnnotation( Comment.class ),
|
||||||
|
@ -116,7 +116,7 @@ class ColumnsBuilder {
|
||||||
String mappedBy = oneToMany != null ?
|
String mappedBy = oneToMany != null ?
|
||||||
oneToMany.mappedBy() :
|
oneToMany.mappedBy() :
|
||||||
"";
|
"";
|
||||||
joinColumns = Ejb3JoinColumn.buildJoinColumns(
|
joinColumns = AnnotatedJoinColumn.buildJoinColumns(
|
||||||
null,
|
null,
|
||||||
property.getAnnotation( Comment.class ),
|
property.getAnnotation( Comment.class ),
|
||||||
mappedBy,
|
mappedBy,
|
||||||
|
@ -132,7 +132,7 @@ class ColumnsBuilder {
|
||||||
}
|
}
|
||||||
if ( columns == null && !property.isAnnotationPresent( ManyToMany.class ) ) {
|
if ( columns == null && !property.isAnnotationPresent( ManyToMany.class ) ) {
|
||||||
//useful for collection of embedded elements
|
//useful for collection of embedded elements
|
||||||
columns = Ejb3Column.buildColumnFromAnnotation(
|
columns = AnnotatedColumn.buildColumnFromAnnotation(
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
property.getAnnotation( Comment.class ),
|
property.getAnnotation( Comment.class ),
|
||||||
|
@ -146,18 +146,18 @@ class ColumnsBuilder {
|
||||||
|
|
||||||
if ( nullability == Nullability.FORCED_NOT_NULL ) {
|
if ( nullability == Nullability.FORCED_NOT_NULL ) {
|
||||||
//force columns to not null
|
//force columns to not null
|
||||||
for (Ejb3Column col : columns ) {
|
for (AnnotatedColumn col : columns ) {
|
||||||
col.forceNotNull();
|
col.forceNotNull();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ejb3JoinColumn[] buildDefaultJoinColumnsForXToOne(XProperty property, PropertyData inferredData) {
|
AnnotatedJoinColumn[] buildDefaultJoinColumnsForXToOne(XProperty property, PropertyData inferredData) {
|
||||||
Ejb3JoinColumn[] joinColumns;
|
AnnotatedJoinColumn[] joinColumns;
|
||||||
JoinTable joinTableAnn = propertyHolder.getJoinTable( property );
|
JoinTable joinTableAnn = propertyHolder.getJoinTable( property );
|
||||||
if ( joinTableAnn != null ) {
|
if ( joinTableAnn != null ) {
|
||||||
joinColumns = Ejb3JoinColumn.buildJoinColumns(
|
joinColumns = AnnotatedJoinColumn.buildJoinColumns(
|
||||||
joinTableAnn.inverseJoinColumns(),
|
joinTableAnn.inverseJoinColumns(),
|
||||||
property.getAnnotation( Comment.class ),
|
property.getAnnotation( Comment.class ),
|
||||||
null,
|
null,
|
||||||
|
@ -178,7 +178,7 @@ class ColumnsBuilder {
|
||||||
String mappedBy = oneToOneAnn != null
|
String mappedBy = oneToOneAnn != null
|
||||||
? oneToOneAnn.mappedBy()
|
? oneToOneAnn.mappedBy()
|
||||||
: null;
|
: null;
|
||||||
joinColumns = Ejb3JoinColumn.buildJoinColumns(
|
joinColumns = AnnotatedJoinColumn.buildJoinColumns(
|
||||||
null,
|
null,
|
||||||
property.getAnnotation( Comment.class ),
|
property.getAnnotation( Comment.class ),
|
||||||
mappedBy,
|
mappedBy,
|
||||||
|
@ -191,7 +191,7 @@ class ColumnsBuilder {
|
||||||
return joinColumns;
|
return joinColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ejb3JoinColumn[] buildExplicitJoinColumns(XProperty property, PropertyData inferredData) {
|
AnnotatedJoinColumn[] buildExplicitJoinColumns(XProperty property, PropertyData inferredData) {
|
||||||
//process @JoinColumn(s) before @Column(s) to handle collection of entities properly
|
//process @JoinColumn(s) before @Column(s) to handle collection of entities properly
|
||||||
JoinColumn[] joinColumnAnnotations = null;
|
JoinColumn[] joinColumnAnnotations = null;
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ class ColumnsBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( joinColumnAnnotations != null ) {
|
if ( joinColumnAnnotations != null ) {
|
||||||
return Ejb3JoinColumn.buildJoinColumns(
|
return AnnotatedJoinColumn.buildJoinColumns(
|
||||||
joinColumnAnnotations,
|
joinColumnAnnotations,
|
||||||
property.getAnnotation( Comment.class ),
|
property.getAnnotation( Comment.class ),
|
||||||
null,
|
null,
|
||||||
|
@ -236,7 +236,7 @@ class ColumnsBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (joinColumnOrFormulaAnnotations != null) {
|
if (joinColumnOrFormulaAnnotations != null) {
|
||||||
return Ejb3JoinColumn.buildJoinColumnsOrFormulas(
|
return AnnotatedJoinColumn.buildJoinColumnsOrFormulas(
|
||||||
joinColumnOrFormulaAnnotations,
|
joinColumnOrFormulaAnnotations,
|
||||||
null,
|
null,
|
||||||
entityBinder.getSecondaryTables(),
|
entityBinder.getSecondaryTables(),
|
||||||
|
@ -248,8 +248,8 @@ class ColumnsBuilder {
|
||||||
|
|
||||||
if (property.isAnnotationPresent( JoinFormula.class)) {
|
if (property.isAnnotationPresent( JoinFormula.class)) {
|
||||||
JoinFormula ann = property.getAnnotation( JoinFormula.class );
|
JoinFormula ann = property.getAnnotation( JoinFormula.class );
|
||||||
Ejb3JoinColumn[] ejb3JoinColumns = new Ejb3JoinColumn[1];
|
AnnotatedJoinColumn[] annotatedJoinColumns = new AnnotatedJoinColumn[1];
|
||||||
ejb3JoinColumns[0] = Ejb3JoinColumn.buildJoinFormula(
|
annotatedJoinColumns[0] = AnnotatedJoinColumn.buildJoinFormula(
|
||||||
ann,
|
ann,
|
||||||
null,
|
null,
|
||||||
entityBinder.getSecondaryTables(),
|
entityBinder.getSecondaryTables(),
|
||||||
|
@ -257,14 +257,14 @@ class ColumnsBuilder {
|
||||||
inferredData.getPropertyName(),
|
inferredData.getPropertyName(),
|
||||||
buildingContext
|
buildingContext
|
||||||
);
|
);
|
||||||
return ejb3JoinColumns;
|
return annotatedJoinColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ejb3Column[] overrideColumnFromMapperOrMapsIdProperty(boolean isId) {
|
AnnotatedColumn[] overrideColumnFromMapperOrMapsIdProperty(boolean isId) {
|
||||||
Ejb3Column[] result = columns;
|
AnnotatedColumn[] result = columns;
|
||||||
final PropertyData overridingProperty = BinderHelper.getPropertyOverriddenByMapperOrMapsId(
|
final PropertyData overridingProperty = BinderHelper.getPropertyOverriddenByMapperOrMapsId(
|
||||||
isId,
|
isId,
|
||||||
propertyHolder,
|
propertyHolder,
|
||||||
|
@ -280,8 +280,8 @@ class ColumnsBuilder {
|
||||||
/**
|
/**
|
||||||
* useful to override a column either by @MapsId or by @IdClass
|
* useful to override a column either by @MapsId or by @IdClass
|
||||||
*/
|
*/
|
||||||
Ejb3Column[] buildExcplicitOrDefaultJoinColumn(PropertyData overridingProperty) {
|
AnnotatedColumn[] buildExcplicitOrDefaultJoinColumn(PropertyData overridingProperty) {
|
||||||
Ejb3Column[] result;
|
AnnotatedColumn[] result;
|
||||||
result = buildExplicitJoinColumns( overridingProperty.getProperty(), overridingProperty );
|
result = buildExplicitJoinColumns( overridingProperty.getProperty(), overridingProperty );
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
result = buildDefaultJoinColumnsForXToOne( overridingProperty.getProperty(), overridingProperty);
|
result = buildDefaultJoinColumnsForXToOne( overridingProperty.getProperty(), overridingProperty);
|
||||||
|
|
|
@ -275,7 +275,7 @@ public class ComponentPropertyHolder extends AbstractPropertyHolder {
|
||||||
return component.getComponentClassName();
|
return component.getComponentClassName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addProperty(Property prop, Ejb3Column[] columns, XClass declaringClass) {
|
public void addProperty(Property prop, AnnotatedColumn[] columns, XClass declaringClass) {
|
||||||
//Ejb3Column.checkPropertyConsistency( ); //already called earlier
|
//Ejb3Column.checkPropertyConsistency( ); //already called earlier
|
||||||
/*
|
/*
|
||||||
* Check table matches between the component and the columns
|
* Check table matches between the component and the columns
|
||||||
|
|
|
@ -38,12 +38,12 @@ public class CopyIdentifierComponentSecondPass extends FkSecondPass {
|
||||||
private final String referencedEntityName;
|
private final String referencedEntityName;
|
||||||
private final Component component;
|
private final Component component;
|
||||||
private final MetadataBuildingContext buildingContext;
|
private final MetadataBuildingContext buildingContext;
|
||||||
private final Ejb3JoinColumn[] joinColumns;
|
private final AnnotatedJoinColumn[] joinColumns;
|
||||||
|
|
||||||
public CopyIdentifierComponentSecondPass(
|
public CopyIdentifierComponentSecondPass(
|
||||||
Component comp,
|
Component comp,
|
||||||
String referencedEntityName,
|
String referencedEntityName,
|
||||||
Ejb3JoinColumn[] joinColumns,
|
AnnotatedJoinColumn[] joinColumns,
|
||||||
MetadataBuildingContext buildingContext) {
|
MetadataBuildingContext buildingContext) {
|
||||||
super( comp, joinColumns );
|
super( comp, joinColumns );
|
||||||
this.component = comp;
|
this.component = comp;
|
||||||
|
@ -83,8 +83,8 @@ public class CopyIdentifierComponentSecondPass extends FkSecondPass {
|
||||||
|
|
||||||
//prepare column name structure
|
//prepare column name structure
|
||||||
boolean isExplicitReference = true;
|
boolean isExplicitReference = true;
|
||||||
Map<String, Ejb3JoinColumn> columnByReferencedName = CollectionHelper.mapOfSize( joinColumns.length);
|
Map<String, AnnotatedJoinColumn> columnByReferencedName = CollectionHelper.mapOfSize( joinColumns.length);
|
||||||
for (Ejb3JoinColumn joinColumn : joinColumns) {
|
for (AnnotatedJoinColumn joinColumn : joinColumns) {
|
||||||
final String referencedColumnName = joinColumn.getReferencedColumn();
|
final String referencedColumnName = joinColumn.getReferencedColumn();
|
||||||
if ( referencedColumnName == null || BinderHelper.isEmptyAnnotationValue( referencedColumnName ) ) {
|
if ( referencedColumnName == null || BinderHelper.isEmptyAnnotationValue( referencedColumnName ) ) {
|
||||||
break;
|
break;
|
||||||
|
@ -117,7 +117,7 @@ public class CopyIdentifierComponentSecondPass extends FkSecondPass {
|
||||||
private Property createComponentProperty(
|
private Property createComponentProperty(
|
||||||
PersistentClass referencedPersistentClass,
|
PersistentClass referencedPersistentClass,
|
||||||
boolean isExplicitReference,
|
boolean isExplicitReference,
|
||||||
Map<String, Ejb3JoinColumn> columnByReferencedName,
|
Map<String, AnnotatedJoinColumn> columnByReferencedName,
|
||||||
MutableInteger index,
|
MutableInteger index,
|
||||||
Property referencedProperty ) {
|
Property referencedProperty ) {
|
||||||
Property property = new Property();
|
Property property = new Property();
|
||||||
|
@ -156,7 +156,7 @@ public class CopyIdentifierComponentSecondPass extends FkSecondPass {
|
||||||
private Property createSimpleProperty(
|
private Property createSimpleProperty(
|
||||||
PersistentClass referencedPersistentClass,
|
PersistentClass referencedPersistentClass,
|
||||||
boolean isExplicitReference,
|
boolean isExplicitReference,
|
||||||
Map<String, Ejb3JoinColumn> columnByReferencedName,
|
Map<String, AnnotatedJoinColumn> columnByReferencedName,
|
||||||
MutableInteger index,
|
MutableInteger index,
|
||||||
Property referencedProperty ) {
|
Property referencedProperty ) {
|
||||||
Property property = new Property();
|
Property property = new Property();
|
||||||
|
@ -186,7 +186,7 @@ public class CopyIdentifierComponentSecondPass extends FkSecondPass {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final Column column = (Column) selectable;
|
final Column column = (Column) selectable;
|
||||||
final Ejb3JoinColumn joinColumn;
|
final AnnotatedJoinColumn joinColumn;
|
||||||
String logicalColumnName = null;
|
String logicalColumnName = null;
|
||||||
if ( isExplicitReference ) {
|
if ( isExplicitReference ) {
|
||||||
logicalColumnName = column.getName();
|
logicalColumnName = column.getName();
|
||||||
|
@ -222,7 +222,7 @@ public class CopyIdentifierComponentSecondPass extends FkSecondPass {
|
||||||
return property;
|
return property;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyComponentColumnSizeValueToJoinColumn(Column column, Ejb3JoinColumn joinColumn) {
|
private void applyComponentColumnSizeValueToJoinColumn(Column column, AnnotatedJoinColumn joinColumn) {
|
||||||
Column mappingColumn = joinColumn.getMappingColumn();
|
Column mappingColumn = joinColumn.getMappingColumn();
|
||||||
mappingColumn.setLength( column.getLength() );
|
mappingColumn.setLength( column.getLength() );
|
||||||
mappingColumn.setPrecision( column.getPrecision() );
|
mappingColumn.setPrecision( column.getPrecision() );
|
||||||
|
|
|
@ -12,7 +12,7 @@ import org.hibernate.internal.util.StringHelper;
|
||||||
/**
|
/**
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
*/
|
*/
|
||||||
public class DefaultComponentSafeNamingStrategy extends EJB3NamingStrategy {
|
public class DefaultComponentSafeNamingStrategy extends PersistenceStandardNamingStrategy {
|
||||||
public static final NamingStrategy INSTANCE = new DefaultComponentSafeNamingStrategy();
|
public static final NamingStrategy INSTANCE = new DefaultComponentSafeNamingStrategy();
|
||||||
|
|
||||||
protected static String addUnderscores(String name) {
|
protected static String addUnderscores(String name) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.hibernate.mapping.Value;
|
||||||
*/
|
*/
|
||||||
public abstract class FkSecondPass implements SecondPass {
|
public abstract class FkSecondPass implements SecondPass {
|
||||||
protected SimpleValue value;
|
protected SimpleValue value;
|
||||||
protected Ejb3JoinColumn[] columns;
|
protected AnnotatedJoinColumn[] columns;
|
||||||
/**
|
/**
|
||||||
* unique counter is needed to differentiate 2 instances of FKSecondPass
|
* unique counter is needed to differentiate 2 instances of FKSecondPass
|
||||||
* as they are compared.
|
* as they are compared.
|
||||||
|
@ -25,7 +25,7 @@ public abstract class FkSecondPass implements SecondPass {
|
||||||
private int uniqueCounter;
|
private int uniqueCounter;
|
||||||
private static AtomicInteger globalCounter = new AtomicInteger();
|
private static AtomicInteger globalCounter = new AtomicInteger();
|
||||||
|
|
||||||
public FkSecondPass(SimpleValue value, Ejb3JoinColumn[] columns) {
|
public FkSecondPass(SimpleValue value, AnnotatedJoinColumn[] columns) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.columns = columns;
|
this.columns = columns;
|
||||||
this.uniqueCounter = globalCounter.getAndIncrement();
|
this.uniqueCounter = globalCounter.getAndIncrement();
|
||||||
|
|
|
@ -17,7 +17,7 @@ import org.hibernate.mapping.Join;
|
||||||
*
|
*
|
||||||
* @author inger
|
* @author inger
|
||||||
*/
|
*/
|
||||||
public class IndexColumn extends Ejb3Column {
|
public class IndexColumn extends AnnotatedColumn {
|
||||||
private int base;
|
private int base;
|
||||||
|
|
||||||
// TODO move to a getter setter strategy for readability
|
// TODO move to a getter setter strategy for readability
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class IndexOrUniqueKeySecondPass implements SecondPass {
|
||||||
private final String indexName;
|
private final String indexName;
|
||||||
private final String[] columns;
|
private final String[] columns;
|
||||||
private final MetadataBuildingContext buildingContext;
|
private final MetadataBuildingContext buildingContext;
|
||||||
private final Ejb3Column column;
|
private final AnnotatedColumn column;
|
||||||
private final boolean unique;
|
private final boolean unique;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,14 +48,14 @@ public class IndexOrUniqueKeySecondPass implements SecondPass {
|
||||||
/**
|
/**
|
||||||
* Build an index
|
* Build an index
|
||||||
*/
|
*/
|
||||||
public IndexOrUniqueKeySecondPass(String indexName, Ejb3Column column, MetadataBuildingContext buildingContext) {
|
public IndexOrUniqueKeySecondPass(String indexName, AnnotatedColumn column, MetadataBuildingContext buildingContext) {
|
||||||
this( indexName, column, buildingContext, false );
|
this( indexName, column, buildingContext, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build an index if unique is false or a Unique Key if unique is true
|
* Build an index if unique is false or a Unique Key if unique is true
|
||||||
*/
|
*/
|
||||||
public IndexOrUniqueKeySecondPass(String indexName, Ejb3Column column, MetadataBuildingContext buildingContext, boolean unique) {
|
public IndexOrUniqueKeySecondPass(String indexName, AnnotatedColumn column, MetadataBuildingContext buildingContext, boolean unique) {
|
||||||
this.indexName = indexName;
|
this.indexName = indexName;
|
||||||
this.column = column;
|
this.column = column;
|
||||||
this.columns = null;
|
this.columns = null;
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class JoinedSubclassFkSecondPass extends FkSecondPass {
|
||||||
|
|
||||||
public JoinedSubclassFkSecondPass(
|
public JoinedSubclassFkSecondPass(
|
||||||
JoinedSubclass entity,
|
JoinedSubclass entity,
|
||||||
Ejb3JoinColumn[] inheritanceJoinedColumns,
|
AnnotatedJoinColumn[] inheritanceJoinedColumns,
|
||||||
SimpleValue key,
|
SimpleValue key,
|
||||||
MetadataBuildingContext buildingContext) {
|
MetadataBuildingContext buildingContext) {
|
||||||
super( key, inheritanceJoinedColumns );
|
super( key, inheritanceJoinedColumns );
|
||||||
|
|
|
@ -13,7 +13,6 @@ import jakarta.persistence.JoinColumn;
|
||||||
import jakarta.persistence.JoinColumns;
|
import jakarta.persistence.JoinColumns;
|
||||||
|
|
||||||
import org.hibernate.AnnotationException;
|
import org.hibernate.AnnotationException;
|
||||||
import org.hibernate.FetchMode;
|
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.annotations.LazyGroup;
|
import org.hibernate.annotations.LazyGroup;
|
||||||
import org.hibernate.annotations.common.reflection.XClass;
|
import org.hibernate.annotations.common.reflection.XClass;
|
||||||
|
@ -47,7 +46,7 @@ public class OneToOneSecondPass implements SecondPass {
|
||||||
private boolean cascadeOnDelete;
|
private boolean cascadeOnDelete;
|
||||||
private boolean optional;
|
private boolean optional;
|
||||||
private String cascadeStrategy;
|
private String cascadeStrategy;
|
||||||
private Ejb3JoinColumn[] joinColumns;
|
private AnnotatedJoinColumn[] joinColumns;
|
||||||
|
|
||||||
//that sucks, we should read that from the property mainly
|
//that sucks, we should read that from the property mainly
|
||||||
public OneToOneSecondPass(
|
public OneToOneSecondPass(
|
||||||
|
@ -61,7 +60,7 @@ public class OneToOneSecondPass implements SecondPass {
|
||||||
boolean cascadeOnDelete,
|
boolean cascadeOnDelete,
|
||||||
boolean optional,
|
boolean optional,
|
||||||
String cascadeStrategy,
|
String cascadeStrategy,
|
||||||
Ejb3JoinColumn[] columns,
|
AnnotatedJoinColumn[] columns,
|
||||||
MetadataBuildingContext buildingContext) {
|
MetadataBuildingContext buildingContext) {
|
||||||
this.ownerEntity = ownerEntity;
|
this.ownerEntity = ownerEntity;
|
||||||
this.ownerProperty = ownerProperty;
|
this.ownerProperty = ownerProperty;
|
||||||
|
|
|
@ -22,10 +22,10 @@ import org.xml.sax.InputSource;
|
||||||
*
|
*
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
*/
|
*/
|
||||||
public class EJB3DTDEntityResolver extends DTDEntityResolver {
|
public class PersistenceStandardEntityResolver extends DTDEntityResolver {
|
||||||
public static final EntityResolver INSTANCE = new EJB3DTDEntityResolver();
|
public static final EntityResolver INSTANCE = new PersistenceStandardEntityResolver();
|
||||||
|
|
||||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, EJB3DTDEntityResolver.class.getName() );
|
private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, PersistenceStandardEntityResolver.class.getName() );
|
||||||
|
|
||||||
boolean resolved = false;
|
boolean resolved = false;
|
||||||
|
|
|
@ -15,8 +15,8 @@ import org.hibernate.internal.util.StringHelper;
|
||||||
*
|
*
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
*/
|
*/
|
||||||
public class EJB3NamingStrategy implements NamingStrategy, Serializable {
|
public class PersistenceStandardNamingStrategy implements NamingStrategy, Serializable {
|
||||||
public static final NamingStrategy INSTANCE = new EJB3NamingStrategy();
|
public static final NamingStrategy INSTANCE = new PersistenceStandardNamingStrategy();
|
||||||
|
|
||||||
public String classToTableName(String className) {
|
public String classToTableName(String className) {
|
||||||
return StringHelper.unqualify( className );
|
return StringHelper.unqualify( className );
|
|
@ -18,10 +18,10 @@ import org.hibernate.mapping.SimpleValue;
|
||||||
*/
|
*/
|
||||||
public class PkDrivenByDefaultMapsIdSecondPass extends FkSecondPass {
|
public class PkDrivenByDefaultMapsIdSecondPass extends FkSecondPass {
|
||||||
private final String referencedEntityName;
|
private final String referencedEntityName;
|
||||||
private final Ejb3JoinColumn[] columns;
|
private final AnnotatedJoinColumn[] columns;
|
||||||
private final SimpleValue value;
|
private final SimpleValue value;
|
||||||
|
|
||||||
public PkDrivenByDefaultMapsIdSecondPass(String referencedEntityName, Ejb3JoinColumn[] columns, SimpleValue value) {
|
public PkDrivenByDefaultMapsIdSecondPass(String referencedEntityName, AnnotatedJoinColumn[] columns, SimpleValue value) {
|
||||||
super( value, columns );
|
super( value, columns );
|
||||||
this.referencedEntityName = referencedEntityName;
|
this.referencedEntityName = referencedEntityName;
|
||||||
this.columns = columns;
|
this.columns = columns;
|
||||||
|
|
|
@ -34,7 +34,7 @@ public interface PropertyHolder {
|
||||||
|
|
||||||
void addProperty(Property prop, XClass declaringClass);
|
void addProperty(Property prop, XClass declaringClass);
|
||||||
|
|
||||||
void addProperty(Property prop, Ejb3Column[] columns, XClass declaringClass);
|
void addProperty(Property prop, AnnotatedColumn[] columns, XClass declaringClass);
|
||||||
|
|
||||||
KeyValue getIdentifier();
|
KeyValue getIdentifier();
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class ToOneFkSecondPass extends FkSecondPass {
|
||||||
|
|
||||||
public ToOneFkSecondPass(
|
public ToOneFkSecondPass(
|
||||||
ToOne value,
|
ToOne value,
|
||||||
Ejb3JoinColumn[] columns,
|
AnnotatedJoinColumn[] columns,
|
||||||
boolean unique,
|
boolean unique,
|
||||||
String entityClassName,
|
String entityClassName,
|
||||||
String path,
|
String path,
|
||||||
|
|
|
@ -58,8 +58,8 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.cfg.AccessType;
|
import org.hibernate.cfg.AccessType;
|
||||||
import org.hibernate.cfg.Ejb3Column;
|
import org.hibernate.cfg.AnnotatedColumn;
|
||||||
import org.hibernate.cfg.Ejb3JoinColumn;
|
import org.hibernate.cfg.AnnotatedJoinColumn;
|
||||||
import org.hibernate.cfg.PkDrivenByDefaultMapsIdSecondPass;
|
import org.hibernate.cfg.PkDrivenByDefaultMapsIdSecondPass;
|
||||||
import org.hibernate.cfg.SetBasicValueTypeSecondPass;
|
import org.hibernate.cfg.SetBasicValueTypeSecondPass;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
|
@ -162,7 +162,7 @@ public class BasicValueBinder<T> implements JdbcTypeDescriptorIndicators {
|
||||||
private TimeZoneStorageType timeZoneStorageType;
|
private TimeZoneStorageType timeZoneStorageType;
|
||||||
|
|
||||||
private Table table;
|
private Table table;
|
||||||
private Ejb3Column[] columns;
|
private AnnotatedColumn[] columns;
|
||||||
|
|
||||||
private BasicValue basicValue;
|
private BasicValue basicValue;
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ public class BasicValueBinder<T> implements JdbcTypeDescriptorIndicators {
|
||||||
this.table = table;
|
this.table = table;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColumns(Ejb3Column[] columns) {
|
public void setColumns(AnnotatedColumn[] columns) {
|
||||||
this.columns = columns;
|
this.columns = columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1193,7 +1193,7 @@ public class BasicValueBinder<T> implements JdbcTypeDescriptorIndicators {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validate() {
|
private void validate() {
|
||||||
Ejb3Column.checkPropertyConsistency( columns, propertyName );
|
AnnotatedColumn.checkPropertyConsistency( columns, propertyName );
|
||||||
}
|
}
|
||||||
|
|
||||||
public BasicValue make() {
|
public BasicValue make() {
|
||||||
|
@ -1250,12 +1250,12 @@ public class BasicValueBinder<T> implements JdbcTypeDescriptorIndicators {
|
||||||
if ( columns[0].isNameDeferred() && !buildingContext.getMetadataCollector().isInSecondPass() && referencedEntityName != null ) {
|
if ( columns[0].isNameDeferred() && !buildingContext.getMetadataCollector().isInSecondPass() && referencedEntityName != null ) {
|
||||||
buildingContext.getMetadataCollector().addSecondPass(
|
buildingContext.getMetadataCollector().addSecondPass(
|
||||||
new PkDrivenByDefaultMapsIdSecondPass(
|
new PkDrivenByDefaultMapsIdSecondPass(
|
||||||
referencedEntityName, (Ejb3JoinColumn[]) columns, basicValue
|
referencedEntityName, (AnnotatedJoinColumn[]) columns, basicValue
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for ( Ejb3Column column : columns ) {
|
for ( AnnotatedColumn column : columns ) {
|
||||||
column.linkWithValue( basicValue );
|
column.linkWithValue( basicValue );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,8 @@ import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.cfg.BinderHelper;
|
import org.hibernate.cfg.BinderHelper;
|
||||||
import org.hibernate.cfg.CollectionPropertyHolder;
|
import org.hibernate.cfg.CollectionPropertyHolder;
|
||||||
import org.hibernate.cfg.CollectionSecondPass;
|
import org.hibernate.cfg.CollectionSecondPass;
|
||||||
import org.hibernate.cfg.Ejb3Column;
|
import org.hibernate.cfg.AnnotatedColumn;
|
||||||
import org.hibernate.cfg.Ejb3JoinColumn;
|
import org.hibernate.cfg.AnnotatedJoinColumn;
|
||||||
import org.hibernate.cfg.IndexColumn;
|
import org.hibernate.cfg.IndexColumn;
|
||||||
import org.hibernate.cfg.InheritanceState;
|
import org.hibernate.cfg.InheritanceState;
|
||||||
import org.hibernate.cfg.PropertyData;
|
import org.hibernate.cfg.PropertyData;
|
||||||
|
@ -157,7 +157,7 @@ public abstract class CollectionBinder {
|
||||||
private String mappedBy;
|
private String mappedBy;
|
||||||
private XClass collectionType;
|
private XClass collectionType;
|
||||||
private XClass targetEntity;
|
private XClass targetEntity;
|
||||||
private Ejb3JoinColumn[] inverseJoinColumns;
|
private AnnotatedJoinColumn[] inverseJoinColumns;
|
||||||
private String cascadeStrategy;
|
private String cascadeStrategy;
|
||||||
private String cacheConcurrencyStrategy;
|
private String cacheConcurrencyStrategy;
|
||||||
private String cacheRegionName;
|
private String cacheRegionName;
|
||||||
|
@ -167,15 +167,15 @@ public abstract class CollectionBinder {
|
||||||
protected String mapKeyPropertyName;
|
protected String mapKeyPropertyName;
|
||||||
private boolean insertable = true;
|
private boolean insertable = true;
|
||||||
private boolean updatable = true;
|
private boolean updatable = true;
|
||||||
private Ejb3JoinColumn[] fkJoinColumns;
|
private AnnotatedJoinColumn[] fkJoinColumns;
|
||||||
private boolean isExplicitAssociationTable;
|
private boolean isExplicitAssociationTable;
|
||||||
private Ejb3Column[] elementColumns;
|
private AnnotatedColumn[] elementColumns;
|
||||||
private boolean isEmbedded;
|
private boolean isEmbedded;
|
||||||
private XProperty property;
|
private XProperty property;
|
||||||
private boolean ignoreNotFound;
|
private boolean ignoreNotFound;
|
||||||
private TableBinder tableBinder;
|
private TableBinder tableBinder;
|
||||||
private Ejb3Column[] mapKeyColumns;
|
private AnnotatedColumn[] mapKeyColumns;
|
||||||
private Ejb3JoinColumn[] mapKeyManyToManyColumns;
|
private AnnotatedJoinColumn[] mapKeyManyToManyColumns;
|
||||||
protected HashMap<String, IdentifierGeneratorDefinition> localGenerators;
|
protected HashMap<String, IdentifierGeneratorDefinition> localGenerators;
|
||||||
protected Map<XClass, InheritanceState> inheritanceStatePerClass;
|
protected Map<XClass, InheritanceState> inheritanceStatePerClass;
|
||||||
private XClass declaringClass;
|
private XClass declaringClass;
|
||||||
|
@ -237,15 +237,15 @@ public abstract class CollectionBinder {
|
||||||
this.accessType = accessType;
|
this.accessType = accessType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInverseJoinColumns(Ejb3JoinColumn[] inverseJoinColumns) {
|
public void setInverseJoinColumns(AnnotatedJoinColumn[] inverseJoinColumns) {
|
||||||
this.inverseJoinColumns = inverseJoinColumns;
|
this.inverseJoinColumns = inverseJoinColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJoinColumns(Ejb3JoinColumn[] joinColumns) {
|
public void setJoinColumns(AnnotatedJoinColumn[] joinColumns) {
|
||||||
this.joinColumns = joinColumns;
|
this.joinColumns = joinColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Ejb3JoinColumn[] joinColumns;
|
private AnnotatedJoinColumn[] joinColumns;
|
||||||
|
|
||||||
public void setPropertyHolder(PropertyHolder propertyHolder) {
|
public void setPropertyHolder(PropertyHolder propertyHolder) {
|
||||||
this.propertyHolder = propertyHolder;
|
this.propertyHolder = propertyHolder;
|
||||||
|
@ -849,12 +849,12 @@ public abstract class CollectionBinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SecondPass getSecondPass(
|
public SecondPass getSecondPass(
|
||||||
final Ejb3JoinColumn[] fkJoinColumns,
|
final AnnotatedJoinColumn[] fkJoinColumns,
|
||||||
final Ejb3JoinColumn[] keyColumns,
|
final AnnotatedJoinColumn[] keyColumns,
|
||||||
final Ejb3JoinColumn[] inverseColumns,
|
final AnnotatedJoinColumn[] inverseColumns,
|
||||||
final Ejb3Column[] elementColumns,
|
final AnnotatedColumn[] elementColumns,
|
||||||
final Ejb3Column[] mapKeyColumns,
|
final AnnotatedColumn[] mapKeyColumns,
|
||||||
final Ejb3JoinColumn[] mapKeyManyToManyColumns,
|
final AnnotatedJoinColumn[] mapKeyManyToManyColumns,
|
||||||
final boolean isEmbedded,
|
final boolean isEmbedded,
|
||||||
final XProperty property,
|
final XProperty property,
|
||||||
final XClass collType,
|
final XClass collType,
|
||||||
|
@ -890,10 +890,10 @@ public abstract class CollectionBinder {
|
||||||
protected boolean bindStarToManySecondPass(
|
protected boolean bindStarToManySecondPass(
|
||||||
Map<String, PersistentClass> persistentClasses,
|
Map<String, PersistentClass> persistentClasses,
|
||||||
XClass collType,
|
XClass collType,
|
||||||
Ejb3JoinColumn[] fkJoinColumns,
|
AnnotatedJoinColumn[] fkJoinColumns,
|
||||||
Ejb3JoinColumn[] keyColumns,
|
AnnotatedJoinColumn[] keyColumns,
|
||||||
Ejb3JoinColumn[] inverseColumns,
|
AnnotatedJoinColumn[] inverseColumns,
|
||||||
Ejb3Column[] elementColumns,
|
AnnotatedColumn[] elementColumns,
|
||||||
boolean isEmbedded,
|
boolean isEmbedded,
|
||||||
XProperty property,
|
XProperty property,
|
||||||
boolean unique,
|
boolean unique,
|
||||||
|
@ -962,7 +962,7 @@ public abstract class CollectionBinder {
|
||||||
protected void bindOneToManySecondPass(
|
protected void bindOneToManySecondPass(
|
||||||
Collection collection,
|
Collection collection,
|
||||||
Map<String, PersistentClass> persistentClasses,
|
Map<String, PersistentClass> persistentClasses,
|
||||||
Ejb3JoinColumn[] fkJoinColumns,
|
AnnotatedJoinColumn[] fkJoinColumns,
|
||||||
XClass collectionType,
|
XClass collectionType,
|
||||||
boolean cascadeDeleteEnabled,
|
boolean cascadeDeleteEnabled,
|
||||||
boolean ignoreNotFound,
|
boolean ignoreNotFound,
|
||||||
|
@ -1002,7 +1002,7 @@ public abstract class CollectionBinder {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
oneToMany.setAssociatedClass( associatedClass );
|
oneToMany.setAssociatedClass( associatedClass );
|
||||||
for (Ejb3JoinColumn column : fkJoinColumns) {
|
for (AnnotatedJoinColumn column : fkJoinColumns) {
|
||||||
column.setPersistentClass( associatedClass, joins, inheritanceStatePerClass );
|
column.setPersistentClass( associatedClass, joins, inheritanceStatePerClass );
|
||||||
column.setJoins( joins );
|
column.setJoins( joins );
|
||||||
collection.setCollectionTable( column.getTable() );
|
collection.setCollectionTable( column.getTable() );
|
||||||
|
@ -1258,7 +1258,7 @@ public abstract class CollectionBinder {
|
||||||
|
|
||||||
private static SimpleValue buildCollectionKey(
|
private static SimpleValue buildCollectionKey(
|
||||||
Collection collValue,
|
Collection collValue,
|
||||||
Ejb3JoinColumn[] joinColumns,
|
AnnotatedJoinColumn[] joinColumns,
|
||||||
boolean cascadeDeleteEnabled,
|
boolean cascadeDeleteEnabled,
|
||||||
boolean noConstraintByDefault,
|
boolean noConstraintByDefault,
|
||||||
XProperty property,
|
XProperty property,
|
||||||
|
@ -1292,7 +1292,7 @@ public abstract class CollectionBinder {
|
||||||
}
|
}
|
||||||
DependantValue key = new DependantValue( buildingContext, collValue.getCollectionTable(), keyVal );
|
DependantValue key = new DependantValue( buildingContext, collValue.getCollectionTable(), keyVal );
|
||||||
key.setTypeName( null );
|
key.setTypeName( null );
|
||||||
Ejb3Column.checkPropertyConsistency( joinColumns, collValue.getOwnerEntityName() );
|
AnnotatedColumn.checkPropertyConsistency( joinColumns, collValue.getOwnerEntityName() );
|
||||||
key.setNullable( joinColumns.length == 0 || joinColumns[0].isNullable() );
|
key.setNullable( joinColumns.length == 0 || joinColumns[0].isNullable() );
|
||||||
key.setUpdateable( joinColumns.length == 0 || joinColumns[0].isUpdatable() );
|
key.setUpdateable( joinColumns.length == 0 || joinColumns[0].isUpdatable() );
|
||||||
key.setCascadeDeleteEnabled( cascadeDeleteEnabled );
|
key.setCascadeDeleteEnabled( cascadeDeleteEnabled );
|
||||||
|
@ -1392,9 +1392,9 @@ public abstract class CollectionBinder {
|
||||||
private void bindManyToManySecondPass(
|
private void bindManyToManySecondPass(
|
||||||
Collection collValue,
|
Collection collValue,
|
||||||
Map<String, PersistentClass> persistentClasses,
|
Map<String, PersistentClass> persistentClasses,
|
||||||
Ejb3JoinColumn[] joinColumns,
|
AnnotatedJoinColumn[] joinColumns,
|
||||||
Ejb3JoinColumn[] inverseJoinColumns,
|
AnnotatedJoinColumn[] inverseJoinColumns,
|
||||||
Ejb3Column[] elementColumns,
|
AnnotatedColumn[] elementColumns,
|
||||||
boolean isEmbedded,
|
boolean isEmbedded,
|
||||||
XClass collType,
|
XClass collType,
|
||||||
boolean ignoreNotFound, boolean unique,
|
boolean ignoreNotFound, boolean unique,
|
||||||
|
@ -1486,7 +1486,7 @@ public abstract class CollectionBinder {
|
||||||
}
|
}
|
||||||
collValue.setCollectionTable( table );
|
collValue.setCollectionTable( table );
|
||||||
String entityName = collectionEntity.getEntityName();
|
String entityName = collectionEntity.getEntityName();
|
||||||
for (Ejb3JoinColumn column : joinColumns) {
|
for (AnnotatedJoinColumn column : joinColumns) {
|
||||||
//column.setDefaultColumnHeader( joinColumns[0].getMappedBy() ); //seems not to be used, make sense
|
//column.setDefaultColumnHeader( joinColumns[0].getMappedBy() ); //seems not to be used, make sense
|
||||||
column.setManyToManyOwnerSideEntityName( entityName );
|
column.setManyToManyOwnerSideEntityName( entityName );
|
||||||
}
|
}
|
||||||
|
@ -1494,7 +1494,7 @@ public abstract class CollectionBinder {
|
||||||
else {
|
else {
|
||||||
//TODO: only for implicit columns?
|
//TODO: only for implicit columns?
|
||||||
//FIXME NamingStrategy
|
//FIXME NamingStrategy
|
||||||
for (Ejb3JoinColumn column : joinColumns) {
|
for (AnnotatedJoinColumn column : joinColumns) {
|
||||||
String mappedByProperty = buildingContext.getMetadataCollector().getFromMappedBy(
|
String mappedByProperty = buildingContext.getMetadataCollector().getFromMappedBy(
|
||||||
collValue.getOwnerEntityName(), column.getPropertyName()
|
collValue.getOwnerEntityName(), column.getPropertyName()
|
||||||
);
|
);
|
||||||
|
@ -1593,7 +1593,7 @@ public abstract class CollectionBinder {
|
||||||
final Formula discriminatorFormulaAnn = inferredData.getProperty().getAnnotation( Formula.class );
|
final Formula discriminatorFormulaAnn = inferredData.getProperty().getAnnotation( Formula.class );
|
||||||
|
|
||||||
//override the table
|
//override the table
|
||||||
for (Ejb3Column column : inverseJoinColumns) {
|
for (AnnotatedColumn column : inverseJoinColumns) {
|
||||||
column.setTable( collValue.getCollectionTable() );
|
column.setTable( collValue.getCollectionTable() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1740,8 +1740,8 @@ public abstract class CollectionBinder {
|
||||||
final BasicValueBinder elementBinder = new BasicValueBinder( BasicValueBinder.Kind.COLLECTION_ELEMENT, buildingContext );
|
final BasicValueBinder elementBinder = new BasicValueBinder( BasicValueBinder.Kind.COLLECTION_ELEMENT, buildingContext );
|
||||||
elementBinder.setReturnedClassName( collType.getName() );
|
elementBinder.setReturnedClassName( collType.getName() );
|
||||||
if ( elementColumns == null || elementColumns.length == 0 ) {
|
if ( elementColumns == null || elementColumns.length == 0 ) {
|
||||||
elementColumns = new Ejb3Column[1];
|
elementColumns = new AnnotatedColumn[1];
|
||||||
Ejb3Column column = new Ejb3Column();
|
AnnotatedColumn column = new AnnotatedColumn();
|
||||||
column.setImplicit( false );
|
column.setImplicit( false );
|
||||||
//not following the spec but more clean
|
//not following the spec but more clean
|
||||||
column.setNullable( true );
|
column.setNullable( true );
|
||||||
|
@ -1753,7 +1753,7 @@ public abstract class CollectionBinder {
|
||||||
elementColumns[0] = column;
|
elementColumns[0] = column;
|
||||||
}
|
}
|
||||||
//override the table
|
//override the table
|
||||||
for (Ejb3Column column : elementColumns) {
|
for (AnnotatedColumn column : elementColumns) {
|
||||||
column.setTable( collValue.getCollectionTable() );
|
column.setTable( collValue.getCollectionTable() );
|
||||||
}
|
}
|
||||||
elementBinder.setColumns( elementColumns );
|
elementBinder.setColumns( elementColumns );
|
||||||
|
@ -1827,7 +1827,7 @@ public abstract class CollectionBinder {
|
||||||
private static void bindCollectionSecondPass(
|
private static void bindCollectionSecondPass(
|
||||||
Collection collValue,
|
Collection collValue,
|
||||||
PersistentClass collectionEntity,
|
PersistentClass collectionEntity,
|
||||||
Ejb3JoinColumn[] joinColumns,
|
AnnotatedJoinColumn[] joinColumns,
|
||||||
boolean cascadeDeleteEnabled,
|
boolean cascadeDeleteEnabled,
|
||||||
XProperty property,
|
XProperty property,
|
||||||
PropertyHolder propertyHolder,
|
PropertyHolder propertyHolder,
|
||||||
|
@ -1875,7 +1875,7 @@ public abstract class CollectionBinder {
|
||||||
*/
|
*/
|
||||||
public static void bindManytoManyInverseFk(
|
public static void bindManytoManyInverseFk(
|
||||||
PersistentClass referencedEntity,
|
PersistentClass referencedEntity,
|
||||||
Ejb3JoinColumn[] columns,
|
AnnotatedJoinColumn[] columns,
|
||||||
SimpleValue value,
|
SimpleValue value,
|
||||||
boolean unique,
|
boolean unique,
|
||||||
MetadataBuildingContext buildingContext) {
|
MetadataBuildingContext buildingContext) {
|
||||||
|
@ -1927,15 +1927,15 @@ public abstract class CollectionBinder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFkJoinColumns(Ejb3JoinColumn[] ejb3JoinColumns) {
|
public void setFkJoinColumns(AnnotatedJoinColumn[] annotatedJoinColumns) {
|
||||||
this.fkJoinColumns = ejb3JoinColumns;
|
this.fkJoinColumns = annotatedJoinColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExplicitAssociationTable(boolean explicitAssocTable) {
|
public void setExplicitAssociationTable(boolean explicitAssocTable) {
|
||||||
this.isExplicitAssociationTable = explicitAssocTable;
|
this.isExplicitAssociationTable = explicitAssocTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setElementColumns(Ejb3Column[] elementColumns) {
|
public void setElementColumns(AnnotatedColumn[] elementColumns) {
|
||||||
this.elementColumns = elementColumns;
|
this.elementColumns = elementColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1951,11 +1951,11 @@ public abstract class CollectionBinder {
|
||||||
this.ignoreNotFound = ignoreNotFound;
|
this.ignoreNotFound = ignoreNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMapKeyColumns(Ejb3Column[] mapKeyColumns) {
|
public void setMapKeyColumns(AnnotatedColumn[] mapKeyColumns) {
|
||||||
this.mapKeyColumns = mapKeyColumns;
|
this.mapKeyColumns = mapKeyColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMapKeyManyToManyColumns(Ejb3JoinColumn[] mapJoinColumns) {
|
public void setMapKeyManyToManyColumns(AnnotatedJoinColumn[] mapJoinColumns) {
|
||||||
this.mapKeyManyToManyColumns = mapJoinColumns;
|
this.mapKeyManyToManyColumns = mapJoinColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.cfg.AccessType;
|
import org.hibernate.cfg.AccessType;
|
||||||
import org.hibernate.cfg.AnnotationBinder;
|
import org.hibernate.cfg.AnnotationBinder;
|
||||||
import org.hibernate.cfg.BinderHelper;
|
import org.hibernate.cfg.BinderHelper;
|
||||||
import org.hibernate.cfg.Ejb3JoinColumn;
|
import org.hibernate.cfg.AnnotatedJoinColumn;
|
||||||
import org.hibernate.cfg.InheritanceState;
|
import org.hibernate.cfg.InheritanceState;
|
||||||
import org.hibernate.cfg.ObjectNameSource;
|
import org.hibernate.cfg.ObjectNameSource;
|
||||||
import org.hibernate.cfg.PropertyHolder;
|
import org.hibernate.cfg.PropertyHolder;
|
||||||
|
@ -849,7 +849,7 @@ public class EntityBinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createPrimaryColumnsToSecondaryTable(Object uncastedColumn, PropertyHolder propertyHolder, Join join) {
|
private void createPrimaryColumnsToSecondaryTable(Object uncastedColumn, PropertyHolder propertyHolder, Join join) {
|
||||||
Ejb3JoinColumn[] ejb3JoinColumns;
|
AnnotatedJoinColumn[] annotatedJoinColumns;
|
||||||
PrimaryKeyJoinColumn[] pkColumnsAnn = null;
|
PrimaryKeyJoinColumn[] pkColumnsAnn = null;
|
||||||
JoinColumn[] joinColumnsAnn = null;
|
JoinColumn[] joinColumnsAnn = null;
|
||||||
if ( uncastedColumn instanceof PrimaryKeyJoinColumn[] ) {
|
if ( uncastedColumn instanceof PrimaryKeyJoinColumn[] ) {
|
||||||
|
@ -859,8 +859,8 @@ public class EntityBinder {
|
||||||
joinColumnsAnn = (JoinColumn[]) uncastedColumn;
|
joinColumnsAnn = (JoinColumn[]) uncastedColumn;
|
||||||
}
|
}
|
||||||
if ( pkColumnsAnn == null && joinColumnsAnn == null ) {
|
if ( pkColumnsAnn == null && joinColumnsAnn == null ) {
|
||||||
ejb3JoinColumns = new Ejb3JoinColumn[1];
|
annotatedJoinColumns = new AnnotatedJoinColumn[1];
|
||||||
ejb3JoinColumns[0] = Ejb3JoinColumn.buildJoinColumn(
|
annotatedJoinColumns[0] = AnnotatedJoinColumn.buildJoinColumn(
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
persistentClass.getIdentifier(),
|
persistentClass.getIdentifier(),
|
||||||
|
@ -874,8 +874,8 @@ public class EntityBinder {
|
||||||
pkColumnsAnn.length :
|
pkColumnsAnn.length :
|
||||||
joinColumnsAnn.length;
|
joinColumnsAnn.length;
|
||||||
if ( nbrOfJoinColumns == 0 ) {
|
if ( nbrOfJoinColumns == 0 ) {
|
||||||
ejb3JoinColumns = new Ejb3JoinColumn[1];
|
annotatedJoinColumns = new AnnotatedJoinColumn[1];
|
||||||
ejb3JoinColumns[0] = Ejb3JoinColumn.buildJoinColumn(
|
annotatedJoinColumns[0] = AnnotatedJoinColumn.buildJoinColumn(
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
persistentClass.getIdentifier(),
|
persistentClass.getIdentifier(),
|
||||||
|
@ -885,10 +885,10 @@ public class EntityBinder {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ejb3JoinColumns = new Ejb3JoinColumn[nbrOfJoinColumns];
|
annotatedJoinColumns = new AnnotatedJoinColumn[nbrOfJoinColumns];
|
||||||
if ( pkColumnsAnn != null ) {
|
if ( pkColumnsAnn != null ) {
|
||||||
for (int colIndex = 0; colIndex < nbrOfJoinColumns; colIndex++) {
|
for (int colIndex = 0; colIndex < nbrOfJoinColumns; colIndex++) {
|
||||||
ejb3JoinColumns[colIndex] = Ejb3JoinColumn.buildJoinColumn(
|
annotatedJoinColumns[colIndex] = AnnotatedJoinColumn.buildJoinColumn(
|
||||||
pkColumnsAnn[colIndex],
|
pkColumnsAnn[colIndex],
|
||||||
null,
|
null,
|
||||||
persistentClass.getIdentifier(),
|
persistentClass.getIdentifier(),
|
||||||
|
@ -900,7 +900,7 @@ public class EntityBinder {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (int colIndex = 0; colIndex < nbrOfJoinColumns; colIndex++) {
|
for (int colIndex = 0; colIndex < nbrOfJoinColumns; colIndex++) {
|
||||||
ejb3JoinColumns[colIndex] = Ejb3JoinColumn.buildJoinColumn(
|
annotatedJoinColumns[colIndex] = AnnotatedJoinColumn.buildJoinColumn(
|
||||||
null,
|
null,
|
||||||
joinColumnsAnn[colIndex],
|
joinColumnsAnn[colIndex],
|
||||||
persistentClass.getIdentifier(),
|
persistentClass.getIdentifier(),
|
||||||
|
@ -913,18 +913,18 @@ public class EntityBinder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Ejb3JoinColumn joinColumn : ejb3JoinColumns) {
|
for (AnnotatedJoinColumn joinColumn : annotatedJoinColumns) {
|
||||||
joinColumn.forceNotNull();
|
joinColumn.forceNotNull();
|
||||||
}
|
}
|
||||||
bindJoinToPersistentClass( join, ejb3JoinColumns, context );
|
bindJoinToPersistentClass( join, annotatedJoinColumns, context );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindJoinToPersistentClass(Join join, Ejb3JoinColumn[] ejb3JoinColumns, MetadataBuildingContext buildingContext) {
|
private void bindJoinToPersistentClass(Join join, AnnotatedJoinColumn[] annotatedJoinColumns, MetadataBuildingContext buildingContext) {
|
||||||
SimpleValue key = new DependantValue( buildingContext, join.getTable(), persistentClass.getIdentifier() );
|
SimpleValue key = new DependantValue( buildingContext, join.getTable(), persistentClass.getIdentifier() );
|
||||||
join.setKey( key );
|
join.setKey( key );
|
||||||
setFKNameIfDefined( join );
|
setFKNameIfDefined( join );
|
||||||
key.setCascadeDeleteEnabled( false );
|
key.setCascadeDeleteEnabled( false );
|
||||||
TableBinder.bindFk( persistentClass, null, ejb3JoinColumns, key, false, buildingContext );
|
TableBinder.bindFk( persistentClass, null, annotatedJoinColumns, key, false, buildingContext );
|
||||||
join.createPrimaryKey();
|
join.createPrimaryKey();
|
||||||
join.createForeignKey();
|
join.createForeignKey();
|
||||||
persistentClass.addJoin( join );
|
persistentClass.addJoin( join );
|
||||||
|
|
|
@ -15,8 +15,8 @@ import org.hibernate.annotations.common.reflection.XClass;
|
||||||
import org.hibernate.annotations.common.reflection.XProperty;
|
import org.hibernate.annotations.common.reflection.XProperty;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.cfg.BinderHelper;
|
import org.hibernate.cfg.BinderHelper;
|
||||||
import org.hibernate.cfg.Ejb3Column;
|
import org.hibernate.cfg.AnnotatedColumn;
|
||||||
import org.hibernate.cfg.Ejb3JoinColumn;
|
import org.hibernate.cfg.AnnotatedJoinColumn;
|
||||||
import org.hibernate.cfg.IdGeneratorResolverSecondPass;
|
import org.hibernate.cfg.IdGeneratorResolverSecondPass;
|
||||||
import org.hibernate.cfg.PropertyData;
|
import org.hibernate.cfg.PropertyData;
|
||||||
import org.hibernate.cfg.PropertyInferredData;
|
import org.hibernate.cfg.PropertyInferredData;
|
||||||
|
@ -47,10 +47,10 @@ public class IdBagBinder extends BagBinder {
|
||||||
protected boolean bindStarToManySecondPass(
|
protected boolean bindStarToManySecondPass(
|
||||||
Map persistentClasses,
|
Map persistentClasses,
|
||||||
XClass collType,
|
XClass collType,
|
||||||
Ejb3JoinColumn[] fkJoinColumns,
|
AnnotatedJoinColumn[] fkJoinColumns,
|
||||||
Ejb3JoinColumn[] keyColumns,
|
AnnotatedJoinColumn[] keyColumns,
|
||||||
Ejb3JoinColumn[] inverseColumns,
|
AnnotatedJoinColumn[] inverseColumns,
|
||||||
Ejb3Column[] elementColumns,
|
AnnotatedColumn[] elementColumns,
|
||||||
boolean isEmbedded,
|
boolean isEmbedded,
|
||||||
XProperty property,
|
XProperty property,
|
||||||
boolean unique,
|
boolean unique,
|
||||||
|
@ -78,7 +78,7 @@ public class IdBagBinder extends BagBinder {
|
||||||
"id"
|
"id"
|
||||||
);
|
);
|
||||||
|
|
||||||
final Ejb3Column[] idColumns = Ejb3Column.buildColumnFromAnnotation(
|
final AnnotatedColumn[] idColumns = AnnotatedColumn.buildColumnFromAnnotation(
|
||||||
new Column[] { collectionIdAnn.column() },
|
new Column[] { collectionIdAnn.column() },
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
@ -90,7 +90,7 @@ public class IdBagBinder extends BagBinder {
|
||||||
);
|
);
|
||||||
|
|
||||||
//we need to make sure all id columns must be not-null.
|
//we need to make sure all id columns must be not-null.
|
||||||
for ( Ejb3Column idColumn:idColumns ) {
|
for ( AnnotatedColumn idColumn:idColumns ) {
|
||||||
idColumn.setNullable( false );
|
idColumn.setNullable( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,15 +8,14 @@ package org.hibernate.cfg.annotations;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.AnnotationException;
|
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.annotations.OrderBy;
|
import org.hibernate.annotations.OrderBy;
|
||||||
import org.hibernate.annotations.common.reflection.XClass;
|
import org.hibernate.annotations.common.reflection.XClass;
|
||||||
import org.hibernate.annotations.common.reflection.XProperty;
|
import org.hibernate.annotations.common.reflection.XProperty;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.cfg.CollectionSecondPass;
|
import org.hibernate.cfg.CollectionSecondPass;
|
||||||
import org.hibernate.cfg.Ejb3Column;
|
import org.hibernate.cfg.AnnotatedColumn;
|
||||||
import org.hibernate.cfg.Ejb3JoinColumn;
|
import org.hibernate.cfg.AnnotatedJoinColumn;
|
||||||
import org.hibernate.cfg.PropertyHolder;
|
import org.hibernate.cfg.PropertyHolder;
|
||||||
import org.hibernate.cfg.PropertyHolderBuilder;
|
import org.hibernate.cfg.PropertyHolderBuilder;
|
||||||
import org.hibernate.cfg.SecondPass;
|
import org.hibernate.cfg.SecondPass;
|
||||||
|
@ -60,12 +59,12 @@ public class ListBinder extends CollectionBinder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecondPass getSecondPass(
|
public SecondPass getSecondPass(
|
||||||
final Ejb3JoinColumn[] fkJoinColumns,
|
final AnnotatedJoinColumn[] fkJoinColumns,
|
||||||
final Ejb3JoinColumn[] keyColumns,
|
final AnnotatedJoinColumn[] keyColumns,
|
||||||
final Ejb3JoinColumn[] inverseColumns,
|
final AnnotatedJoinColumn[] inverseColumns,
|
||||||
final Ejb3Column[] elementColumns,
|
final AnnotatedColumn[] elementColumns,
|
||||||
Ejb3Column[] mapKeyColumns,
|
AnnotatedColumn[] mapKeyColumns,
|
||||||
final Ejb3JoinColumn[] mapKeyManyToManyColumns,
|
final AnnotatedJoinColumn[] mapKeyManyToManyColumns,
|
||||||
final boolean isEmbedded,
|
final boolean isEmbedded,
|
||||||
final XProperty property,
|
final XProperty property,
|
||||||
final XClass collType,
|
final XClass collType,
|
||||||
|
@ -118,7 +117,7 @@ public class ListBinder extends CollectionBinder {
|
||||||
}
|
}
|
||||||
indexColumn.setPropertyHolder( valueHolder );
|
indexColumn.setPropertyHolder( valueHolder );
|
||||||
final BasicValueBinder valueBinder = new BasicValueBinder( BasicValueBinder.Kind.LIST_INDEX, buildingContext );
|
final BasicValueBinder valueBinder = new BasicValueBinder( BasicValueBinder.Kind.LIST_INDEX, buildingContext );
|
||||||
valueBinder.setColumns( new Ejb3Column[] { indexColumn } );
|
valueBinder.setColumns( new AnnotatedColumn[] { indexColumn } );
|
||||||
valueBinder.setReturnedClassName( Integer.class.getName() );
|
valueBinder.setReturnedClassName( Integer.class.getName() );
|
||||||
valueBinder.setType( property, collType, null, null );
|
valueBinder.setType( property, collType, null, null );
|
||||||
// valueBinder.setExplicitType( "integer" );
|
// valueBinder.setExplicitType( "integer" );
|
||||||
|
|
|
@ -24,8 +24,8 @@ import org.hibernate.cfg.AnnotationBinder;
|
||||||
import org.hibernate.cfg.BinderHelper;
|
import org.hibernate.cfg.BinderHelper;
|
||||||
import org.hibernate.cfg.CollectionPropertyHolder;
|
import org.hibernate.cfg.CollectionPropertyHolder;
|
||||||
import org.hibernate.cfg.CollectionSecondPass;
|
import org.hibernate.cfg.CollectionSecondPass;
|
||||||
import org.hibernate.cfg.Ejb3Column;
|
import org.hibernate.cfg.AnnotatedColumn;
|
||||||
import org.hibernate.cfg.Ejb3JoinColumn;
|
import org.hibernate.cfg.AnnotatedJoinColumn;
|
||||||
import org.hibernate.cfg.InheritanceState;
|
import org.hibernate.cfg.InheritanceState;
|
||||||
import org.hibernate.cfg.PropertyData;
|
import org.hibernate.cfg.PropertyData;
|
||||||
import org.hibernate.cfg.PropertyHolderBuilder;
|
import org.hibernate.cfg.PropertyHolderBuilder;
|
||||||
|
@ -78,12 +78,12 @@ public class MapBinder extends CollectionBinder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecondPass getSecondPass(
|
public SecondPass getSecondPass(
|
||||||
final Ejb3JoinColumn[] fkJoinColumns,
|
final AnnotatedJoinColumn[] fkJoinColumns,
|
||||||
final Ejb3JoinColumn[] keyColumns,
|
final AnnotatedJoinColumn[] keyColumns,
|
||||||
final Ejb3JoinColumn[] inverseColumns,
|
final AnnotatedJoinColumn[] inverseColumns,
|
||||||
final Ejb3Column[] elementColumns,
|
final AnnotatedColumn[] elementColumns,
|
||||||
final Ejb3Column[] mapKeyColumns,
|
final AnnotatedColumn[] mapKeyColumns,
|
||||||
final Ejb3JoinColumn[] mapKeyManyToManyColumns,
|
final AnnotatedJoinColumn[] mapKeyManyToManyColumns,
|
||||||
final boolean isEmbedded,
|
final boolean isEmbedded,
|
||||||
final XProperty property,
|
final XProperty property,
|
||||||
final XClass collType,
|
final XClass collType,
|
||||||
|
@ -159,8 +159,8 @@ public class MapBinder extends CollectionBinder {
|
||||||
XProperty property,
|
XProperty property,
|
||||||
boolean isEmbedded,
|
boolean isEmbedded,
|
||||||
MetadataBuildingContext buildingContext,
|
MetadataBuildingContext buildingContext,
|
||||||
Ejb3Column[] mapKeyColumns,
|
AnnotatedColumn[] mapKeyColumns,
|
||||||
Ejb3JoinColumn[] mapKeyManyToManyColumns,
|
AnnotatedJoinColumn[] mapKeyManyToManyColumns,
|
||||||
String targetPropertyName) {
|
String targetPropertyName) {
|
||||||
if ( mapKeyPropertyName != null ) {
|
if ( mapKeyPropertyName != null ) {
|
||||||
//this is an EJB3 @MapKey
|
//this is an EJB3 @MapKey
|
||||||
|
@ -302,10 +302,10 @@ public class MapBinder extends CollectionBinder {
|
||||||
final BasicValueBinder elementBinder = new BasicValueBinder( BasicValueBinder.Kind.MAP_KEY, buildingContext );
|
final BasicValueBinder elementBinder = new BasicValueBinder( BasicValueBinder.Kind.MAP_KEY, buildingContext );
|
||||||
elementBinder.setReturnedClassName( mapKeyType );
|
elementBinder.setReturnedClassName( mapKeyType );
|
||||||
|
|
||||||
Ejb3Column[] elementColumns = mapKeyColumns;
|
AnnotatedColumn[] elementColumns = mapKeyColumns;
|
||||||
if ( elementColumns == null || elementColumns.length == 0 ) {
|
if ( elementColumns == null || elementColumns.length == 0 ) {
|
||||||
elementColumns = new Ejb3Column[1];
|
elementColumns = new AnnotatedColumn[1];
|
||||||
Ejb3Column column = new Ejb3Column();
|
AnnotatedColumn column = new AnnotatedColumn();
|
||||||
column.setImplicit( false );
|
column.setImplicit( false );
|
||||||
column.setNullable( true );
|
column.setNullable( true );
|
||||||
column.setLength( Size.DEFAULT_LENGTH );
|
column.setLength( Size.DEFAULT_LENGTH );
|
||||||
|
@ -317,7 +317,7 @@ public class MapBinder extends CollectionBinder {
|
||||||
elementColumns[0] = column;
|
elementColumns[0] = column;
|
||||||
}
|
}
|
||||||
//override the table
|
//override the table
|
||||||
for (Ejb3Column column : elementColumns) {
|
for (AnnotatedColumn column : elementColumns) {
|
||||||
column.setTable( mapValue.getCollectionTable() );
|
column.setTable( mapValue.getCollectionTable() );
|
||||||
}
|
}
|
||||||
elementBinder.setColumns( elementColumns );
|
elementBinder.setColumns( elementColumns );
|
||||||
|
@ -337,7 +337,7 @@ public class MapBinder extends CollectionBinder {
|
||||||
//FIXME pass the Index Entity JoinColumns
|
//FIXME pass the Index Entity JoinColumns
|
||||||
if ( !collection.isOneToMany() ) {
|
if ( !collection.isOneToMany() ) {
|
||||||
//index column should not be null
|
//index column should not be null
|
||||||
for (Ejb3JoinColumn col : mapKeyManyToManyColumns) {
|
for (AnnotatedJoinColumn col : mapKeyManyToManyColumns) {
|
||||||
col.forceNotNull();
|
col.forceNotNull();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.cfg.AccessType;
|
import org.hibernate.cfg.AccessType;
|
||||||
import org.hibernate.cfg.AnnotationBinder;
|
import org.hibernate.cfg.AnnotationBinder;
|
||||||
import org.hibernate.cfg.BinderHelper;
|
import org.hibernate.cfg.BinderHelper;
|
||||||
import org.hibernate.cfg.Ejb3Column;
|
import org.hibernate.cfg.AnnotatedColumn;
|
||||||
import org.hibernate.cfg.InheritanceState;
|
import org.hibernate.cfg.InheritanceState;
|
||||||
import org.hibernate.cfg.PropertyHolder;
|
import org.hibernate.cfg.PropertyHolder;
|
||||||
import org.hibernate.cfg.PropertyPreloadedData;
|
import org.hibernate.cfg.PropertyPreloadedData;
|
||||||
|
@ -65,7 +65,7 @@ public class PropertyBinder {
|
||||||
private boolean lazy;
|
private boolean lazy;
|
||||||
private String lazyGroup;
|
private String lazyGroup;
|
||||||
private AccessType accessType;
|
private AccessType accessType;
|
||||||
private Ejb3Column[] columns;
|
private AnnotatedColumn[] columns;
|
||||||
private PropertyHolder holder;
|
private PropertyHolder holder;
|
||||||
private Value value;
|
private Value value;
|
||||||
private boolean insertable = true;
|
private boolean insertable = true;
|
||||||
|
@ -129,7 +129,7 @@ public class PropertyBinder {
|
||||||
this.accessType = accessType;
|
this.accessType = accessType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColumns(Ejb3Column[] columns) {
|
public void setColumns(AnnotatedColumn[] columns) {
|
||||||
insertable = columns[0].isInsertable();
|
insertable = columns[0].isInsertable();
|
||||||
updatable = columns[0].isUpdatable();
|
updatable = columns[0].isUpdatable();
|
||||||
//consistency is checked later when we know the property name
|
//consistency is checked later when we know the property name
|
||||||
|
|
|
@ -24,12 +24,10 @@ import org.hibernate.boot.model.source.spi.AttributePath;
|
||||||
import org.hibernate.boot.spi.InFlightMetadataCollector;
|
import org.hibernate.boot.spi.InFlightMetadataCollector;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.cfg.BinderHelper;
|
import org.hibernate.cfg.BinderHelper;
|
||||||
import org.hibernate.cfg.Ejb3JoinColumn;
|
import org.hibernate.cfg.AnnotatedJoinColumn;
|
||||||
import org.hibernate.cfg.IndexOrUniqueKeySecondPass;
|
import org.hibernate.cfg.IndexOrUniqueKeySecondPass;
|
||||||
import org.hibernate.cfg.JPAIndexHolder;
|
import org.hibernate.cfg.JPAIndexHolder;
|
||||||
import org.hibernate.cfg.ObjectNameSource;
|
import org.hibernate.cfg.ObjectNameSource;
|
||||||
import org.hibernate.cfg.SimpleToOneFkSecondPass;
|
|
||||||
import org.hibernate.cfg.ToOneFkSecondPass;
|
|
||||||
import org.hibernate.cfg.UniqueConstraintHolder;
|
import org.hibernate.cfg.UniqueConstraintHolder;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
|
@ -536,7 +534,7 @@ public class TableBinder {
|
||||||
public static void bindFk(
|
public static void bindFk(
|
||||||
PersistentClass referencedEntity,
|
PersistentClass referencedEntity,
|
||||||
PersistentClass destinationEntity,
|
PersistentClass destinationEntity,
|
||||||
Ejb3JoinColumn[] columns,
|
AnnotatedJoinColumn[] columns,
|
||||||
SimpleValue value,
|
SimpleValue value,
|
||||||
boolean unique,
|
boolean unique,
|
||||||
MetadataBuildingContext buildingContext) {
|
MetadataBuildingContext buildingContext) {
|
||||||
|
@ -599,9 +597,9 @@ public class TableBinder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int fkEnum = Ejb3JoinColumn.checkReferencedColumnsType( columns, referencedEntity, buildingContext );
|
int fkEnum = AnnotatedJoinColumn.checkReferencedColumnsType( columns, referencedEntity, buildingContext );
|
||||||
|
|
||||||
if ( Ejb3JoinColumn.NON_PK_REFERENCE == fkEnum ) {
|
if ( AnnotatedJoinColumn.NON_PK_REFERENCE == fkEnum ) {
|
||||||
String referencedPropertyName;
|
String referencedPropertyName;
|
||||||
if ( value instanceof ToOne ) {
|
if ( value instanceof ToOne ) {
|
||||||
referencedPropertyName = ( (ToOne) value ).getReferencedPropertyName();
|
referencedPropertyName = ( (ToOne) value ).getReferencedPropertyName();
|
||||||
|
@ -641,7 +639,7 @@ public class TableBinder {
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( Ejb3JoinColumn.NO_REFERENCE == fkEnum ) {
|
if ( AnnotatedJoinColumn.NO_REFERENCE == fkEnum ) {
|
||||||
//implicit case, we hope PK and FK columns are in the same order
|
//implicit case, we hope PK and FK columns are in the same order
|
||||||
if ( columns.length != referencedEntity.getIdentifier().getColumnSpan() ) {
|
if ( columns.length != referencedEntity.getIdentifier().getColumnSpan() ) {
|
||||||
throw new AnnotationException(
|
throw new AnnotationException(
|
||||||
|
@ -676,7 +674,7 @@ public class TableBinder {
|
||||||
//for each PK column, find the associated FK column.
|
//for each PK column, find the associated FK column.
|
||||||
col = (Column) idColItr.next();
|
col = (Column) idColItr.next();
|
||||||
final String colName = col.getQuotedName( buildingContext.getMetadataCollector().getDatabase().getJdbcEnvironment().getDialect() );
|
final String colName = col.getQuotedName( buildingContext.getMetadataCollector().getDatabase().getJdbcEnvironment().getDialect() );
|
||||||
for (Ejb3JoinColumn joinCol : columns) {
|
for (AnnotatedJoinColumn joinCol : columns) {
|
||||||
String referencedColumn = joinCol.getReferencedColumn();
|
String referencedColumn = joinCol.getReferencedColumn();
|
||||||
referencedColumn = buildingContext.getMetadataCollector().getPhysicalColumnName(
|
referencedColumn = buildingContext.getMetadataCollector().getPhysicalColumnName(
|
||||||
table,
|
table,
|
||||||
|
@ -721,9 +719,9 @@ public class TableBinder {
|
||||||
public static void linkJoinColumnWithValueOverridingNameIfImplicit(
|
public static void linkJoinColumnWithValueOverridingNameIfImplicit(
|
||||||
PersistentClass referencedEntity,
|
PersistentClass referencedEntity,
|
||||||
Iterator columnIterator,
|
Iterator columnIterator,
|
||||||
Ejb3JoinColumn[] columns,
|
AnnotatedJoinColumn[] columns,
|
||||||
SimpleValue value) {
|
SimpleValue value) {
|
||||||
for (Ejb3JoinColumn joinCol : columns) {
|
for (AnnotatedJoinColumn joinCol : columns) {
|
||||||
Column synthCol = (Column) columnIterator.next();
|
Column synthCol = (Column) columnIterator.next();
|
||||||
if ( joinCol.isNameDeferred() ) {
|
if ( joinCol.isNameDeferred() ) {
|
||||||
//this has to be the default value
|
//this has to be the default value
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.hibernate.MappingException;
|
||||||
import org.hibernate.annotations.common.reflection.XClass;
|
import org.hibernate.annotations.common.reflection.XClass;
|
||||||
import org.hibernate.boot.spi.InFlightMetadataCollector;
|
import org.hibernate.boot.spi.InFlightMetadataCollector;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.cfg.Ejb3JoinColumn;
|
import org.hibernate.cfg.AnnotatedJoinColumn;
|
||||||
import org.hibernate.cfg.InheritanceState;
|
import org.hibernate.cfg.InheritanceState;
|
||||||
import org.hibernate.cfg.PropertyHolder;
|
import org.hibernate.cfg.PropertyHolder;
|
||||||
import org.hibernate.cfg.annotations.CollectionBinder;
|
import org.hibernate.cfg.annotations.CollectionBinder;
|
||||||
|
@ -74,7 +74,7 @@ public class CollectionBinderTest extends BaseUnitTestCase {
|
||||||
public void bindOneToManySecondPass(
|
public void bindOneToManySecondPass(
|
||||||
Collection collection,
|
Collection collection,
|
||||||
Map<String, PersistentClass> persistentClasses,
|
Map<String, PersistentClass> persistentClasses,
|
||||||
Ejb3JoinColumn[] fkJoinColumns,
|
AnnotatedJoinColumn[] fkJoinColumns,
|
||||||
XClass collectionType,
|
XClass collectionType,
|
||||||
boolean cascadeDeleteEnabled,
|
boolean cascadeDeleteEnabled,
|
||||||
boolean ignoreNotFound,
|
boolean ignoreNotFound,
|
||||||
|
|
|
@ -13,7 +13,7 @@ import jakarta.persistence.InheritanceType;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.cfg.Ejb3DiscriminatorColumn;
|
import org.hibernate.cfg.AnnotatedDiscriminatorColumn;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.persister.entity.JoinedSubclassEntityPersister;
|
import org.hibernate.persister.entity.JoinedSubclassEntityPersister;
|
||||||
|
|
||||||
|
@ -54,11 +54,11 @@ public class JoinedSubclassWithImplicitDiscriminatorTest {
|
||||||
assertNotNull( p );
|
assertNotNull( p );
|
||||||
final JoinedSubclassEntityPersister dogPersister = assertTyping( JoinedSubclassEntityPersister.class, p );
|
final JoinedSubclassEntityPersister dogPersister = assertTyping( JoinedSubclassEntityPersister.class, p );
|
||||||
assertEquals(
|
assertEquals(
|
||||||
Ejb3DiscriminatorColumn.DEFAULT_DISCRIMINATOR_TYPE,
|
AnnotatedDiscriminatorColumn.DEFAULT_DISCRIMINATOR_TYPE,
|
||||||
dogPersister.getDiscriminatorType().getName()
|
dogPersister.getDiscriminatorType().getName()
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
Ejb3DiscriminatorColumn.DEFAULT_DISCRIMINATOR_COLUMN_NAME,
|
AnnotatedDiscriminatorColumn.DEFAULT_DISCRIMINATOR_COLUMN_NAME,
|
||||||
dogPersister.getDiscriminatorColumnName()
|
dogPersister.getDiscriminatorColumnName()
|
||||||
);
|
);
|
||||||
assertEquals( "Dog", dogPersister.getDiscriminatorValue() );
|
assertEquals( "Dog", dogPersister.getDiscriminatorValue() );
|
||||||
|
@ -67,11 +67,11 @@ public class JoinedSubclassWithImplicitDiscriminatorTest {
|
||||||
assertNotNull( p );
|
assertNotNull( p );
|
||||||
final JoinedSubclassEntityPersister catPersister = assertTyping( JoinedSubclassEntityPersister.class, p );
|
final JoinedSubclassEntityPersister catPersister = assertTyping( JoinedSubclassEntityPersister.class, p );
|
||||||
assertEquals(
|
assertEquals(
|
||||||
Ejb3DiscriminatorColumn.DEFAULT_DISCRIMINATOR_TYPE,
|
AnnotatedDiscriminatorColumn.DEFAULT_DISCRIMINATOR_TYPE,
|
||||||
catPersister.getDiscriminatorType().getName()
|
catPersister.getDiscriminatorType().getName()
|
||||||
);
|
);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
Ejb3DiscriminatorColumn.DEFAULT_DISCRIMINATOR_COLUMN_NAME,
|
AnnotatedDiscriminatorColumn.DEFAULT_DISCRIMINATOR_COLUMN_NAME,
|
||||||
catPersister.getDiscriminatorColumnName()
|
catPersister.getDiscriminatorColumnName()
|
||||||
);
|
);
|
||||||
assertEquals( "Cat", catPersister.getDiscriminatorValue() );
|
assertEquals( "Cat", catPersister.getDiscriminatorValue() );
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.boot.spi.MetadataImplementor;
|
import org.hibernate.boot.spi.MetadataImplementor;
|
||||||
|
import org.hibernate.cfg.AnnotatedJoinColumn;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.mapping.Column;
|
import org.hibernate.mapping.Column;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
|
@ -30,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link org.hibernate.cfg.Ejb3JoinColumn} and {@link org.hibernate.boot.model.naming.PhysicalNamingStrategy}
|
* Tests {@link AnnotatedJoinColumn} and {@link org.hibernate.boot.model.naming.PhysicalNamingStrategy}
|
||||||
* interaction
|
* interaction
|
||||||
*
|
*
|
||||||
* @author Anton Wimmer
|
* @author Anton Wimmer
|
||||||
|
|
|
@ -7,14 +7,14 @@
|
||||||
|
|
||||||
//$Id$
|
//$Id$
|
||||||
package org.hibernate.test.annotations;
|
package org.hibernate.test.annotations;
|
||||||
import org.hibernate.cfg.EJB3NamingStrategy;
|
import org.hibernate.cfg.PersistenceStandardNamingStrategy;
|
||||||
import org.hibernate.cfg.NamingStrategy;
|
import org.hibernate.cfg.NamingStrategy;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
*/
|
*/
|
||||||
public class AlternativeNamingStrategy extends EJB3NamingStrategy {
|
public class AlternativeNamingStrategy extends PersistenceStandardNamingStrategy {
|
||||||
public static NamingStrategy INSTANCE = new AlternativeNamingStrategy();
|
public static NamingStrategy INSTANCE = new AlternativeNamingStrategy();
|
||||||
|
|
||||||
public String classToTableName(String className) {
|
public String classToTableName(String className) {
|
||||||
|
|
Loading…
Reference in New Issue