mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-27 21:01:15 +08:00
updated documentation to match new packages and classes
This commit is contained in:
parent
f4f9ece17c
commit
63bce0fd7f
@ -11,7 +11,7 @@
|
||||
of the simple type name. For the type Account this would be account :</para>
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
public class QAccount extends PEntity<Account>{
|
||||
public class QAccount extends EntityPathBase<Account>{
|
||||
|
||||
public static final QAccount account = new QAccount("account");
|
||||
|
||||
@ -51,7 +51,7 @@ public class QAccount extends PEntity<Account>{
|
||||
<para>For HQL usage :</para>
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
protected HQLQuery from(PEntity<?>... o) {
|
||||
protected HQLQuery from(EntityPath<?>... o) {
|
||||
return new HqlQueryImpl(session).from(o);
|
||||
}
|
||||
]]></programlisting>
|
||||
@ -59,7 +59,7 @@ protected HQLQuery from(PEntity<?>... o) {
|
||||
<para>For JDO usage : </para>
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
protected JDOQLQuery from(PEntity<?>... o) {
|
||||
protected JDOQLQuery from(EntityPath<?>... o) {
|
||||
return new JDOQLQueryImpl(persistenceManager).from(o);
|
||||
}
|
||||
]]></programlisting>
|
||||
|
||||
@ -103,7 +103,7 @@ import com.mysema.query.annotations.QuerydslConfig;
|
||||
<plugin>
|
||||
<groupId>com.mysema.maven</groupId>
|
||||
<artifactId>maven-apt-plugin</artifactId>
|
||||
<version>0.3.2</version>
|
||||
<version>1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@ -236,7 +236,7 @@ public class Point{
|
||||
}
|
||||
|
||||
@QueryDelegate(User.class)
|
||||
public static EBoolean isManagedBy(QUser user, User other){
|
||||
public static BooleanPath isManagedBy(QUser user, User other){
|
||||
return user.manager.eq(other);
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ public class Point{
|
||||
<para>And the generated methods in the QUser query type :</para>
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
public EBoolean isManagedBy(Qser other) {
|
||||
public BooleanPath isManagedBy(Qser other) {
|
||||
return com.mysema.query.domain.DelegateTest.isManagedBy(this, other);
|
||||
}
|
||||
|
||||
@ -258,12 +258,12 @@ public class Point{
|
||||
public class QueryExtensions {
|
||||
|
||||
@QueryDelegate(Date.class)
|
||||
public static EBoolean inPeriod(PDate<Date> date, Pair<Date,Date> period){
|
||||
public static BooleanPath inPeriod(DatePath<Date> date, Pair<Date,Date> period){
|
||||
return date.goe(period.getFirst()).and(date.loe(period.getSecond()));
|
||||
}
|
||||
|
||||
@QueryDelegate(Timestamp.class)
|
||||
public static EBoolean inDatePeriod(PDateTime<Timestamp> timestamp, Pair<Date,Date> period){
|
||||
public static BooleanPath inDatePeriod(DateTimePath<Timestamp> timestamp, Pair<Date,Date> period){
|
||||
Timestamp first = new Timestamp(DateUtils.truncate(period.getFirst(), Calendar.DAY_OF_MONTH).getTime());
|
||||
Calendar second = Calendar.getInstance();
|
||||
second.setTime(DateUtils.truncate(period.getSecond(), Calendar.DAY_OF_MONTH));
|
||||
@ -287,7 +287,7 @@ public class QDate extends PDate<java.sql.Date> {
|
||||
super(java.sql.Date.class, metadata);
|
||||
}
|
||||
|
||||
public EBoolean inPeriod(com.mysema.commons.lang.Pair<java.sql.Date, java.sql.Date> period) {
|
||||
public BooleanPath inPeriod(com.mysema.commons.lang.Pair<java.sql.Date, java.sql.Date> period) {
|
||||
return QueryExtensions.inPeriod(this, period);
|
||||
}
|
||||
|
||||
@ -303,11 +303,10 @@ public class QTimestamp extends PDateTime<java.sql.Timestamp> {
|
||||
super(java.sql.Timestamp.class, metadata);
|
||||
}
|
||||
|
||||
public EBoolean inDatePeriod(com.mysema.commons.lang.Pair<java.sql.Date, java.sql.Date> period) {
|
||||
public BooleanPath inDatePeriod(com.mysema.commons.lang.Pair<java.sql.Date, java.sql.Date> period) {
|
||||
return QueryExtensions.inDatePeriod(this, period);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
]]></programlisting>
|
||||
|
||||
@ -332,7 +331,7 @@ public class QTimestamp extends PDateTime<java.sql.Timestamp> {
|
||||
<plugin>
|
||||
<groupId>com.mysema.maven</groupId>
|
||||
<artifactId>maven-apt-plugin</artifactId>
|
||||
<version>0.3.2</version>
|
||||
<version>1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
|
||||
<para>
|
||||
To avoid a generic signature in Querydsl query types the type hierarchies are flattened. The result is that
|
||||
all generated query types are direct subclasses of com.mysema.query.types.path.PEntity and cannot be directly cast
|
||||
to their Querydsl supertypes.
|
||||
all generated query types are direct subclasses of com.mysema.query.types.path.EntityPathBase or com.mysema.query.types.path.BeanPath
|
||||
and cannot be directly cast to their Querydsl supertypes.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
@ -19,12 +19,12 @@
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
// from Account
|
||||
QAccount extends PEntity<Account>{
|
||||
QAccount extends EntityPathBase<Account>{
|
||||
// ...
|
||||
}
|
||||
|
||||
// from BankAccount extends Account
|
||||
QBankAccount extends PEntity<BankAccount>{
|
||||
QBankAccount extends EntityPathBase<BankAccount>{
|
||||
|
||||
public final QAccount _super = new QAccount(this);
|
||||
|
||||
@ -32,7 +32,7 @@ QBankAccount extends PEntity<BankAccount>{
|
||||
}
|
||||
]]></programlisting>
|
||||
|
||||
<para>To cast from a supertype to a subtype you can use the as-method of the PEntity class :</para>
|
||||
<para>To cast from a supertype to a subtype you can use the as-method of the EntityPathBase class :</para>
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
QAccount account = new QAccount("account");
|
||||
@ -74,7 +74,7 @@ class CustomerDTO {
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
QCustomer customer = QCustomer.customer;
|
||||
HQLQuery query = new HibernateQuery(session);
|
||||
JPQLQuery query = new HibernateQuery(session);
|
||||
List<CustomerDTO> dtos = qry.from(customer).list(new QCustomerDTO(customer.id, customer.name));
|
||||
]]></programlisting>
|
||||
|
||||
@ -99,7 +99,7 @@ class Customer {
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
QCustomer customer = QCustomer.customer;
|
||||
HQLQuery query = new HibernateQuery(session);
|
||||
JPQLQuery query = new HibernateQuery(session);
|
||||
List<Customer> dtos = qry.from(customer).list(new QCustomer.create(customer.id, customer.name));
|
||||
]]></programlisting>
|
||||
|
||||
@ -142,7 +142,7 @@ public List<Customer> getCustomer(String... names){
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
QCustomer customer = QCustomer.customer;
|
||||
Expr<String> cases = new CaseBuilder()
|
||||
Expression<String> cases = new CaseBuilder()
|
||||
.when(customer.annualSpending.gt(10000)).then("Premier")
|
||||
.when(customer.annualSpending.gt(5000)).then("Gold")
|
||||
.when(customer.annualSpending.gt(2000)).then("Silver")
|
||||
@ -154,7 +154,7 @@ Expr<String> cases = new CaseBuilder()
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
QCustomer customer = QCustomer.customer;
|
||||
Expr<String> cases = customer.annualSpending
|
||||
Expression<String> cases = customer.annualSpending
|
||||
.when(10000).then("Premier")
|
||||
.when(5000).then("Gold")
|
||||
.when(2000).then("Silver")
|
||||
@ -170,7 +170,7 @@ Expr<String> cases = customer.annualSpending
|
||||
<title>Dynamic path usage</title>
|
||||
|
||||
<para>
|
||||
For dynamic path generation the PathBuilder class can be used. It extends PEntity and can be used
|
||||
For dynamic path generation the PathBuilder class can be used. It extends EntityPathBase and can be used
|
||||
as an alternative to class generation and alias-usage for path generation.
|
||||
</para>
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
<para>
|
||||
To get an impression of the expressivity of the Querydsl query and expression types go to
|
||||
the javadocs and explore
|
||||
com.mysema.query.Query, com.mysema.query.Projectable and com.mysema.query.types.expr.Expr.
|
||||
com.mysema.query.Query, com.mysema.query.Projectable and com.mysema.query.types.Expression.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
@ -131,7 +131,7 @@ for (String name : from(cat,cats)
|
||||
<plugin>
|
||||
<groupId>com.mysema.maven</groupId>
|
||||
<artifactId>maven-apt-plugin</artifactId>
|
||||
<version>0.3.2</version>
|
||||
<version>1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mysema.querydsl</groupId>
|
||||
<artifactId>querydsl-jdoql</artifactId>
|
||||
<artifactId>querydsl-jdo</artifactId>
|
||||
<version>${querydsl.version}</version>
|
||||
</dependency>
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
<plugin>
|
||||
<groupId>com.mysema.maven</groupId>
|
||||
<artifactId>maven-apt-plugin</artifactId>
|
||||
<version>0.3.2</version>
|
||||
<version>1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mysema.querydsl</groupId>
|
||||
<artifactId>querydsl-hql</artifactId>
|
||||
<artifactId>querydsl-jpa</artifactId>
|
||||
<version>${querydsl.version}</version>
|
||||
</dependency>
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
</dependency>
|
||||
]]></programlisting>
|
||||
|
||||
<para>
|
||||
<para>
|
||||
And now, configure the Maven APT plugin :
|
||||
</para>
|
||||
|
||||
@ -57,7 +57,7 @@
|
||||
<plugin>
|
||||
<groupId>com.mysema.maven</groupId>
|
||||
<artifactId>maven-apt-plugin</artifactId>
|
||||
<version>0.3.2</version>
|
||||
<version>1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@ -200,20 +200,20 @@ QCustomer customer = new QCustomer("myCustomer");
|
||||
<title>Querying</title>
|
||||
|
||||
<para>
|
||||
For the HQL-module HibernateQuery is the main Query implementation. It is
|
||||
For the JPA-module HibernateQuery is the main Query implementation. It is
|
||||
instantiated like this :
|
||||
</para>
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
// where session is a Hibernate session
|
||||
HQLQuery query = new HibernateQuery (session);
|
||||
JPQLQuery query = new HibernateQuery (session);
|
||||
]]></programlisting>
|
||||
|
||||
<para>To use the JPA API instead of the Hibernate API, you can instantiate a JPAQuery like this :</para>
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
// where entityManager is a JPA EntityManager
|
||||
HQLQuery query = new JPAQuery (entityManager);
|
||||
JPQLQuery query = new JPAQuery (entityManager);
|
||||
]]></programlisting>
|
||||
|
||||
<para>
|
||||
@ -223,7 +223,7 @@ HQLQuery query = new JPAQuery (entityManager);
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
QCustomer customer = QCustomer.customer;
|
||||
HQLQuery query = new HibernateQuery (session);
|
||||
JPQLQuery query = new HibernateQuery (session);
|
||||
Customer bob = query.from(customer)
|
||||
.where(customer.firstName.eq("Bob"))
|
||||
.uniqueResult(customer);
|
||||
@ -236,7 +236,7 @@ Customer bob = query.from(customer)
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To create a query with multiple sources you just use the HQLQuery interface like this :
|
||||
To create a query with multiple sources you just use the JPQLQuery interface like this :
|
||||
</para>
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
@ -313,7 +313,7 @@ from Cat as cat
|
||||
|
||||
<title>General usage</title>
|
||||
|
||||
<para>Use the the cascading methods of the HQLQuery interface like this</para>
|
||||
<para>Use the the cascading methods of the JPQLQuery interface like this</para>
|
||||
|
||||
<para><emphasis>from :</emphasis> Define the query sources here.</para>
|
||||
|
||||
@ -382,7 +382,7 @@ select customer.lastName
|
||||
|
||||
<sect2>
|
||||
<title>Delete clauses</title>
|
||||
<para>Delete clauses in Querydsl JPQL follow a simple delete-where-execute form. Here are some examples :</para>
|
||||
<para>Delete clauses in Querydsl JPA follow a simple delete-where-execute form. Here are some examples :</para>
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
QCat cat = QCat.cat;
|
||||
@ -400,7 +400,7 @@ new HibernateDeleteClause(session, cat).where(cat.kittens.isNotEmpty()).execute(
|
||||
|
||||
<sect2>
|
||||
<title>Update clauses</title>
|
||||
<para>Update clauses in Querydsl JPQL follow a simple update-set/where-execute form. Here are some examples :</para>
|
||||
<para>Update clauses in Querydsl JPA follow a simple update-set/where-execute form. Here are some examples :</para>
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
QCat cat = QCat.cat;
|
||||
@ -422,7 +422,7 @@ new HibernateUpdateClause(session, cat).where(cat.name.eq("Bob"))
|
||||
|
||||
<title>Subqueries</title>
|
||||
|
||||
<para>To create a subquery you create a HQLSubQuery instance, define the query parameters
|
||||
<para>To create a subquery you create a JPQLSubQuery instance, define the query parameters
|
||||
via from, where etc and use
|
||||
unique or list to create a subquery, which is just a type-safe Querydsl expression for the query.
|
||||
unique is used for a unique (single) result and list for a list result.</para>
|
||||
@ -430,7 +430,7 @@ new HibernateUpdateClause(session, cat).where(cat.name.eq("Bob"))
|
||||
<programlisting language="java"><![CDATA[
|
||||
query.from(department)
|
||||
.where(department.employees.size().eq(
|
||||
new HQLSubQuery().from(d).unique(d.employees.size().max())
|
||||
new JPQLSubQuery().from(d).unique(d.employees.size().max())
|
||||
)).list(department);
|
||||
]]></programlisting>
|
||||
|
||||
@ -439,7 +439,7 @@ query.from(department)
|
||||
<programlisting language="java"><![CDATA[
|
||||
query.from(employee)
|
||||
.where(employee.weeklyhours.gt(
|
||||
new HQLSubQuery().from(employee.department.employees, e)
|
||||
new JPQLSubQuery().from(employee.department.employees, e)
|
||||
.where(e.manager.eq(employee.manager))
|
||||
.unique(e.weeklyhours.avg())
|
||||
)).list(employee);
|
||||
|
||||
@ -13,16 +13,16 @@
|
||||
<para>With fields year and title a manually created query type could look something like this :</para>
|
||||
|
||||
<programlisting language="java"><![CDATA[
|
||||
public class QDocument extends PEntity<Document>{
|
||||
public class QDocument extends EntityPathBase<Document>{
|
||||
private static final long serialVersionUID = -4872833626508344081L;
|
||||
|
||||
public QDocument(String var) {
|
||||
super(Document.class, PathMetadataFactory.forVariable(var));
|
||||
}
|
||||
|
||||
public final PString year = createString("year");
|
||||
public final StringPath year = createString("year");
|
||||
|
||||
public final PString title = createString("title");
|
||||
public final StringPath title = createString("title");
|
||||
}
|
||||
]]></programlisting>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user