[jOOQ/jOOQ#13069] Added <existsConvenience/>
This commit is contained in:
parent
e122273e50
commit
95bc88e5fe
@ -70,6 +70,8 @@ abstract class AbstractGenerator implements Generator {
|
||||
boolean generateRelations = true;
|
||||
boolean generateImplicitJoinPathsToOne = true;
|
||||
boolean generateImplicitJoinPathsAsKotlinProperties = true;
|
||||
boolean generateExistsConvenienceOneToMany = true;
|
||||
boolean generateExistsConvenienceManyToMany = true;
|
||||
boolean generateRowConvenienceToOne = true;
|
||||
boolean generateMultisetConvenienceOneToMany = true;
|
||||
boolean generateMultisetConvenienceManyToMany = true;
|
||||
@ -307,6 +309,26 @@ abstract class AbstractGenerator implements Generator {
|
||||
this.generateImplicitJoinPathsAsKotlinProperties = generateImplicitJoinPathsAsKotlinProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateExistsConvenienceOneToMany() {
|
||||
return generateExistsConvenienceOneToMany && generateRelations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGenerateExistsConvenienceOneToMany(boolean generateExistsConvenienceOneToMany) {
|
||||
this.generateExistsConvenienceOneToMany = generateExistsConvenienceOneToMany;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateExistsConvenienceManyToMany() {
|
||||
return generateExistsConvenienceManyToMany && generateRelations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGenerateExistsConvenienceManyToMany(boolean generateExistsConvenienceManyToMany) {
|
||||
this.generateExistsConvenienceManyToMany = generateExistsConvenienceManyToMany;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateRowConvenienceToOne() {
|
||||
return generateRowConvenienceToOne && generateRelations();
|
||||
|
||||
@ -720,6 +720,10 @@ public class GenerationTool {
|
||||
generator.setGenerateImplicitJoinPathsToOne(g.getGenerate().isImplicitJoinPathsToOne());
|
||||
if (g.getGenerate().isImplicitJoinPathsAsKotlinProperties() != null)
|
||||
generator.setGenerateImplicitJoinPathsAsKotlinProperties(g.getGenerate().isImplicitJoinPathsAsKotlinProperties());
|
||||
if (g.getGenerate().isExistsConvenienceOneToMany() != null)
|
||||
generator.setGenerateExistsConvenienceOneToMany(g.getGenerate().isExistsConvenienceOneToMany());
|
||||
if (g.getGenerate().isExistsConvenienceManyToMany() != null)
|
||||
generator.setGenerateExistsConvenienceManyToMany(g.getGenerate().isExistsConvenienceManyToMany());
|
||||
if (g.getGenerate().isRowConvenienceToOne() != null)
|
||||
generator.setGenerateRowConvenienceToOne(g.getGenerate().isRowConvenienceToOne());
|
||||
if (g.getGenerate().isMultisetConvenienceOneToMany() != null)
|
||||
|
||||
@ -142,6 +142,30 @@ public interface Generator {
|
||||
*/
|
||||
void setGenerateImplicitJoinPathsAsKotlinProperties(boolean generateImplicitJoinPathsAsKotlinProperties);
|
||||
|
||||
/**
|
||||
* Whether <code>EXISTS</code> convenience syntax for one-to-many
|
||||
* relationships should be generated.
|
||||
*/
|
||||
boolean generateExistsConvenienceOneToMany();
|
||||
|
||||
/**
|
||||
* Whether <code>EXISTS</code> convenience syntax for one-to-many
|
||||
* relationships should be generated.
|
||||
*/
|
||||
void setGenerateExistsConvenienceOneToMany(boolean generateExistsConvenienceOneToMany);
|
||||
|
||||
/**
|
||||
* Whether <code>EXISTS</code> convenience syntax for many-to-many
|
||||
* relationships should be generated.
|
||||
*/
|
||||
boolean generateExistsConvenienceManyToMany();
|
||||
|
||||
/**
|
||||
* Whether <code>EXISTS</code> convenience syntax for many-to-many
|
||||
* relationships should be generated.
|
||||
*/
|
||||
void setGenerateExistsConvenienceManyToMany(boolean generateExistsConvenienceManyToMany);
|
||||
|
||||
/**
|
||||
* Whether <code>ROW</code> convenience syntax for to-one relationships
|
||||
* should be generated.
|
||||
|
||||
@ -95,6 +95,7 @@ import java.util.stream.Stream;
|
||||
import org.jooq.AggregateFunction;
|
||||
import org.jooq.Catalog;
|
||||
import org.jooq.Check;
|
||||
import org.jooq.Condition;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Constants;
|
||||
import org.jooq.DataType;
|
||||
@ -6523,6 +6524,163 @@ public class JavaGenerator extends AbstractGenerator {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -43,6 +43,10 @@ public class Generate implements Serializable, XMLAppendable
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean implicitJoinPathsAsKotlinProperties = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean existsConvenienceOneToMany = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean existsConvenienceManyToMany = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean rowConvenienceToOne = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean multisetConvenienceOneToMany = true;
|
||||
@ -389,6 +393,58 @@ public class Generate implements Serializable, XMLAppendable
|
||||
this.implicitJoinPathsAsKotlinProperties = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate <code>EXISTS</code> convenience syntax for one-to-many relationships.
|
||||
* <p>
|
||||
* This feature is available in the commercial distribution only.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public Boolean isExistsConvenienceOneToMany() {
|
||||
return existsConvenienceOneToMany;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the existsConvenienceOneToMany property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public void setExistsConvenienceOneToMany(Boolean value) {
|
||||
this.existsConvenienceOneToMany = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate <code>EXISTS</code> convenience syntax for many-to-many relationships. A many-to-many relationship is achieved when a child table has 2 non-nullable foreign keys that are part of a unique key.
|
||||
* <p>
|
||||
* This feature is available in the commercial distribution only.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public Boolean isExistsConvenienceManyToMany() {
|
||||
return existsConvenienceManyToMany;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the existsConvenienceManyToMany property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public void setExistsConvenienceManyToMany(Boolean value) {
|
||||
this.existsConvenienceManyToMany = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate <code>ROW</code> convenience syntax for to-one relationships.
|
||||
* <p>
|
||||
@ -2608,6 +2664,16 @@ public class Generate implements Serializable, XMLAppendable
|
||||
return this;
|
||||
}
|
||||
|
||||
public Generate withExistsConvenienceOneToMany(Boolean value) {
|
||||
setExistsConvenienceOneToMany(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Generate withExistsConvenienceManyToMany(Boolean value) {
|
||||
setExistsConvenienceManyToMany(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Generate withRowConvenienceToOne(Boolean value) {
|
||||
setRowConvenienceToOne(value);
|
||||
return this;
|
||||
@ -3130,6 +3196,8 @@ public class Generate implements Serializable, XMLAppendable
|
||||
builder.append("implicitJoinPathsToOne", implicitJoinPathsToOne);
|
||||
builder.append("implicitJoinPathsUseTableNameForUnambiguousFKs", implicitJoinPathsUseTableNameForUnambiguousFKs);
|
||||
builder.append("implicitJoinPathsAsKotlinProperties", implicitJoinPathsAsKotlinProperties);
|
||||
builder.append("existsConvenienceOneToMany", existsConvenienceOneToMany);
|
||||
builder.append("existsConvenienceManyToMany", existsConvenienceManyToMany);
|
||||
builder.append("rowConvenienceToOne", rowConvenienceToOne);
|
||||
builder.append("multisetConvenienceOneToMany", multisetConvenienceOneToMany);
|
||||
builder.append("multisetConvenienceManyToMany", multisetConvenienceManyToMany);
|
||||
@ -3298,6 +3366,24 @@ public class Generate implements Serializable, XMLAppendable
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (existsConvenienceOneToMany == null) {
|
||||
if (other.existsConvenienceOneToMany!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!existsConvenienceOneToMany.equals(other.existsConvenienceOneToMany)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (existsConvenienceManyToMany == null) {
|
||||
if (other.existsConvenienceManyToMany!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!existsConvenienceManyToMany.equals(other.existsConvenienceManyToMany)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (rowConvenienceToOne == null) {
|
||||
if (other.rowConvenienceToOne!= null) {
|
||||
return false;
|
||||
@ -4148,6 +4234,8 @@ public class Generate implements Serializable, XMLAppendable
|
||||
result = ((prime*result)+((implicitJoinPathsToOne == null)? 0 :implicitJoinPathsToOne.hashCode()));
|
||||
result = ((prime*result)+((implicitJoinPathsUseTableNameForUnambiguousFKs == null)? 0 :implicitJoinPathsUseTableNameForUnambiguousFKs.hashCode()));
|
||||
result = ((prime*result)+((implicitJoinPathsAsKotlinProperties == null)? 0 :implicitJoinPathsAsKotlinProperties.hashCode()));
|
||||
result = ((prime*result)+((existsConvenienceOneToMany == null)? 0 :existsConvenienceOneToMany.hashCode()));
|
||||
result = ((prime*result)+((existsConvenienceManyToMany == null)? 0 :existsConvenienceManyToMany.hashCode()));
|
||||
result = ((prime*result)+((rowConvenienceToOne == null)? 0 :rowConvenienceToOne.hashCode()));
|
||||
result = ((prime*result)+((multisetConvenienceOneToMany == null)? 0 :multisetConvenienceOneToMany.hashCode()));
|
||||
result = ((prime*result)+((multisetConvenienceManyToMany == null)? 0 :multisetConvenienceManyToMany.hashCode()));
|
||||
|
||||
@ -1760,6 +1760,18 @@ This flag allows for turning off this default behaviour.]]></jxb:javadoc></jxb:p
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether implicit join path constructors should be offered as properties in Kotlin.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="existsConvenienceOneToMany" type="boolean" default="true" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Generate <code>EXISTS</code> convenience syntax for one-to-many relationships.
|
||||
<p>
|
||||
This feature is available in the commercial distribution only.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="existsConvenienceManyToMany" type="boolean" default="true" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Generate <code>EXISTS</code> convenience syntax for many-to-many relationships. A many-to-many relationship is achieved when a child table has 2 non-nullable foreign keys that are part of a unique key.
|
||||
<p>
|
||||
This feature is available in the commercial distribution only.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="rowConvenienceToOne" type="boolean" default="true" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Generate <code>ROW</code> convenience syntax for to-one relationships.
|
||||
<p>
|
||||
|
||||
@ -57,12 +57,15 @@ import static org.jooq.SQLDialect.MYSQL;
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
import static org.jooq.impl.DSL.and;
|
||||
import static org.jooq.impl.DSL.exists;
|
||||
import static org.jooq.impl.DSL.falseCondition;
|
||||
import static org.jooq.impl.DSL.multiset;
|
||||
import static org.jooq.impl.DSL.multisetAgg;
|
||||
import static org.jooq.impl.DSL.one;
|
||||
import static org.jooq.impl.DSL.row;
|
||||
import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.DSL.selectFrom;
|
||||
import static org.jooq.impl.DSL.selectOne;
|
||||
import static org.jooq.impl.DSL.val;
|
||||
import static org.jooq.impl.DefaultMetaProvider.meta;
|
||||
import static org.jooq.impl.DerivedTable.NO_SUPPORT_CORRELATED_DERIVED_TABLE;
|
||||
@ -387,6 +390,77 @@ implements
|
||||
throw new DataAccessException("The many-to-many MULTISET convenience feature is available in the commercial jOOQ distribution only. Please consider upgrading to the jOOQ Professional Edition or jOOQ Enterprise Edition.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a <code>MULTISET</code> one-to-many child table expression from
|
||||
* this table.
|
||||
*/
|
||||
@org.jooq.Internal
|
||||
@NotNull
|
||||
protected <O1 extends Record> Condition oneToManyExists(
|
||||
ForeignKey<O1, R> path,
|
||||
Function<? super Table<O1>, ? extends TableLike<?>> f
|
||||
) {
|
||||
if (CONFIG.commercial()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
throw new DataAccessException("The one-to-many EXISTS convenience feature is available in the commercial jOOQ distribution only. Please consider upgrading to the jOOQ Professional Edition or jOOQ Enterprise Edition.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a <code>MULTISET</code> many-to-many child table expression from
|
||||
* this table.
|
||||
*/
|
||||
@org.jooq.Internal
|
||||
@NotNull
|
||||
protected <O1 extends Record, X extends Record> Condition manyToManyExists(
|
||||
ForeignKey<O1, R> path1,
|
||||
ForeignKey<O1, X> path2,
|
||||
Function<? super Table<X>, ? extends TableLike<?>> f
|
||||
) {
|
||||
if (CONFIG.commercial()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
throw new DataAccessException("The many-to-many EXISTS convenience feature is available in the commercial jOOQ distribution only. Please consider upgrading to the jOOQ Professional Edition or jOOQ Enterprise Edition.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user