[jOOQ/jOOQ#9663] Add code generator support for NOT ENFORCED constraint flag
This depends on [jOOQ/jOOQ#9672] Add ConstraintDefinition
This commit is contained in:
parent
ce43c415c1
commit
f1bbecc136
@ -223,20 +223,21 @@ public class XMLGenerator extends AbstractGenerator {
|
||||
TableDefinition table = u.getTable();
|
||||
List<ColumnDefinition> columns = u.getKeyColumns();
|
||||
|
||||
TableConstraint constraint = new TableConstraint();
|
||||
constraint.setConstraintCatalog(catalogName);
|
||||
constraint.setConstraintSchema(schemaName);
|
||||
constraint.setConstraintName(constraintName);
|
||||
constraint.setConstraintType(u.isPrimaryKey() ? PRIMARY_KEY : UNIQUE);
|
||||
TableConstraint tc = new TableConstraint();
|
||||
tc.setConstraintCatalog(catalogName);
|
||||
tc.setConstraintSchema(schemaName);
|
||||
tc.setConstraintName(constraintName);
|
||||
tc.setConstraintType(u.isPrimaryKey() ? PRIMARY_KEY : UNIQUE);
|
||||
|
||||
if (generateCommentsOnKeys())
|
||||
constraint.setComment(u.getComment());
|
||||
tc.setComment(u.getComment());
|
||||
|
||||
constraint.setTableCatalog(table.getCatalog().getOutputName());
|
||||
constraint.setTableSchema(table.getSchema().getOutputName());
|
||||
constraint.setTableName(table.getOutputName());
|
||||
tc.setTableCatalog(table.getCatalog().getOutputName());
|
||||
tc.setTableSchema(table.getSchema().getOutputName());
|
||||
tc.setTableName(table.getOutputName());
|
||||
tc.setEnforced(u.enforced());
|
||||
|
||||
is.getTableConstraints().add(constraint);
|
||||
is.getTableConstraints().add(tc);
|
||||
|
||||
for (int i = 0; i < columns.size(); i++) {
|
||||
ColumnDefinition column = columns.get(i);
|
||||
@ -274,6 +275,7 @@ public class XMLGenerator extends AbstractGenerator {
|
||||
tc.setTableCatalog(table.getCatalog().getOutputName());
|
||||
tc.setTableSchema(table.getSchema().getOutputName());
|
||||
tc.setTableName(table.getOutputName());
|
||||
tc.setEnforced(f.enforced());
|
||||
|
||||
ReferentialConstraint rc = new ReferentialConstraint();
|
||||
rc.setConstraintCatalog(catalogName);
|
||||
@ -320,6 +322,7 @@ public class XMLGenerator extends AbstractGenerator {
|
||||
tc.setTableCatalog(table.getCatalog().getOutputName());
|
||||
tc.setTableSchema(table.getSchema().getOutputName());
|
||||
tc.setTableName(table.getOutputName());
|
||||
tc.setEnforced(ch.enforced());
|
||||
|
||||
is.getTableConstraints().add(tc);
|
||||
|
||||
|
||||
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.meta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public class AbstractConstraintDefinition extends AbstractDefinition implements ConstraintDefinition {
|
||||
|
||||
private final TableDefinition table;
|
||||
private final boolean enforced;
|
||||
|
||||
public AbstractConstraintDefinition(SchemaDefinition schema, TableDefinition table, String name, boolean enforced) {
|
||||
super(schema.getDatabase(), schema, name, null);
|
||||
|
||||
this.table = table;
|
||||
this.enforced = enforced;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Definition> getDefinitionPath() {
|
||||
List<Definition> result = new ArrayList<>();
|
||||
|
||||
result.addAll(getSchema().getDefinitionPath());
|
||||
result.add(this);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDefinition getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enforced() {
|
||||
return enforced;
|
||||
}
|
||||
}
|
||||
@ -42,15 +42,10 @@ package org.jooq.meta;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface CheckConstraintDefinition extends Definition {
|
||||
public interface CheckConstraintDefinition extends ConstraintDefinition {
|
||||
|
||||
/**
|
||||
* The check clause.
|
||||
*/
|
||||
String getCheckClause();
|
||||
|
||||
/**
|
||||
* The containing table.
|
||||
*/
|
||||
TableDefinition getTable();
|
||||
}
|
||||
|
||||
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.meta;
|
||||
|
||||
/**
|
||||
* An object holding information about a constraint.
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface ConstraintDefinition extends Definition {
|
||||
|
||||
/**
|
||||
* The table holding this constraint.
|
||||
*/
|
||||
TableDefinition getTable();
|
||||
|
||||
/**
|
||||
* Whether this constraint is enforced.
|
||||
*/
|
||||
boolean enforced();
|
||||
}
|
||||
@ -37,36 +37,20 @@
|
||||
*/
|
||||
package org.jooq.meta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
public class DefaultCheckConstraintDefinition extends AbstractConstraintDefinition implements CheckConstraintDefinition {
|
||||
|
||||
public class DefaultCheckConstraintDefinition extends AbstractDefinition implements CheckConstraintDefinition {
|
||||
|
||||
private final TableDefinition table;
|
||||
private final String checkClause;
|
||||
|
||||
public DefaultCheckConstraintDefinition(SchemaDefinition schema, TableDefinition table, String name, String checkClause) {
|
||||
super(schema.getDatabase(), schema, name, null);
|
||||
this(schema, table, name, checkClause, true);
|
||||
}
|
||||
|
||||
public DefaultCheckConstraintDefinition(SchemaDefinition schema, TableDefinition table, String name, String checkClause, boolean enforced) {
|
||||
super(schema, table, name, enforced);
|
||||
|
||||
this.table = table;
|
||||
this.checkClause = checkClause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Definition> getDefinitionPath() {
|
||||
List<Definition> result = new ArrayList<>();
|
||||
|
||||
result.addAll(getSchema().getDefinitionPath());
|
||||
result.add(this);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDefinition getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCheckClause() {
|
||||
return checkClause;
|
||||
|
||||
@ -42,35 +42,25 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class DefaultForeignKeyDefinition extends AbstractDefinition implements ForeignKeyDefinition {
|
||||
public class DefaultForeignKeyDefinition extends AbstractConstraintDefinition implements ForeignKeyDefinition {
|
||||
|
||||
private final List<ColumnDefinition> keyColumns;
|
||||
private final TableDefinition table;
|
||||
private final UniqueKeyDefinition uniqueKey;
|
||||
|
||||
public DefaultForeignKeyDefinition(SchemaDefinition schema, String name, TableDefinition table,
|
||||
UniqueKeyDefinition uniqueKey) {
|
||||
public DefaultForeignKeyDefinition(SchemaDefinition schema, String name, TableDefinition table, UniqueKeyDefinition uniqueKey) {
|
||||
this(schema, name, table, uniqueKey, true);
|
||||
}
|
||||
|
||||
super(schema.getDatabase(), schema, name, null);
|
||||
public DefaultForeignKeyDefinition(SchemaDefinition schema, String name, TableDefinition table, UniqueKeyDefinition uniqueKey, boolean enforced) {
|
||||
super(schema, table, name, enforced);
|
||||
|
||||
this.keyColumns = new ArrayList<>();
|
||||
this.table = table;
|
||||
this.uniqueKey = uniqueKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Definition> getDefinitionPath() {
|
||||
List<Definition> result = new ArrayList<>();
|
||||
|
||||
result.addAll(getSchema().getDefinitionPath());
|
||||
result.add(this);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDefinition getKeyTable() {
|
||||
return table;
|
||||
return getTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -97,11 +87,9 @@ public class DefaultForeignKeyDefinition extends AbstractDefinition implements F
|
||||
public int countSimilarReferences() {
|
||||
Set<String> keys = new HashSet<>();
|
||||
|
||||
for (ForeignKeyDefinition key : getDatabase().getRelations().getForeignKeys(table)) {
|
||||
if (key.getReferencedTable().equals(getReferencedTable())) {
|
||||
for (ForeignKeyDefinition key : getDatabase().getRelations().getForeignKeys(getTable()))
|
||||
if (key.getReferencedTable().equals(getReferencedTable()))
|
||||
keys.add(key.getName());
|
||||
}
|
||||
}
|
||||
|
||||
return keys.size();
|
||||
}
|
||||
|
||||
@ -66,6 +66,10 @@ public class DefaultRelations implements Relations {
|
||||
private transient Map<TableDefinition, List<CheckConstraintDefinition>> checkConstraintsByTable;
|
||||
|
||||
public void addPrimaryKey(String keyName, TableDefinition table, ColumnDefinition column) {
|
||||
addPrimaryKey(keyName, table, column, true);
|
||||
}
|
||||
|
||||
public void addPrimaryKey(String keyName, TableDefinition table, ColumnDefinition column, boolean enforced) {
|
||||
Key key = key(table, keyName);
|
||||
|
||||
// [#2718] Column exclusions may hit primary key references. Ignore
|
||||
@ -89,11 +93,15 @@ public class DefaultRelations implements Relations {
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("Adding primary key", keyName + " (" + column + ")");
|
||||
|
||||
UniqueKeyDefinition result = getUniqueKey(keyName, table, column, true);
|
||||
UniqueKeyDefinition result = getUniqueKey(keyName, table, column, true, enforced);
|
||||
result.getKeyColumns().add(column);
|
||||
}
|
||||
|
||||
public void addUniqueKey(String keyName, TableDefinition table, ColumnDefinition column) {
|
||||
addUniqueKey(keyName, table, column, true);
|
||||
}
|
||||
|
||||
public void addUniqueKey(String keyName, TableDefinition table, ColumnDefinition column, boolean enforced) {
|
||||
Key key = key(table, keyName);
|
||||
|
||||
// [#2718] Column exclusions may hit unique key references. Ignore
|
||||
@ -116,7 +124,7 @@ public class DefaultRelations implements Relations {
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("Adding unique key", keyName + " (" + column + ")");
|
||||
|
||||
UniqueKeyDefinition result = getUniqueKey(keyName, table, column, false);
|
||||
UniqueKeyDefinition result = getUniqueKey(keyName, table, column, false, enforced);
|
||||
result.getKeyColumns().add(column);
|
||||
}
|
||||
|
||||
@ -151,12 +159,12 @@ public class DefaultRelations implements Relations {
|
||||
", new key : " + key.getName());
|
||||
}
|
||||
|
||||
private UniqueKeyDefinition getUniqueKey(String keyName, TableDefinition table, ColumnDefinition column, boolean isPK) {
|
||||
private UniqueKeyDefinition getUniqueKey(String keyName, TableDefinition table, ColumnDefinition column, boolean isPK, boolean enforced) {
|
||||
Key key = key(table, keyName);
|
||||
UniqueKeyDefinition result = uniqueKeys.get(key);
|
||||
|
||||
if (result == null) {
|
||||
result = new DefaultUniqueKeyDefinition(column.getSchema(), keyName, table, isPK);
|
||||
result = new DefaultUniqueKeyDefinition(column.getSchema(), keyName, table, isPK, enforced);
|
||||
uniqueKeys.put(key, result);
|
||||
|
||||
if (isPK)
|
||||
@ -172,6 +180,16 @@ public class DefaultRelations implements Relations {
|
||||
ColumnDefinition foreignKeyColumn,
|
||||
String uniqueKeyName,
|
||||
TableDefinition uniqueKeyTable) {
|
||||
addForeignKey(foreignKeyName, foreignKeyTable, foreignKeyColumn, uniqueKeyName, uniqueKeyTable, true);
|
||||
}
|
||||
|
||||
public void addForeignKey(
|
||||
String foreignKeyName,
|
||||
TableDefinition foreignKeyTable,
|
||||
ColumnDefinition foreignKeyColumn,
|
||||
String uniqueKeyName,
|
||||
TableDefinition uniqueKeyTable,
|
||||
boolean enforced) {
|
||||
|
||||
|
||||
// [#2718] Column exclusions may hit foreign key references. Ignore
|
||||
@ -208,7 +226,7 @@ public class DefaultRelations implements Relations {
|
||||
|
||||
// If the unique key is not loaded, ignore this foreign key
|
||||
if (uniqueKey != null) {
|
||||
foreignKey = new DefaultForeignKeyDefinition(foreignKeyColumn.getSchema(), foreignKeyName, foreignKeyColumn.getContainer(), uniqueKey);
|
||||
foreignKey = new DefaultForeignKeyDefinition(foreignKeyColumn.getSchema(), foreignKeyName, foreignKeyColumn.getContainer(), uniqueKey, enforced);
|
||||
foreignKeys.put(key, foreignKey);
|
||||
|
||||
uniqueKey.getForeignKeys().add(foreignKey);
|
||||
|
||||
@ -40,19 +40,21 @@ package org.jooq.meta;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DefaultUniqueKeyDefinition extends AbstractDefinition implements UniqueKeyDefinition {
|
||||
public class DefaultUniqueKeyDefinition extends AbstractConstraintDefinition implements UniqueKeyDefinition {
|
||||
|
||||
private final List<ForeignKeyDefinition> foreignKeys;
|
||||
private final List<ColumnDefinition> keyColumns;
|
||||
private final TableDefinition table;
|
||||
private final boolean isPrimaryKey;
|
||||
|
||||
public DefaultUniqueKeyDefinition(SchemaDefinition schema, String name, TableDefinition table, boolean isPrimaryKey) {
|
||||
super(schema.getDatabase(), schema, name, null);
|
||||
this(schema, name, table, isPrimaryKey, true);
|
||||
}
|
||||
|
||||
public DefaultUniqueKeyDefinition(SchemaDefinition schema, String name, TableDefinition table, boolean isPrimaryKey, boolean enforced) {
|
||||
super(schema, table, name, enforced);
|
||||
|
||||
this.foreignKeys = new ArrayList<>();
|
||||
this.keyColumns = new ArrayList<>();
|
||||
this.table = table;
|
||||
this.isPrimaryKey = isPrimaryKey;
|
||||
}
|
||||
|
||||
@ -61,16 +63,6 @@ public class DefaultUniqueKeyDefinition extends AbstractDefinition implements Un
|
||||
return isPrimaryKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Definition> getDefinitionPath() {
|
||||
List<Definition> result = new ArrayList<>();
|
||||
|
||||
result.addAll(getSchema().getDefinitionPath());
|
||||
result.add(this);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ColumnDefinition> getKeyColumns() {
|
||||
return keyColumns;
|
||||
@ -80,9 +72,4 @@ public class DefaultUniqueKeyDefinition extends AbstractDefinition implements Un
|
||||
public List<ForeignKeyDefinition> getForeignKeys() {
|
||||
return foreignKeys;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDefinition getTable() {
|
||||
return table;
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,11 +44,14 @@ import java.util.List;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface ForeignKeyDefinition extends Definition {
|
||||
public interface ForeignKeyDefinition extends ConstraintDefinition {
|
||||
|
||||
/**
|
||||
* The definition of the referencing table
|
||||
*
|
||||
* @deprecated - [#9672] - jOOQ 3.13 - Use {@link ConstraintDefinition#getTable()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
TableDefinition getKeyTable();
|
||||
|
||||
/**
|
||||
|
||||
@ -47,7 +47,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface UniqueKeyDefinition extends Definition {
|
||||
public interface UniqueKeyDefinition extends ConstraintDefinition {
|
||||
|
||||
/**
|
||||
* Whether this unique key is the primary key
|
||||
@ -63,9 +63,4 @@ public interface UniqueKeyDefinition extends Definition {
|
||||
* The foreign keys referencing this primary key
|
||||
*/
|
||||
List<ForeignKeyDefinition> getForeignKeys();
|
||||
|
||||
/**
|
||||
* The table holding this key
|
||||
*/
|
||||
TableDefinition getTable();
|
||||
}
|
||||
|
||||
@ -341,9 +341,10 @@ public class XMLDatabase extends AbstractDatabase {
|
||||
String tableName = usage.getTableName();
|
||||
String columnName = usage.getColumnName();
|
||||
|
||||
TableConstraint tc = tableConstraint(usage.getConstraintCatalog(), usage.getConstraintSchema(), usage.getConstraintName());
|
||||
TableDefinition table = getTable(schema, tableName);
|
||||
if (table != null)
|
||||
relations.addPrimaryKey(key, table, table.getColumn(columnName));
|
||||
relations.addPrimaryKey(key, table, table.getColumn(columnName), tc.isEnforced());
|
||||
}
|
||||
}
|
||||
|
||||
@ -355,9 +356,10 @@ public class XMLDatabase extends AbstractDatabase {
|
||||
String tableName = usage.getTableName();
|
||||
String columnName = usage.getColumnName();
|
||||
|
||||
TableConstraint tc = tableConstraint(usage.getConstraintCatalog(), usage.getConstraintSchema(), usage.getConstraintName());
|
||||
TableDefinition table = getTable(schema, tableName);
|
||||
if (table != null)
|
||||
relations.addUniqueKey(key, table, table.getColumn(columnName));
|
||||
relations.addUniqueKey(key, table, table.getColumn(columnName), tc.isEnforced());
|
||||
}
|
||||
}
|
||||
|
||||
@ -414,11 +416,12 @@ public class XMLDatabase extends AbstractDatabase {
|
||||
String foreignKeyTableName = usage.getTableName();
|
||||
String foreignKeyColumn = usage.getColumnName();
|
||||
String uniqueKey = fk.getUniqueConstraintName();
|
||||
TableConstraint uk = tableConstraint(fk.getUniqueConstraintCatalog(), fk.getUniqueConstraintSchema(), fk.getUniqueConstraintName());
|
||||
TableConstraint fktc = tableConstraint(fk.getConstraintCatalog(), fk.getConstraintSchema(), fk.getConstraintName());
|
||||
TableConstraint uktc = tableConstraint(fk.getUniqueConstraintCatalog(), fk.getUniqueConstraintSchema(), fk.getUniqueConstraintName());
|
||||
|
||||
if (uk != null) {
|
||||
if (uktc != null) {
|
||||
TableDefinition foreignKeyTable = getTable(foreignKeySchema, foreignKeyTableName);
|
||||
TableDefinition uniqueKeyTable = getTable(uniqueKeySchema, uk.getTableName());
|
||||
TableDefinition uniqueKeyTable = getTable(uniqueKeySchema, uktc.getTableName());
|
||||
|
||||
if (foreignKeyTable != null && uniqueKeyTable != null)
|
||||
relations.addForeignKey(
|
||||
@ -426,7 +429,8 @@ public class XMLDatabase extends AbstractDatabase {
|
||||
foreignKeyTable,
|
||||
foreignKeyTable.getColumn(foreignKeyColumn),
|
||||
uniqueKey,
|
||||
uniqueKeyTable
|
||||
uniqueKeyTable,
|
||||
fktc.isEnforced()
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -465,7 +469,7 @@ public class XMLDatabase extends AbstractDatabase {
|
||||
if (table == null)
|
||||
continue constraintLoop;
|
||||
|
||||
r.addCheckConstraint(table, new DefaultCheckConstraintDefinition(schema, table, check.getConstraintName(), check.getCheckClause()));
|
||||
r.addCheckConstraint(table, new DefaultCheckConstraintDefinition(schema, table, check.getConstraintName(), check.getCheckClause(), tc.isEnforced()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@ import org.jooq.util.jaxb.tools.XMLBuilder;
|
||||
* <element name="table_schema" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
|
||||
* <element name="table_name" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||
* <element name="comment" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
|
||||
* <element name="enforced" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
|
||||
* </all>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
@ -73,6 +74,7 @@ public class TableConstraint implements Serializable, XMLAppendable
|
||||
protected String tableName;
|
||||
@XmlJavaTypeAdapter(StringAdapter.class)
|
||||
protected String comment;
|
||||
protected Boolean enforced;
|
||||
|
||||
public String getConstraintCatalog() {
|
||||
return constraintCatalog;
|
||||
@ -138,6 +140,30 @@ public class TableConstraint implements Serializable, XMLAppendable
|
||||
this.comment = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the enforced property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public Boolean isEnforced() {
|
||||
return enforced;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the enforced property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public void setEnforced(Boolean value) {
|
||||
this.enforced = value;
|
||||
}
|
||||
|
||||
public TableConstraint withConstraintCatalog(String value) {
|
||||
setConstraintCatalog(value);
|
||||
return this;
|
||||
@ -178,6 +204,11 @@ public class TableConstraint implements Serializable, XMLAppendable
|
||||
return this;
|
||||
}
|
||||
|
||||
public TableConstraint withEnforced(Boolean value) {
|
||||
setEnforced(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void appendTo(XMLBuilder builder) {
|
||||
builder.append("constraint_catalog", constraintCatalog);
|
||||
@ -188,6 +219,7 @@ public class TableConstraint implements Serializable, XMLAppendable
|
||||
builder.append("table_schema", tableSchema);
|
||||
builder.append("table_name", tableName);
|
||||
builder.append("comment", comment);
|
||||
builder.append("enforced", enforced);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -281,6 +313,15 @@ public class TableConstraint implements Serializable, XMLAppendable
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (enforced == null) {
|
||||
if (other.enforced!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!enforced.equals(other.enforced)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -296,6 +337,7 @@ public class TableConstraint implements Serializable, XMLAppendable
|
||||
result = ((prime*result)+((tableSchema == null)? 0 :tableSchema.hashCode()));
|
||||
result = ((prime*result)+((tableName == null)? 0 :tableName.hashCode()));
|
||||
result = ((prime*result)+((comment == null)? 0 :comment.hashCode()));
|
||||
result = ((prime*result)+((enforced == null)? 0 :enforced.hashCode()));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -135,6 +135,7 @@
|
||||
<element name="table_schema" type="string" minOccurs="0" maxOccurs="1" />
|
||||
<element name="table_name" type="string" minOccurs="1" maxOccurs="1" />
|
||||
<element name="comment" type="string" minOccurs="0" maxOccurs="1" />
|
||||
<element name="enforced" type="boolean" minOccurs="0" maxOccurs="1" />
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user