[jOOQ/jOOQ#9603] Support sequence flags in jooq-meta.xsd
Sequence flags are now also supported in the jooq-meta.xsd model and everywhere where this is used.
This commit is contained in:
parent
f00cbabd5e
commit
9940a56afa
@ -347,6 +347,13 @@ public class XMLGenerator extends AbstractGenerator {
|
||||
sequence.setNumericPrecision(type.getPrecision());
|
||||
sequence.setNumericScale(type.getScale());
|
||||
|
||||
sequence.setStartWith(se.getStartWith());
|
||||
sequence.setIncrementBy(se.getIncrementBy());
|
||||
sequence.setMinValue(se.getMinValue());
|
||||
sequence.setMaxValue(se.getMaxValue());
|
||||
sequence.setCycle(se.getCycle());
|
||||
sequence.setCache(se.getCache());
|
||||
|
||||
is.getSequences().add(sequence);
|
||||
}
|
||||
|
||||
|
||||
@ -507,7 +507,17 @@ public class XMLDatabase extends AbstractDatabase {
|
||||
(String) null
|
||||
);
|
||||
|
||||
result.add(new DefaultSequenceDefinition(schema, sequence.getSequenceName(), type, sequence.getComment()));
|
||||
result.add(new DefaultSequenceDefinition(
|
||||
schema,
|
||||
sequence.getSequenceName(),
|
||||
type,
|
||||
sequence.getComment(),
|
||||
sequence.getStartWith(),
|
||||
sequence.getIncrementBy(),
|
||||
sequence.getMinValue(),
|
||||
sequence.getMaxValue(),
|
||||
Boolean.TRUE.equals(sequence.isCycle()),
|
||||
sequence.getCache()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -54,12 +54,14 @@ import org.jooq.Field;
|
||||
import org.jooq.ForeignKey;
|
||||
import org.jooq.Index;
|
||||
import org.jooq.Key;
|
||||
import org.jooq.Param;
|
||||
import org.jooq.Schema;
|
||||
import org.jooq.Sequence;
|
||||
import org.jooq.SortField;
|
||||
import org.jooq.SortOrder;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.UniqueKey;
|
||||
import org.jooq.tools.Convert;
|
||||
import org.jooq.tools.StringUtils;
|
||||
import org.jooq.util.xml.jaxb.CheckConstraint;
|
||||
import org.jooq.util.xml.jaxb.Column;
|
||||
@ -177,6 +179,18 @@ final class InformationSchemaExport {
|
||||
if (q.getDataType().hasScale())
|
||||
iq.setNumericScale(q.getDataType().scale());
|
||||
|
||||
if (q.getStartWith() != null)
|
||||
iq.setStartWith(Convert.convert(q.getStartWith() instanceof Param ? ((Param<?>) q.getStartWith()).getValue() : q.getStartWith().toString(), Long.class));
|
||||
if (q.getIncrementBy() != null)
|
||||
iq.setIncrementBy(Convert.convert(q.getIncrementBy() instanceof Param ? ((Param<?>) q.getIncrementBy()).getValue() : q.getIncrementBy().toString(), Long.class));
|
||||
if (q.getMinValue() != null)
|
||||
iq.setMinValue(Convert.convert(q.getMinValue() instanceof Param ? ((Param<?>) q.getMinValue()).getValue() : q.getMinValue().toString(), Long.class));
|
||||
if (q.getMaxValue() != null)
|
||||
iq.setMaxValue(Convert.convert(q.getMaxValue() instanceof Param ? ((Param<?>) q.getMaxValue()).getValue() : q.getMaxValue().toString(), Long.class));
|
||||
iq.setCycle(q.getCycle());
|
||||
if (q.getCache() != null)
|
||||
iq.setCache(Convert.convert(q.getCache() instanceof Param ? ((Param<?>) q.getCache()).getValue() : q.getCache().toString(), Long.class));
|
||||
|
||||
result.getSequences().add(iq);
|
||||
}
|
||||
|
||||
|
||||
@ -448,12 +448,24 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
|
||||
int precision = xs.getNumericPrecision() == null ? 0 : xs.getNumericPrecision();
|
||||
int scale = xs.getNumericScale() == null ? 0 : xs.getNumericScale();
|
||||
boolean nullable = true;
|
||||
Long startWith = xs.getStartWith();
|
||||
Long incrementBy = xs.getIncrementBy();
|
||||
Long minValue = xs.getMinValue();
|
||||
Long maxValue = xs.getMaxValue();
|
||||
Boolean cycle = xs.isCycle();
|
||||
Long cache = xs.getCache();
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
InformationSchemaSequence is = new InformationSchemaSequence(
|
||||
xs.getSequenceName(),
|
||||
schema,
|
||||
type(typeName, length, precision, scale, nullable)
|
||||
type(typeName, length, precision, scale, nullable),
|
||||
startWith,
|
||||
incrementBy,
|
||||
minValue,
|
||||
maxValue,
|
||||
cycle,
|
||||
cache
|
||||
);
|
||||
|
||||
sequences.add(is);
|
||||
@ -636,8 +648,18 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
|
||||
*/
|
||||
private static final long serialVersionUID = -1246697252597049756L;
|
||||
|
||||
InformationSchemaSequence(String name, Schema schema, DataType<N> type) {
|
||||
super(name, schema, type);
|
||||
InformationSchemaSequence(String name, Schema schema, DataType<N> type, Long startWith, Long incrementBy, Long minValue, Long maxValue, Boolean cycle, Long cache) {
|
||||
super(DSL.name(name),
|
||||
schema,
|
||||
type,
|
||||
false,
|
||||
startWith != null ? Tools.field(startWith, type) : null,
|
||||
incrementBy != null ? Tools.field(incrementBy, type) : null,
|
||||
minValue != null ? Tools.field(minValue, type) : null,
|
||||
maxValue != null ? Tools.field(maxValue, type) : null,
|
||||
Boolean.TRUE.equals(cycle),
|
||||
cache != null ? Tools.field(cache, type) : null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -149,7 +149,18 @@ public final class Internal {
|
||||
* Factory method for sequences.
|
||||
*/
|
||||
public static final <T extends Number> Sequence<T> createSequence(String name, Schema schema, DataType<T> type, Long startWith, Long incrementBy, Long minValue, Long maxValue, boolean cycle, Long cache) {
|
||||
return new SequenceImpl<>(DSL.name(name), schema, type, false, Tools.field(startWith, type), Tools.field(incrementBy, type), Tools.field(minValue, type), Tools.field(maxValue, type), cycle, Tools.field(cache, type));
|
||||
return new SequenceImpl<>(
|
||||
DSL.name(name),
|
||||
schema,
|
||||
type,
|
||||
false,
|
||||
startWith != null ? Tools.field(startWith, type) : null,
|
||||
incrementBy != null ? Tools.field(incrementBy, type) : null,
|
||||
minValue != null ? Tools.field(minValue, type) : null,
|
||||
maxValue != null ? Tools.field(maxValue, type) : null,
|
||||
cycle,
|
||||
cache != null ? Tools.field(cache, type) : null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -29,6 +29,12 @@ import org.jooq.util.jaxb.tools.XMLBuilder;
|
||||
* <element name="character_maximum_length" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
|
||||
* <element name="numeric_precision" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
|
||||
* <element name="numeric_scale" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
|
||||
* <element name="start_with" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/>
|
||||
* <element name="increment_by" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/>
|
||||
* <element name="min_value" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/>
|
||||
* <element name="max_value" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/>
|
||||
* <element name="cycle" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
|
||||
* <element name="cache" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/>
|
||||
* <element name="comment" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
|
||||
* </all>
|
||||
* </restriction>
|
||||
@ -67,6 +73,16 @@ public class Sequence implements Serializable, XMLAppendable
|
||||
protected Integer numericPrecision;
|
||||
@XmlElement(name = "numeric_scale")
|
||||
protected Integer numericScale;
|
||||
@XmlElement(name = "start_with")
|
||||
protected Long startWith;
|
||||
@XmlElement(name = "increment_by")
|
||||
protected Long incrementBy;
|
||||
@XmlElement(name = "min_value")
|
||||
protected Long minValue;
|
||||
@XmlElement(name = "max_value")
|
||||
protected Long maxValue;
|
||||
protected Boolean cycle;
|
||||
protected Long cache;
|
||||
@XmlJavaTypeAdapter(StringAdapter.class)
|
||||
protected String comment;
|
||||
|
||||
@ -126,6 +142,70 @@ public class Sequence implements Serializable, XMLAppendable
|
||||
this.numericScale = value;
|
||||
}
|
||||
|
||||
public Long getStartWith() {
|
||||
return startWith;
|
||||
}
|
||||
|
||||
public void setStartWith(Long value) {
|
||||
this.startWith = value;
|
||||
}
|
||||
|
||||
public Long getIncrementBy() {
|
||||
return incrementBy;
|
||||
}
|
||||
|
||||
public void setIncrementBy(Long value) {
|
||||
this.incrementBy = value;
|
||||
}
|
||||
|
||||
public Long getMinValue() {
|
||||
return minValue;
|
||||
}
|
||||
|
||||
public void setMinValue(Long value) {
|
||||
this.minValue = value;
|
||||
}
|
||||
|
||||
public Long getMaxValue() {
|
||||
return maxValue;
|
||||
}
|
||||
|
||||
public void setMaxValue(Long value) {
|
||||
this.maxValue = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the cycle property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public Boolean isCycle() {
|
||||
return cycle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the cycle property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public void setCycle(Boolean value) {
|
||||
this.cycle = value;
|
||||
}
|
||||
|
||||
public Long getCache() {
|
||||
return cache;
|
||||
}
|
||||
|
||||
public void setCache(Long value) {
|
||||
this.cache = value;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
@ -169,6 +249,36 @@ public class Sequence implements Serializable, XMLAppendable
|
||||
return this;
|
||||
}
|
||||
|
||||
public Sequence withStartWith(Long value) {
|
||||
setStartWith(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Sequence withIncrementBy(Long value) {
|
||||
setIncrementBy(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Sequence withMinValue(Long value) {
|
||||
setMinValue(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Sequence withMaxValue(Long value) {
|
||||
setMaxValue(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Sequence withCycle(Boolean value) {
|
||||
setCycle(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Sequence withCache(Long value) {
|
||||
setCache(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Sequence withComment(String value) {
|
||||
setComment(value);
|
||||
return this;
|
||||
@ -183,6 +293,12 @@ public class Sequence implements Serializable, XMLAppendable
|
||||
builder.append("character_maximum_length", characterMaximumLength);
|
||||
builder.append("numeric_precision", numericPrecision);
|
||||
builder.append("numeric_scale", numericScale);
|
||||
builder.append("start_with", startWith);
|
||||
builder.append("increment_by", incrementBy);
|
||||
builder.append("min_value", minValue);
|
||||
builder.append("max_value", maxValue);
|
||||
builder.append("cycle", cycle);
|
||||
builder.append("cache", cache);
|
||||
builder.append("comment", comment);
|
||||
}
|
||||
|
||||
@ -268,6 +384,60 @@ public class Sequence implements Serializable, XMLAppendable
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (startWith == null) {
|
||||
if (other.startWith!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!startWith.equals(other.startWith)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (incrementBy == null) {
|
||||
if (other.incrementBy!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!incrementBy.equals(other.incrementBy)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (minValue == null) {
|
||||
if (other.minValue!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!minValue.equals(other.minValue)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (maxValue == null) {
|
||||
if (other.maxValue!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!maxValue.equals(other.maxValue)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (cycle == null) {
|
||||
if (other.cycle!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!cycle.equals(other.cycle)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (cache == null) {
|
||||
if (other.cache!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!cache.equals(other.cache)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (comment == null) {
|
||||
if (other.comment!= null) {
|
||||
return false;
|
||||
@ -291,6 +461,12 @@ public class Sequence implements Serializable, XMLAppendable
|
||||
result = ((prime*result)+((characterMaximumLength == null)? 0 :characterMaximumLength.hashCode()));
|
||||
result = ((prime*result)+((numericPrecision == null)? 0 :numericPrecision.hashCode()));
|
||||
result = ((prime*result)+((numericScale == null)? 0 :numericScale.hashCode()));
|
||||
result = ((prime*result)+((startWith == null)? 0 :startWith.hashCode()));
|
||||
result = ((prime*result)+((incrementBy == null)? 0 :incrementBy.hashCode()));
|
||||
result = ((prime*result)+((minValue == null)? 0 :minValue.hashCode()));
|
||||
result = ((prime*result)+((maxValue == null)? 0 :maxValue.hashCode()));
|
||||
result = ((prime*result)+((cycle == null)? 0 :cycle.hashCode()));
|
||||
result = ((prime*result)+((cache == null)? 0 :cache.hashCode()));
|
||||
result = ((prime*result)+((comment == null)? 0 :comment.hashCode()));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -67,6 +67,12 @@
|
||||
<element name="character_maximum_length" type="int" minOccurs="0" maxOccurs="1" />
|
||||
<element name="numeric_precision" type="int" minOccurs="0" maxOccurs="1" />
|
||||
<element name="numeric_scale" type="int" minOccurs="0" maxOccurs="1" />
|
||||
<element name="start_with" type="long" minOccurs="0" maxOccurs="1" />
|
||||
<element name="increment_by" type="long" minOccurs="0" maxOccurs="1" />
|
||||
<element name="min_value" type="long" minOccurs="0" maxOccurs="1" />
|
||||
<element name="max_value" type="long" minOccurs="0" maxOccurs="1" />
|
||||
<element name="cycle" type="boolean" minOccurs="0" maxOccurs="1" />
|
||||
<element name="cache" type="long" minOccurs="0" maxOccurs="1" />
|
||||
<element name="comment" type="string" minOccurs="0" maxOccurs="1" />
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user