Skip to content

Commit

Permalink
#330 Add README.md for SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
timowest committed Jan 29, 2013
1 parent 5fb1b5d commit 845c9ab
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 7 deletions.
6 changes: 3 additions & 3 deletions querydsl-jdo/README.md
Expand Up @@ -52,9 +52,9 @@ If you use Eclipse, run mvn eclipse:eclipse to update your Eclipse project to in

Now you are able to construct JDOQL query instances and instances of the query domain model.

**Example query**
**Querying**

Here is an example query using the default variable of the QCustomer class
Querying with Querydsl JDO is as simple as this :

QCustomer customer = QCustomer.customer;
JDOQuery query = new JDOQuery(pm);
Expand All @@ -63,4 +63,4 @@ Here is an example query using the default variable of the QCustomer class
.uniqueResult(customer);
query.close();

For more information on the Querydsl JDO module read the reference documentation http://www.querydsl.com/static/querydsl/latest/reference/html/ch02s02.html
For more information on the Querydsl JDO module visit the reference documentation http://www.querydsl.com/static/querydsl/latest/reference/html/ch02s02.html
6 changes: 3 additions & 3 deletions querydsl-jpa/README.md
Expand Up @@ -54,14 +54,14 @@ If you use Eclipse, run mvn eclipse:eclipse to update your Eclipse project to in

Now you are able to construct JPQL query instances and instances of the query domain model.

**Example query**
**Querying**

Here is an example query using the default variable of the QCustomer class
Querying with Querydsl JPA is as simple as this :

QCustomer customer = QCustomer.customer;
JPAQuery query = new JPAQuery(entityManager);
Customer bob = query.from(customer)
.where(customer.firstName.eq("Bob"))
.uniqueResult(customer);
For more information on the Querydsl JPA module read the reference documentation http://www.querydsl.com/static/querydsl/latest/reference/html/ch02.html#jpa_integration
For more information on the Querydsl JPA module visit the reference documentation http://www.querydsl.com/static/querydsl/latest/reference/html/ch02.html#jpa_integration
2 changes: 1 addition & 1 deletion querydsl-mongodb/README.md
Expand Up @@ -59,4 +59,4 @@ Querying with Querydsl Mongodb with Morphia is as simple as this :
.list();


For more information on the Querydsl Mongodb module read the reference documentation http://www.querydsl.com/static/querydsl/latest/reference/html/ch02s06.html
For more information on the Querydsl Mongodb module visit the reference documentation http://www.querydsl.com/static/querydsl/latest/reference/html/ch02s06.html
73 changes: 73 additions & 0 deletions querydsl-sql/README.md
@@ -0,0 +1,73 @@
# Querydsl SQL #

The SQL module provides integration with the JDBC API.

**Maven integration**

Add the following dependencies to your Maven project :

<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-sql</artifactId>
<version>${querydsl.version}</version>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-sql-codegen</artifactId>
<version>${querydsl.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>

The querydsl-sql-codegen dependency can be skipped, if code generation happens via Maven or Ant.
2.3.2. Code generation via Maven

This functionality is also available as a Maven plugin. The presented example can be declared like this in the POM :

<plugin>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-maven-plugin</artifactId>
<version>${querydsl.version}</version>
<executions>
<execution>
<goals>
<goal>export</goal>
</goals>
</execution>
</executions>
<configuration>
<jdbcDriver>org.apache.derby.jdbc.EmbeddedDriver</jdbcDriver>
<jdbcUrl>jdbc:derby:target/demoDB;create=true</jdbcUrl>
<packageName>com.myproject.domain</packageName>
<targetFolder>${project.basedir}/target/generated-sources/java</targetFolder>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>${derby.version}</version>
</dependency>
</dependencies>
</plugin>

Use the goal test-export to add the targetFolder as a test compile source root instead of a compile source root.

**Querying**

Querying with Querydsl SQL is as simple as this :

QCustomer customer = new QCustomer("c");

SQLTemplates dialect = new HSQLDBTemplates(); // SQL-dialect
SQLQuery query = new SQLQuery(connection, dialect);
List<String> lastNames = query.from(customer)
.where(customer.firstName.eq("Bob"))
.list(customer.lastName);
For more information on the Querydsl JDO module visit the reference documentation http://www.querydsl.com/static/querydsl/latest/reference/html/ch02s03.html

0 comments on commit 845c9ab

Please sign in to comment.