Mirage-SQL
![Join the chat at https://gitter.im/mirage-sql/mirage-sql](https://camo.githubusercontent.com/c951b764c94ae1295e685f44cb3f97919c6733be42a3ede5b47f97228d5a9849/68747470733a2f2f6261646765732e6769747465722e696d2f6d69726167652d73716c2f6d69726167652d73716c2e737667)
Mirage-SQL
is an easy and powerful SQL-centric database access library for Java (or JVM based languages) which provides dynamic SQL templates in plain SQL files.
Using
You can get Mirage-SQL
from the Maven Central repository. Add the following fragment into your pom.xml
.
<dependency>
<groupId>com.miragesql</groupId>
<artifactId>miragesql</artifactId>
<version>2.1.0</version>
</dependency>
or in a Gradle based project add to your build.gradle
the following line:
compile 'com.miragesql:miragesql:2.1.0'
or just download it from the Release Page.
Other Mirage-SQL
Modules:
Module | Description | Gradle | Build |
---|---|---|---|
Mirage-SQL Test | The testing functionality. | testCompile 'com.miragesql:miragesql-test:2.1.0' |
|
Mirage-SQL Tools | The development tools. | testCompile 'com.miragesql:miragesql-tools:2.1.0' |
|
Mirage-SQL Integration | The integration with Spring, Guice and Seasar2. | compile 'com.miragesql:miragesql-integration:2.1.0' |
If you are updating your application from a previous Mirage-SQL
version, see the Migration Guide.
Example
This is a simple example of a SQL template:
SELECT * FROM BOOK
/*BEGIN*/
WHERE
/*IF author != null */
AUTHOR = /*author*/'Naoki Takezoe'
/*END*/
/*IF minPrice != null */
AND PRICE >= /*minPrice*/20
/*END*/
/*IF maxPrice != null */
AND PRICE <= /*maxPrice*/100
/*END*/
/*END*/
ORDER BY BOOK_ID ASC
With Mirage-SQL
you can embed variables or conditions using special
SQL comments, so it's a plain SQL that can be run with any SQL client tool directly. This feature used in the Mirage's SQL template it's called 2Way SQL.
Links:
- A detailed documentation is provided in the Wiki.
- User Support in English is provided in the Gitter Chatroom.
- If you find any bugs or issues, please report them in the GitHub Issue Tracker.
- Release Notes of all previous Mirage-SQL versions.
- Mirage-SQL also has support for other JVM based languages:
- Scala language support - Mirage-SQL Scala
- Groovy language support - Mirage-SQL Groovy
- Clojure language support - Mirage-SQL Clojure