[jOOQ/jOOQ#10588] Configuration should allow for explicit ordering of

key fields
This commit is contained in:
Lukas Eder 2020-09-10 10:44:42 +02:00
parent 2dbf3ab145
commit 373e725e9c
7 changed files with 290 additions and 233 deletions

View File

@ -1198,7 +1198,7 @@ public abstract class AbstractDatabase implements Database {
for (String syntheticPrimaryKey : syntheticPrimaryKeys) {
if (!StringUtils.isBlank(syntheticPrimaryKey)) {
log.warn("DEPRECATION", "The <syntheticPrimaryKeys/> configuration element has been deprecated in jOOQ 3.14. Use <syntheticObjects/> only, instead.");
getConfiguredSyntheticPrimaryKeys().add(new SyntheticPrimaryKeyType().withKeyFields(syntheticPrimaryKey));
getConfiguredSyntheticPrimaryKeys().add(new SyntheticPrimaryKeyType().withFields(syntheticPrimaryKey));
}
}
}
@ -1238,7 +1238,7 @@ public abstract class AbstractDatabase implements Database {
for (String syntheticIdentity : syntheticIdentities) {
if (!StringUtils.isBlank(syntheticIdentity)) {
log.warn("DEPRECATION", "The <syntheticIdentities/> configuration element has been deprecated in jOOQ 3.14. Use <syntheticObjects/> only, instead.");
getConfiguredSyntheticIdentities().add(new SyntheticIdentityType().withKeyFields(syntheticIdentity));
getConfiguredSyntheticIdentities().add(new SyntheticIdentityType().withFields(syntheticIdentity));
}
}
}
@ -2603,6 +2603,15 @@ public abstract class AbstractDatabase implements Database {
return filterExcludeInclude(definitions, null, include);
}
protected final <T extends Definition> List<T> filter(List<T> definitions, List<String> include) {
List<T> result = new ArrayList<>();
for (String i : include)
result.addAll(filter(definitions, i));
return result;
}
protected final <T extends Definition> List<T> filterExcludeInclude(List<T> definitions, String e, String i) {
return filterExcludeInclude(definitions, new String[] { e }, new String[] { i != null ? i : ".*" }, Collections.<Filter>emptyList());
}
@ -2874,7 +2883,7 @@ public abstract class AbstractDatabase implements Database {
if (key.getKey() == null)
continue keyLoop;
for (TableDefinition table : filter(getTables(), key.getKeyTables())) {
for (TableDefinition table : filter(getTables(), key.getTables())) {
for (UniqueKeyDefinition uk : filter(table.getUniqueKeys(), key.getKey())) {
log.info("Overriding primary key", "" + uk);
r.overridePrimaryKey(uk);
@ -2891,10 +2900,10 @@ public abstract class AbstractDatabase implements Database {
if (key.getKey() != null)
continue keyLoop;
for (TableDefinition table : filter(getTables(), key.getKeyTables())) {
for (TableDefinition table : filter(getTables(), key.getTables())) {
String keyName = key.getName() != null ? key.getName() : "SYNTHETIC_PK_" + table.getName();
List<ColumnDefinition> columns = filter(table.getColumns(), key.getKeyFields());
List<ColumnDefinition> columns = filter(table.getColumns(), key.getFields());
if (!columns.isEmpty()) {
markUsed(key);
@ -2963,7 +2972,6 @@ public abstract class AbstractDatabase implements Database {
@Override

View File

@ -78,8 +78,8 @@ public class DefaultColumnDefinition
AbstractDatabase db = (AbstractDatabase) column.getDatabase();
for (SyntheticIdentityType id : db.getConfiguredSyntheticIdentities()) {
for (TableDefinition t : db.filter(singletonList(column.getContainer()), id.getKeyTables())) {
for (ColumnDefinition c : db.filter(singletonList(column), id.getKeyFields())) {
for (TableDefinition t : db.filter(singletonList(column.getContainer()), id.getTables())) {
for (ColumnDefinition c : db.filter(singletonList(column), id.getFields())) {
log.info("Synthetic identity", column.getQualifiedName());
db.markUsed(id);
return true;

View File

@ -2,9 +2,13 @@
package org.jooq.meta.jaxb;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.jooq.util.jaxb.tools.StringAdapter;
@ -23,10 +27,10 @@ import org.jooq.util.jaxb.tools.XMLBuilder;
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
* &lt;all&gt;
* &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;element name="keyTables" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;element name="keyFields" type="{http://www.w3.org/2001/XMLSchema}string"/&gt;
* &lt;element name="tables" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;element name="fields" type="{http://www.jooq.org/xsd/jooq-codegen-3.13.0.xsd}SyntheticKeyFieldsType"/&gt;
* &lt;element name="referencedTable" type="{http://www.w3.org/2001/XMLSchema}string"/&gt;
* &lt;element name="referencedFields" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;element name="referencedFields" type="{http://www.jooq.org/xsd/jooq-codegen-3.13.0.xsd}SyntheticKeyFieldsType" minOccurs="0"/&gt;
* &lt;element name="referencedKey" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;/all&gt;
* &lt;/restriction&gt;
@ -50,17 +54,18 @@ public class SyntheticForeignKeyType implements Serializable, XMLAppendable
@XmlJavaTypeAdapter(StringAdapter.class)
protected String name;
@XmlJavaTypeAdapter(StringAdapter.class)
protected String keyTables;
@XmlElement(required = true)
@XmlJavaTypeAdapter(StringAdapter.class)
protected String keyFields;
protected String tables;
@XmlElement(required = true)
@XmlJavaTypeAdapter(StringAdapter.class)
protected String referencedTable;
@XmlJavaTypeAdapter(StringAdapter.class)
protected String referencedFields;
@XmlJavaTypeAdapter(StringAdapter.class)
protected String referencedKey;
@XmlElementWrapper(name = "fields", required = true)
@XmlElement(name = "field")
protected List<String> fields;
@XmlElementWrapper(name = "referencedFields")
@XmlElement(name = "field")
protected List<String> referencedFields;
/**
* The optional foreign key name.
@ -82,32 +87,16 @@ public class SyntheticForeignKeyType implements Serializable, XMLAppendable
* A regular expression matching all tables on which to apply this synthetic foreign key.
*
*/
public String getKeyTables() {
return keyTables;
public String getTables() {
return tables;
}
/**
* A regular expression matching all tables on which to apply this synthetic foreign key.
*
*/
public void setKeyTables(String value) {
this.keyTables = value;
}
/**
* A regular expression matching all fields on which to apply this synthetic foreign key.
*
*/
public String getKeyFields() {
return keyFields;
}
/**
* A regular expression matching all fields on which to apply this synthetic foreign key.
*
*/
public void setKeyFields(String value) {
this.keyFields = value;
public void setTables(String value) {
this.tables = value;
}
/**
@ -126,22 +115,6 @@ public class SyntheticForeignKeyType implements Serializable, XMLAppendable
this.referencedTable = value;
}
/**
* A regular expression matching fields that are referenced by this synthetic foreign key.
*
*/
public String getReferencedFields() {
return referencedFields;
}
/**
* A regular expression matching fields that are referenced by this synthetic foreign key.
*
*/
public void setReferencedFields(String value) {
this.referencedFields = value;
}
/**
* A regular expression matching a key that is referenced by this synthetic foreign key.
*
@ -158,6 +131,28 @@ public class SyntheticForeignKeyType implements Serializable, XMLAppendable
this.referencedKey = value;
}
public List<String> getFields() {
if (fields == null) {
fields = new ArrayList<String>();
}
return fields;
}
public void setFields(List<String> fields) {
this.fields = fields;
}
public List<String> getReferencedFields() {
if (referencedFields == null) {
referencedFields = new ArrayList<String>();
}
return referencedFields;
}
public void setReferencedFields(List<String> referencedFields) {
this.referencedFields = referencedFields;
}
/**
* The optional foreign key name.
*
@ -171,17 +166,8 @@ public class SyntheticForeignKeyType implements Serializable, XMLAppendable
* A regular expression matching all tables on which to apply this synthetic foreign key.
*
*/
public SyntheticForeignKeyType withKeyTables(String value) {
setKeyTables(value);
return this;
}
/**
* A regular expression matching all fields on which to apply this synthetic foreign key.
*
*/
public SyntheticForeignKeyType withKeyFields(String value) {
setKeyFields(value);
public SyntheticForeignKeyType withTables(String value) {
setTables(value);
return this;
}
@ -194,15 +180,6 @@ public class SyntheticForeignKeyType implements Serializable, XMLAppendable
return this;
}
/**
* A regular expression matching fields that are referenced by this synthetic foreign key.
*
*/
public SyntheticForeignKeyType withReferencedFields(String value) {
setReferencedFields(value);
return this;
}
/**
* A regular expression matching a key that is referenced by this synthetic foreign key.
*
@ -212,14 +189,56 @@ public class SyntheticForeignKeyType implements Serializable, XMLAppendable
return this;
}
public SyntheticForeignKeyType withFields(String... values) {
if (values!= null) {
for (String value: values) {
getFields().add(value);
}
}
return this;
}
public SyntheticForeignKeyType withFields(Collection<String> values) {
if (values!= null) {
getFields().addAll(values);
}
return this;
}
public SyntheticForeignKeyType withFields(List<String> fields) {
setFields(fields);
return this;
}
public SyntheticForeignKeyType withReferencedFields(String... values) {
if (values!= null) {
for (String value: values) {
getReferencedFields().add(value);
}
}
return this;
}
public SyntheticForeignKeyType withReferencedFields(Collection<String> values) {
if (values!= null) {
getReferencedFields().addAll(values);
}
return this;
}
public SyntheticForeignKeyType withReferencedFields(List<String> referencedFields) {
setReferencedFields(referencedFields);
return this;
}
@Override
public final void appendTo(XMLBuilder builder) {
builder.append("name", name);
builder.append("keyTables", keyTables);
builder.append("keyFields", keyFields);
builder.append("tables", tables);
builder.append("referencedTable", referencedTable);
builder.append("referencedFields", referencedFields);
builder.append("referencedKey", referencedKey);
builder.append("fields", "field", fields);
builder.append("referencedFields", "field", referencedFields);
}
@Override
@ -250,21 +269,12 @@ public class SyntheticForeignKeyType implements Serializable, XMLAppendable
return false;
}
}
if (keyTables == null) {
if (other.keyTables!= null) {
if (tables == null) {
if (other.tables!= null) {
return false;
}
} else {
if (!keyTables.equals(other.keyTables)) {
return false;
}
}
if (keyFields == null) {
if (other.keyFields!= null) {
return false;
}
} else {
if (!keyFields.equals(other.keyFields)) {
if (!tables.equals(other.tables)) {
return false;
}
}
@ -277,15 +287,6 @@ public class SyntheticForeignKeyType implements Serializable, XMLAppendable
return false;
}
}
if (referencedFields == null) {
if (other.referencedFields!= null) {
return false;
}
} else {
if (!referencedFields.equals(other.referencedFields)) {
return false;
}
}
if (referencedKey == null) {
if (other.referencedKey!= null) {
return false;
@ -295,6 +296,24 @@ public class SyntheticForeignKeyType implements Serializable, XMLAppendable
return false;
}
}
if (fields == null) {
if (other.fields!= null) {
return false;
}
} else {
if (!fields.equals(other.fields)) {
return false;
}
}
if (referencedFields == null) {
if (other.referencedFields!= null) {
return false;
}
} else {
if (!referencedFields.equals(other.referencedFields)) {
return false;
}
}
return true;
}
@ -303,11 +322,11 @@ public class SyntheticForeignKeyType implements Serializable, XMLAppendable
final int prime = 31;
int result = 1;
result = ((prime*result)+((name == null)? 0 :name.hashCode()));
result = ((prime*result)+((keyTables == null)? 0 :keyTables.hashCode()));
result = ((prime*result)+((keyFields == null)? 0 :keyFields.hashCode()));
result = ((prime*result)+((tables == null)? 0 :tables.hashCode()));
result = ((prime*result)+((referencedTable == null)? 0 :referencedTable.hashCode()));
result = ((prime*result)+((referencedFields == null)? 0 :referencedFields.hashCode()));
result = ((prime*result)+((referencedKey == null)? 0 :referencedKey.hashCode()));
result = ((prime*result)+((fields == null)? 0 :fields.hashCode()));
result = ((prime*result)+((referencedFields == null)? 0 :referencedFields.hashCode()));
return result;
}

View File

@ -22,8 +22,8 @@ import org.jooq.util.jaxb.tools.XMLBuilder;
* &lt;complexContent&gt;
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
* &lt;all&gt;
* &lt;element name="keyTables" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;element name="keyFields" type="{http://www.w3.org/2001/XMLSchema}string"/&gt;
* &lt;element name="tables" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;element name="fields" type="{http://www.w3.org/2001/XMLSchema}string"/&gt;
* &lt;/all&gt;
* &lt;/restriction&gt;
* &lt;/complexContent&gt;
@ -44,49 +44,49 @@ public class SyntheticIdentityType implements Serializable, XMLAppendable
private final static long serialVersionUID = 31400L;
@XmlJavaTypeAdapter(StringAdapter.class)
protected String keyTables;
protected String tables;
@XmlElement(required = true)
@XmlJavaTypeAdapter(StringAdapter.class)
protected String keyFields;
protected String fields;
/**
* A regular expression matching all tables on which to apply this synthetic identity.
*
*/
public String getKeyTables() {
return keyTables;
public String getTables() {
return tables;
}
/**
* A regular expression matching all tables on which to apply this synthetic identity.
*
*/
public void setKeyTables(String value) {
this.keyTables = value;
public void setTables(String value) {
this.tables = value;
}
/**
* A regular expression matching all fields on which to apply this synthetic identity.
*
*/
public String getKeyFields() {
return keyFields;
public String getFields() {
return fields;
}
/**
* A regular expression matching all fields on which to apply this synthetic identity.
*
*/
public void setKeyFields(String value) {
this.keyFields = value;
public void setFields(String value) {
this.fields = value;
}
/**
* A regular expression matching all tables on which to apply this synthetic identity.
*
*/
public SyntheticIdentityType withKeyTables(String value) {
setKeyTables(value);
public SyntheticIdentityType withTables(String value) {
setTables(value);
return this;
}
@ -94,15 +94,15 @@ public class SyntheticIdentityType implements Serializable, XMLAppendable
* A regular expression matching all fields on which to apply this synthetic identity.
*
*/
public SyntheticIdentityType withKeyFields(String value) {
setKeyFields(value);
public SyntheticIdentityType withFields(String value) {
setFields(value);
return this;
}
@Override
public final void appendTo(XMLBuilder builder) {
builder.append("keyTables", keyTables);
builder.append("keyFields", keyFields);
builder.append("tables", tables);
builder.append("fields", fields);
}
@Override
@ -124,21 +124,21 @@ public class SyntheticIdentityType implements Serializable, XMLAppendable
return false;
}
SyntheticIdentityType other = ((SyntheticIdentityType) that);
if (keyTables == null) {
if (other.keyTables!= null) {
if (tables == null) {
if (other.tables!= null) {
return false;
}
} else {
if (!keyTables.equals(other.keyTables)) {
if (!tables.equals(other.tables)) {
return false;
}
}
if (keyFields == null) {
if (other.keyFields!= null) {
if (fields == null) {
if (other.fields!= null) {
return false;
}
} else {
if (!keyFields.equals(other.keyFields)) {
if (!fields.equals(other.fields)) {
return false;
}
}
@ -149,8 +149,8 @@ public class SyntheticIdentityType implements Serializable, XMLAppendable
public int hashCode() {
final int prime = 31;
int result = 1;
result = ((prime*result)+((keyTables == null)? 0 :keyTables.hashCode()));
result = ((prime*result)+((keyFields == null)? 0 :keyFields.hashCode()));
result = ((prime*result)+((tables == null)? 0 :tables.hashCode()));
result = ((prime*result)+((fields == null)? 0 :fields.hashCode()));
return result;
}

View File

@ -2,9 +2,13 @@
package org.jooq.meta.jaxb;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.jooq.util.jaxb.tools.StringAdapter;
@ -23,8 +27,8 @@ import org.jooq.util.jaxb.tools.XMLBuilder;
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
* &lt;all&gt;
* &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;element name="keyTables" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;element name="keyFields" type="{http://www.w3.org/2001/XMLSchema}string"/&gt;
* &lt;element name="tables" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;element name="fields" type="{http://www.jooq.org/xsd/jooq-codegen-3.13.0.xsd}SyntheticKeyFieldsType"/&gt;
* &lt;element name="key" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;/all&gt;
* &lt;/restriction&gt;
@ -48,12 +52,12 @@ public class SyntheticPrimaryKeyType implements Serializable, XMLAppendable
@XmlJavaTypeAdapter(StringAdapter.class)
protected String name;
@XmlJavaTypeAdapter(StringAdapter.class)
protected String keyTables;
@XmlElement(required = true)
@XmlJavaTypeAdapter(StringAdapter.class)
protected String keyFields;
protected String tables;
@XmlJavaTypeAdapter(StringAdapter.class)
protected String key;
@XmlElementWrapper(name = "fields", required = true)
@XmlElement(name = "field")
protected List<String> fields;
/**
* The optional primary key name.
@ -75,32 +79,16 @@ public class SyntheticPrimaryKeyType implements Serializable, XMLAppendable
* A regular expression matching all tables on which to apply this synthetic primary key.
*
*/
public String getKeyTables() {
return keyTables;
public String getTables() {
return tables;
}
/**
* A regular expression matching all tables on which to apply this synthetic primary key.
*
*/
public void setKeyTables(String value) {
this.keyTables = value;
}
/**
* A regular expression matching all fields on which to apply this new synthetic primary key.
*
*/
public String getKeyFields() {
return keyFields;
}
/**
* A regular expression matching all fields on which to apply this new synthetic primary key.
*
*/
public void setKeyFields(String value) {
this.keyFields = value;
public void setTables(String value) {
this.tables = value;
}
/**
@ -119,6 +107,17 @@ public class SyntheticPrimaryKeyType implements Serializable, XMLAppendable
this.key = value;
}
public List<String> getFields() {
if (fields == null) {
fields = new ArrayList<String>();
}
return fields;
}
public void setFields(List<String> fields) {
this.fields = fields;
}
/**
* The optional primary key name.
*
@ -132,17 +131,8 @@ public class SyntheticPrimaryKeyType implements Serializable, XMLAppendable
* A regular expression matching all tables on which to apply this synthetic primary key.
*
*/
public SyntheticPrimaryKeyType withKeyTables(String value) {
setKeyTables(value);
return this;
}
/**
* A regular expression matching all fields on which to apply this new synthetic primary key.
*
*/
public SyntheticPrimaryKeyType withKeyFields(String value) {
setKeyFields(value);
public SyntheticPrimaryKeyType withTables(String value) {
setTables(value);
return this;
}
@ -155,12 +145,33 @@ public class SyntheticPrimaryKeyType implements Serializable, XMLAppendable
return this;
}
public SyntheticPrimaryKeyType withFields(String... values) {
if (values!= null) {
for (String value: values) {
getFields().add(value);
}
}
return this;
}
public SyntheticPrimaryKeyType withFields(Collection<String> values) {
if (values!= null) {
getFields().addAll(values);
}
return this;
}
public SyntheticPrimaryKeyType withFields(List<String> fields) {
setFields(fields);
return this;
}
@Override
public final void appendTo(XMLBuilder builder) {
builder.append("name", name);
builder.append("keyTables", keyTables);
builder.append("keyFields", keyFields);
builder.append("tables", tables);
builder.append("key", key);
builder.append("fields", "field", fields);
}
@Override
@ -191,21 +202,12 @@ public class SyntheticPrimaryKeyType implements Serializable, XMLAppendable
return false;
}
}
if (keyTables == null) {
if (other.keyTables!= null) {
if (tables == null) {
if (other.tables!= null) {
return false;
}
} else {
if (!keyTables.equals(other.keyTables)) {
return false;
}
}
if (keyFields == null) {
if (other.keyFields!= null) {
return false;
}
} else {
if (!keyFields.equals(other.keyFields)) {
if (!tables.equals(other.tables)) {
return false;
}
}
@ -218,6 +220,15 @@ public class SyntheticPrimaryKeyType implements Serializable, XMLAppendable
return false;
}
}
if (fields == null) {
if (other.fields!= null) {
return false;
}
} else {
if (!fields.equals(other.fields)) {
return false;
}
}
return true;
}
@ -226,9 +237,9 @@ public class SyntheticPrimaryKeyType implements Serializable, XMLAppendable
final int prime = 31;
int result = 1;
result = ((prime*result)+((name == null)? 0 :name.hashCode()));
result = ((prime*result)+((keyTables == null)? 0 :keyTables.hashCode()));
result = ((prime*result)+((keyFields == null)? 0 :keyFields.hashCode()));
result = ((prime*result)+((tables == null)? 0 :tables.hashCode()));
result = ((prime*result)+((key == null)? 0 :key.hashCode()));
result = ((prime*result)+((fields == null)? 0 :fields.hashCode()));
return result;
}

View File

@ -2,9 +2,13 @@
package org.jooq.meta.jaxb;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.jooq.util.jaxb.tools.StringAdapter;
@ -23,8 +27,8 @@ import org.jooq.util.jaxb.tools.XMLBuilder;
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
* &lt;all&gt;
* &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;element name="keyTables" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;element name="keyFields" type="{http://www.w3.org/2001/XMLSchema}string"/&gt;
* &lt;element name="tables" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;element name="fields" type="{http://www.jooq.org/xsd/jooq-codegen-3.13.0.xsd}SyntheticKeyFieldsType"/&gt;
* &lt;/all&gt;
* &lt;/restriction&gt;
* &lt;/complexContent&gt;
@ -47,10 +51,10 @@ public class SyntheticUniqueKeyType implements Serializable, XMLAppendable
@XmlJavaTypeAdapter(StringAdapter.class)
protected String name;
@XmlJavaTypeAdapter(StringAdapter.class)
protected String keyTables;
@XmlElement(required = true)
@XmlJavaTypeAdapter(StringAdapter.class)
protected String keyFields;
protected String tables;
@XmlElementWrapper(name = "fields", required = true)
@XmlElement(name = "field")
protected List<String> fields;
/**
* The optional unique key name.
@ -72,32 +76,27 @@ public class SyntheticUniqueKeyType implements Serializable, XMLAppendable
* A regular expression matching all tables on which to apply this synthetic unique key.
*
*/
public String getKeyTables() {
return keyTables;
public String getTables() {
return tables;
}
/**
* A regular expression matching all tables on which to apply this synthetic unique key.
*
*/
public void setKeyTables(String value) {
this.keyTables = value;
public void setTables(String value) {
this.tables = value;
}
/**
* A regular expression matching all fields on which to apply this synthetic unique key.
*
*/
public String getKeyFields() {
return keyFields;
public List<String> getFields() {
if (fields == null) {
fields = new ArrayList<String>();
}
return fields;
}
/**
* A regular expression matching all fields on which to apply this synthetic unique key.
*
*/
public void setKeyFields(String value) {
this.keyFields = value;
public void setFields(List<String> fields) {
this.fields = fields;
}
/**
@ -113,25 +112,37 @@ public class SyntheticUniqueKeyType implements Serializable, XMLAppendable
* A regular expression matching all tables on which to apply this synthetic unique key.
*
*/
public SyntheticUniqueKeyType withKeyTables(String value) {
setKeyTables(value);
public SyntheticUniqueKeyType withTables(String value) {
setTables(value);
return this;
}
/**
* A regular expression matching all fields on which to apply this synthetic unique key.
*
*/
public SyntheticUniqueKeyType withKeyFields(String value) {
setKeyFields(value);
public SyntheticUniqueKeyType withFields(String... values) {
if (values!= null) {
for (String value: values) {
getFields().add(value);
}
}
return this;
}
public SyntheticUniqueKeyType withFields(Collection<String> values) {
if (values!= null) {
getFields().addAll(values);
}
return this;
}
public SyntheticUniqueKeyType withFields(List<String> fields) {
setFields(fields);
return this;
}
@Override
public final void appendTo(XMLBuilder builder) {
builder.append("name", name);
builder.append("keyTables", keyTables);
builder.append("keyFields", keyFields);
builder.append("tables", tables);
builder.append("fields", "field", fields);
}
@Override
@ -162,21 +173,21 @@ public class SyntheticUniqueKeyType implements Serializable, XMLAppendable
return false;
}
}
if (keyTables == null) {
if (other.keyTables!= null) {
if (tables == null) {
if (other.tables!= null) {
return false;
}
} else {
if (!keyTables.equals(other.keyTables)) {
if (!tables.equals(other.tables)) {
return false;
}
}
if (keyFields == null) {
if (other.keyFields!= null) {
if (fields == null) {
if (other.fields!= null) {
return false;
}
} else {
if (!keyFields.equals(other.keyFields)) {
if (!fields.equals(other.fields)) {
return false;
}
}
@ -188,8 +199,8 @@ public class SyntheticUniqueKeyType implements Serializable, XMLAppendable
final int prime = 31;
int result = 1;
result = ((prime*result)+((name == null)? 0 :name.hashCode()));
result = ((prime*result)+((keyTables == null)? 0 :keyTables.hashCode()));
result = ((prime*result)+((keyFields == null)? 0 :keyFields.hashCode()));
result = ((prime*result)+((tables == null)? 0 :tables.hashCode()));
result = ((prime*result)+((fields == null)? 0 :fields.hashCode()));
return result;
}

View File

@ -945,11 +945,11 @@ for Oracle.]]></jxb:javadoc></jxb:property></appinfo></annotation>
<complexType name="SyntheticIdentityType">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Synthetic identity configuration]]></jxb:javadoc></jxb:property></appinfo></annotation>
<all>
<element name="keyTables" type="string" minOccurs="0" maxOccurs="1">
<element name="tables" type="string" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[A regular expression matching all tables on which to apply this synthetic identity.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="keyFields" type="string" minOccurs="1" maxOccurs="1">
<element name="fields" type="string" minOccurs="1" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[A regular expression matching all fields on which to apply this synthetic identity.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
</all>
@ -968,12 +968,12 @@ for Oracle.]]></jxb:javadoc></jxb:property></appinfo></annotation>
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[The optional primary key name.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="keyTables" type="string" minOccurs="0" maxOccurs="1">
<element name="tables" type="string" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[A regular expression matching all tables on which to apply this synthetic primary key.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="keyFields" type="string" minOccurs="1" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[A regular expression matching all fields on which to apply this new synthetic primary key.]]></jxb:javadoc></jxb:property></appinfo></annotation>
<element name="fields" type="tns:SyntheticKeyFieldsType" minOccurs="1" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[A set of regular expressions matching all fields in order on which to apply this new synthetic primary key.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="key" type="string" minOccurs="0" maxOccurs="1">
@ -995,12 +995,12 @@ for Oracle.]]></jxb:javadoc></jxb:property></appinfo></annotation>
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[The optional unique key name.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="keyTables" type="string" minOccurs="0" maxOccurs="1">
<element name="tables" type="string" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[A regular expression matching all tables on which to apply this synthetic unique key.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="keyFields" type="string" minOccurs="1" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[A regular expression matching all fields on which to apply this synthetic unique key.]]></jxb:javadoc></jxb:property></appinfo></annotation>
<element name="fields" type="tns:SyntheticKeyFieldsType" minOccurs="1" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[A set of regular expressions matching all fields in order on which to apply this synthetic unique key.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
</all>
</complexType>
@ -1018,20 +1018,20 @@ for Oracle.]]></jxb:javadoc></jxb:property></appinfo></annotation>
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[The optional foreign key name.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="keyTables" type="string" minOccurs="0" maxOccurs="1">
<element name="tables" type="string" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[A regular expression matching all tables on which to apply this synthetic foreign key.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="keyFields" type="string" minOccurs="1" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[A regular expression matching all fields on which to apply this synthetic foreign key.]]></jxb:javadoc></jxb:property></appinfo></annotation>
<element name="fields" type="tns:SyntheticKeyFieldsType" minOccurs="1" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[A set of regular expressions matching fields in order on which to apply this synthetic foreign key.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="referencedTable" type="string" minOccurs="1" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[A regular expression matching a table that is referenced by this synthetic foreign key.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="referencedFields" type="string" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[A regular expression matching fields that are referenced by this synthetic foreign key.]]></jxb:javadoc></jxb:property></appinfo></annotation>
<element name="referencedFields" type="tns:SyntheticKeyFieldsType" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[A set regular of regular expressions matching fields in order that are referenced by this synthetic foreign key.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="referencedKey" type="string" minOccurs="0" maxOccurs="1">
@ -1039,7 +1039,15 @@ for Oracle.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
</all>
</complexType>
<complexType name="SyntheticKeyFieldsType">
<sequence>
<element name="field" type="string" minOccurs="1" maxOccurs="unbounded">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[A regular expression matching a key field that is referenced by a synthetic key.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
</sequence>
</complexType>
<complexType name="CatalogMappingsType">
<sequence>
<element name="catalog" type="tns:CatalogMappingType" minOccurs="1" maxOccurs="unbounded"/>