mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-13 21:01:01 +08:00
removed DDL sections from SQL docs
This commit is contained in:
parent
5ad131edff
commit
ff00a8d65c
@ -396,92 +396,6 @@ public class MySQLQuery extends AbstractSQLQuery<MySQLQuery>{
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2>
|
||||
|
||||
<title>Using DDL commands</title>
|
||||
|
||||
<para>CREATE TABLE commands can be used in fluent form via the CreateTableClause. Here are
|
||||
some examples : </para>
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
createTable("language")
|
||||
.column("id", Integer.class).notNull()
|
||||
.column("text", String.class).size(256).notNull()
|
||||
.primaryKey("PK_LANGUAGE","id")
|
||||
.execute();
|
||||
|
||||
createTable("symbol")
|
||||
.column("id", Long.class).notNull()
|
||||
.column("lexical", String.class).size(1024).notNull()
|
||||
.column("datatype", Long.class)
|
||||
.column("lang", Integer.class)
|
||||
.column("intval",Long.class)
|
||||
.column("floatval",Double.class)
|
||||
.column("datetimeval",Timestamp.class)
|
||||
.primaryKey("PK_SYMBOL","id")
|
||||
.foreignKey("FK_LANG","lang").references("language","id")
|
||||
.execute();
|
||||
|
||||
createTable("statement")
|
||||
.column("model", Long.class)
|
||||
.column("subject", Long.class).notNull()
|
||||
.column("predicate", Long.class).notNull()
|
||||
.column("object", Long.class).notNull()
|
||||
.foreignKey("FK_MODEL","model").references("symbol","id")
|
||||
.foreignKey("FK_SUBJECT","subject").references("symbol","id")
|
||||
.foreignKey("FK_PREDICATE","predicate").references("symbol","id")
|
||||
.foreignKey("FK_OBJECT","object").references("symbol","id")
|
||||
.execute();
|
||||
]]></programlisting>
|
||||
|
||||
<para>The factory method for CreateTableClause construction is :</para>
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
private CreateTableClause createTable(String tableName) {
|
||||
return new CreateTableClause(conn, templates, tableName);
|
||||
}
|
||||
]]></programlisting>
|
||||
|
||||
<para>The constructor of CreateTableClause takes the connection, the templates and the table name.
|
||||
The rest is declared via
|
||||
column, primaryKey and foreignKey invocations.
|
||||
</para>
|
||||
|
||||
<para>Here are the corresponding CREATE TABLE clauses as they are executed.</para>
|
||||
|
||||
<programlisting language="sql"><![CDATA[
|
||||
CREATE TABLE language (
|
||||
id INTEGER NOT NULL,
|
||||
text VARCHAR(256) NOT NULL,
|
||||
CONSTRAINT PK_LANGUAGE PRIMARY KEY(id)
|
||||
)
|
||||
|
||||
CREATE TABLE symbol (
|
||||
id BIGINT NOT NULL,
|
||||
lexical VARCHAR(1024) NOT NULL,
|
||||
datatype BIGINT,
|
||||
lang INTEGER,
|
||||
intval BIGINT,
|
||||
floatval DOUBLE,
|
||||
datetimeval TIMESTAMP,
|
||||
CONSTRAINT PK_SYMBOL PRIMARY KEY(id),
|
||||
CONSTRAINT FK_LANG FOREIGN KEY(lang) REFERENCES language(id)
|
||||
)
|
||||
|
||||
CREATE TABLE statement (
|
||||
model BIGINT,
|
||||
subject BIGINT NOT NULL,
|
||||
predicate BIGINT NOT NULL,
|
||||
object BIGINT NOT NULL,
|
||||
CONSTRAINT FK_MODEL FOREIGN KEY(model) REFERENCES symbol(id),
|
||||
CONSTRAINT FK_SUBJECT FOREIGN KEY(subject) REFERENCES symbol(id),
|
||||
CONSTRAINT FK_PREDICATE FOREIGN KEY(predicate) REFERENCES symbol(id),
|
||||
CONSTRAINT FK_OBJECT FOREIGN KEY(object) REFERENCES symbol(id)
|
||||
)
|
||||
]]></programlisting>
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2>
|
||||
|
||||
<title>Using Data manipulation commands</title>
|
||||
|
||||
@ -62,8 +62,10 @@ public final class NativeSQLSerializer extends SQLSerializer{
|
||||
}
|
||||
} else if (!isAlias(args[i]) && !(args[i] instanceof FactoryExpression)) {
|
||||
// https://github.com/mysema/querydsl/issues/80
|
||||
args[i] = ExpressionUtils.as(args[i], "col__"+(i+1));
|
||||
modified = true;
|
||||
if (!args[i].toString().contains("*")) {
|
||||
args[i] = ExpressionUtils.as(args[i], "col__"+(i+1));
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (modified) {
|
||||
|
||||
@ -36,6 +36,7 @@ import com.mysema.query.sql.SQLTemplates;
|
||||
import com.mysema.query.types.ConstructorExpression;
|
||||
import com.mysema.query.types.Expression;
|
||||
import com.mysema.query.types.SubQueryExpression;
|
||||
import com.mysema.query.types.expr.Wildcard;
|
||||
|
||||
public abstract class AbstractSQLTest {
|
||||
|
||||
@ -97,6 +98,11 @@ public abstract class AbstractSQLTest {
|
||||
assertEquals(6, query().from(cat).where(cat.dtype.eq("C")).list(cat.id).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void List_Wildcard() {
|
||||
assertEquals(6l, query().from(cat).where(cat.dtype.eq("C")).list(Wildcard.all).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void List_With_Limit(){
|
||||
assertEquals(3, query().from(cat).limit(3).list(cat.id).size());
|
||||
|
||||
@ -42,6 +42,11 @@ public class H2SQLTest extends AbstractSQLTest{
|
||||
public void Wildcard(){
|
||||
//
|
||||
}
|
||||
|
||||
@Test
|
||||
public void List_Wildcard() {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ import com.mysema.query.sql.SQLTemplates;
|
||||
import com.mysema.query.types.ConstructorExpression;
|
||||
import com.mysema.query.types.Expression;
|
||||
import com.mysema.query.types.SubQueryExpression;
|
||||
import com.mysema.query.types.query.ListSubQuery;
|
||||
import com.mysema.query.types.expr.Wildcard;
|
||||
|
||||
public abstract class AbstractJPASQLTest {
|
||||
|
||||
@ -100,6 +100,11 @@ public abstract class AbstractJPASQLTest {
|
||||
public void List(){
|
||||
assertEquals(6, query().from(cat).where(cat.dtype.eq("C")).list(cat.id).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void List_Wildcard() {
|
||||
assertEquals(6l, query().from(cat).where(cat.dtype.eq("C")).list(Wildcard.all).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void List_Non_Path() {
|
||||
|
||||
@ -30,4 +30,9 @@ public class H2JPASQLTest extends AbstractJPASQLTest {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void List_Wildcard() {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user