mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
This commit is contained in:
parent
3dd09513b0
commit
3f739d86c1
@ -112,6 +112,14 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-eclipse-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<ajdtVersion>none</ajdtVersion>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
<project name="querydsl">
|
||||
|
||||
<bannerLeft>
|
||||
<src>/images/logos/header_mysema_logo.png</src>
|
||||
<href>http://source.mysema.com</href>
|
||||
</bannerLeft>
|
||||
|
||||
<bannerRight>
|
||||
<name>${project.name}</name>
|
||||
<href>/index.html</href>
|
||||
</bannerRight>
|
||||
|
||||
<version position="left" />
|
||||
|
||||
<body>
|
||||
<menu name="Documentation">
|
||||
<item name="Overview" href="/index.html"/>
|
||||
<item name="Getting started" href="/getting-started.html"/>
|
||||
<item name="APT options" href="/apt-options.html"/>
|
||||
<item name="Modules" href="/modules.html"/>
|
||||
</menu>
|
||||
<menu name="Download">
|
||||
<item name="Binaries" href="http://source.mysema.com/maven2/releases/com/mysema/querydsl/"/>
|
||||
</menu>
|
||||
<menu ref="modules"/>
|
||||
<menu ref="reports"/>
|
||||
|
||||
</body>
|
||||
|
||||
</project>
|
||||
@ -1,31 +0,0 @@
|
||||
<document>
|
||||
<properties>
|
||||
<author email="timo@mysema.com">Timo Westkämper</author>
|
||||
<title>APT options</title>
|
||||
</properties>
|
||||
<body>
|
||||
<section name="APT options">
|
||||
<!--
|
||||
this.destClass = getString(env.getOptions(), "-AdestClass=", null);
|
||||
this.destPackage = getString(env.getOptions(), "-AdestPackage=", null);
|
||||
this.dtoClass = getString(env.getOptions(), "-AdtoClass=", null);
|
||||
this.dtoPackage = getString(env.getOptions(), "-AdtoPackage=", null);
|
||||
this.include = getFileContent(env.getOptions(), "-Ainclude=", "");
|
||||
this.namePrefix = getString(env.getOptions(), "-AnamePrefix=", "");
|
||||
-->
|
||||
|
||||
The APT options for Querydsl are
|
||||
<ul>
|
||||
<li>destClass : destination class for query domain types (inner class switch)</li>
|
||||
<li>destPackage : destination package for query domain types (outer class switch)</li>
|
||||
<li>dtoClass : destination class for query DTO types (inner class switch)</li>
|
||||
<li>dtoPackage : destination package for query DTO types (outer class switch)</li>
|
||||
<li>include : file path for class content of destClass</li>
|
||||
<li>namePrefix : prefix for query domain type simplenames</li>
|
||||
</ul>
|
||||
|
||||
<!-- TODO : examples -->
|
||||
</section>
|
||||
|
||||
</body>
|
||||
</document>
|
||||
@ -1,101 +0,0 @@
|
||||
<document>
|
||||
<properties>
|
||||
<author email="timo@mysema.com">Timo Westkämper</author>
|
||||
<title>Getting started</title>
|
||||
</properties>
|
||||
<body>
|
||||
|
||||
<section name="Getting started">
|
||||
<p>
|
||||
The basic steps to get Querydsl working in your project are the following :
|
||||
<ul>
|
||||
<li>Add the main Querydsl dependencies into your project pom : querydsl-hql (default scope) and querydsl-apt (provided scope)</li>
|
||||
|
||||
<li>Add the following plugin configuration
|
||||
<source>
|
||||
<plugin>
|
||||
<groupId>org.apache.myfaces.tobago</groupId>
|
||||
<artifactId>maven-apt-plugin</artifactId>
|
||||
<version>1.0.15</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<force>true</force>
|
||||
<fork>true</fork>
|
||||
<factory>com.mysema.query.apt.APTFactory</factory>
|
||||
<generated>target/generated-sources/java</generated>
|
||||
<nocompile>true</nocompile>
|
||||
<A>
|
||||
-AdestClass=com.mysema.someproject.dao.domain.Domain,
|
||||
-AdtoClass=com.mysema.someproject.dao.domain.Dtos
|
||||
</A>
|
||||
<includes>
|
||||
<include>
|
||||
com/mysema/someproject/dao/domain/*.java
|
||||
</include>
|
||||
<include>com/mysema/someproject/ui/dto/*.java</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</source>
|
||||
The APT-plugin generates Querydsl domain types into the class specified after -AdestClass= and Querydsl DTO types
|
||||
into -AdtoClass=. DTO types in your project domain need to be annotated with com.mysema.query.annotations.DTO and
|
||||
for project domain types standard Hibernate annotations are used.
|
||||
</li>
|
||||
|
||||
<li>
|
||||
You can now create Querydsl domain type instances like this :
|
||||
|
||||
<source>
|
||||
protected final Domain.Address address = new Domain.Address("address");
|
||||
|
||||
protected final Domain.Bookmark bookmark = new Domain.Bookmark("bookmark");
|
||||
|
||||
protected final Domain.NetworkLink nl = new Domain.NetworkLink("nl");
|
||||
|
||||
protected final Domain.Subscription sub = new Domain.Subscription("sub");
|
||||
|
||||
protected final Domain.Tag tag1 = new Domain.Tag("tag1");
|
||||
</source>
|
||||
|
||||
and reference them in your queries like this
|
||||
|
||||
<source>
|
||||
public SearchResults<Bookmark> findBookmarksWithTags(String[] tagNames,
|
||||
QueryModifiers mod) {
|
||||
return select(distinct(bookmark)).from(bookmark)
|
||||
.innerJoin(FETCH, bookmark.address)
|
||||
.innerJoin(bookmark.tags.as(tag1))
|
||||
.where(tag1.name.in(tagNames))
|
||||
.orderBy(bookmark.created.desc()).restrict(mod).listResults();
|
||||
}
|
||||
|
||||
protected <RT> HqlQuery<RT> select(Expr<RT> s){
|
||||
return new HqlQuery<RT>(currentSession()).select(s);
|
||||
}
|
||||
|
||||
</source>
|
||||
|
||||
The method distinct is taken via a static import from com.mysema.query.grammar.HqlGrammar
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For more examples on how to use the Querydsl API visit the API docs of the querydsl-core and querydsl-hql modules
|
||||
or look through the examples in the <a href="xref/index.html">source code</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Feel also free to contact us if you need any help.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
</body>
|
||||
</document>
|
||||
@ -1,56 +0,0 @@
|
||||
<document>
|
||||
<properties>
|
||||
<author email="timo@mysema.com">Timo Westkämper</author>
|
||||
<title>Querydsl</title>
|
||||
</properties>
|
||||
<body>
|
||||
<section name="Querydsl">
|
||||
<p>
|
||||
Querydsl (spell: query diesel) is a framework which enables the construction of statically typed SQL-like queries.
|
||||
Instead of writing queries as inline strings or externalizing them into XML files they can be constructed via a
|
||||
<a href="http://www.martinfowler.com/bliki/FluentInterface.html">fluent</a>
|
||||
<a href="http://www.martinfowler.com/bliki/DomainSpecificLanguage.html">DSL</a>/API like Querydsl.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The benefits of using a fluent API in comparison to simple strings are
|
||||
<ul>
|
||||
<li>code completion in IDE</li>
|
||||
<li>almost none syntactically invalid queries allowed</li>
|
||||
<li>domain types and properties can be referenced safely</li>
|
||||
<li>adopts better to refactoring changes in domain types</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Here a quick example for the impatient ones :
|
||||
<source>
|
||||
<span style="font-weight:bold;">public</span> SearchResults<Bookmark> findBookmarksWithTags(String[] tagNames,
|
||||
QueryModifiers mod) {
|
||||
<span style="font-weight:bold;">return</span> select(distinct(<span style="color:blue;">bookmark</span>)).from(<span style="color:blue;">bookmark</span>)
|
||||
.innerJoin(<span style="color:blue;">FETCH</span>, <span style="color:blue;">bookmark.address</span>)
|
||||
.innerJoin(<span style="color:blue;">bookmark.tags</span>.as(<span style="color:blue;">tag1</span>))
|
||||
.where(<span style="color:blue;">tag1.name</span>.in(tagNames))
|
||||
.orderBy(<span style="color:blue;">bookmark.created</span>.desc()).restrict(mod).listResults();
|
||||
}
|
||||
</source>
|
||||
which represents the followoing HQL query
|
||||
|
||||
<source>
|
||||
select distinct bookmark from Bookmark bookmark
|
||||
inner join fetch bookmark.address
|
||||
inner join bookmark.tags as tag1
|
||||
where tag1.name in :tagNames
|
||||
order by bookmark.created desc
|
||||
</source>
|
||||
|
||||
</p>
|
||||
|
||||
<p>
|
||||
More examples of Hibernate queries and their Querydsl equivalents can be found
|
||||
<a href="xref-test/com/mysema/query/grammar/hql/HqlParserTest.html">here</a>.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
</body>
|
||||
</document>
|
||||
@ -1,22 +0,0 @@
|
||||
<document>
|
||||
<properties>
|
||||
<author email="timo@mysema.com">Timo Westkämper</author>
|
||||
<title>Modules</title>
|
||||
</properties>
|
||||
<body>
|
||||
|
||||
<section name="Modules">
|
||||
<p>
|
||||
Querydsl is based on various modules with different purposes. The modules are
|
||||
<ul>
|
||||
<li><a href="../querydsl-core">querydsl-core</a> with the basic constructs used in various query language specific versions of the API</li>
|
||||
<li><a href="../querydsl-annotations">querydsl-annotations</a> with Java annotations for domain and DTO types</li>
|
||||
<li><a href="../querydsl-apt">querydsl-apt</a> for code generation via <a href="http://java.sun.com/j2se/1.5.0/docs/guide/apt/GettingStarted.html">APT</a></li>
|
||||
<li><a href="../querydsl-hql">querydsl-hql</a> as a fluent API for <a href="http://www.hibernate.org/hib_docs/reference/en/html/queryhql.html">Hibernate HQL</a></li>
|
||||
<li><a href="../querydsl-sql">querydsl-sql</a> as a fluent API for SQL</li>
|
||||
</ul>
|
||||
</p>
|
||||
</section>
|
||||
|
||||
</body>
|
||||
</document>
|
||||
Loading…
Reference in New Issue
Block a user