org.evcode.queryfy:queryfy-querydsl

Queryfy translate a SQL-like DSL in an query object

License

License

Categories

Categories

Querydsl Data Databases
GroupId

GroupId

org.evcode.queryfy
ArtifactId

ArtifactId

queryfy-querydsl
Last Version

Last Version

1.2.2
Release Date

Release Date

Type

Type

pom
Description

Description

Queryfy translate a SQL-like DSL in an query object
Project Organization

Project Organization

Edmo Vamerlatti Costa

Download queryfy-querydsl

How to add to project

<!-- https://jarcasting.com/artifacts/org.evcode.queryfy/queryfy-querydsl/ -->
<dependency>
    <groupId>org.evcode.queryfy</groupId>
    <artifactId>queryfy-querydsl</artifactId>
    <version>1.2.2</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/org.evcode.queryfy/queryfy-querydsl/
implementation 'org.evcode.queryfy:queryfy-querydsl:1.2.2'
// https://jarcasting.com/artifacts/org.evcode.queryfy/queryfy-querydsl/
implementation ("org.evcode.queryfy:queryfy-querydsl:1.2.2")
'org.evcode.queryfy:queryfy-querydsl:pom:1.2.2'
<dependency org="org.evcode.queryfy" name="queryfy-querydsl" rev="1.2.2">
  <artifact name="queryfy-querydsl" type="pom" />
</dependency>
@Grapes(
@Grab(group='org.evcode.queryfy', module='queryfy-querydsl', version='1.2.2')
)
libraryDependencies += "org.evcode.queryfy" % "queryfy-querydsl" % "1.2.2"
[org.evcode.queryfy/queryfy-querydsl "1.2.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • queryfy-querydsl-core
  • queryfy-querydsl-jpa

Queryfy

Build Status

Queryfy is a simple SQL-like language designed to provide a safe and flexible way to filter, sort and to paginate data over REST APIs and Front-end as well.

  • As it is NOT SQL, there is no SQL Injection.

  • The Queryfy-Core is responsible for build the abstract syntax tree (AST) from the query string and use a provided visitor to build the filter object (eg. JPAQuery, etc).

  • You can use the existing implementation (QueryDSL JPA, MongoDB (Bson)) or implement your own visitor.

Usage

<dependency>
    <groupId>org.evcode.queryfy</groupId>
    <artifactId>queryfy-core</artifactId>
    <version>1.2.2</version>
</dependency>

QueryDSL

<dependency>
    <groupId>org.evcode.queryfy</groupId>
    <artifactId>queryfy-querydsl-jpa</artifactId>
    <version>1.2.2</version>
</dependency>
EntityManager em = ...;
String query = "select name, age where age > 18 order by name limit 0, 100";

JPAQueryDslParser parser = new JPAQueryDslParser(em);

//Create an evaluation context. All paths added here will be available on the query syntax
QueryDslContext context = QueryDslContext.from(QTest.test)
                .withPath("name", QTest.test.name)
                .withPath("age", QTest.test.age)
                .withPath("other.id", QTest.test.other.id)
                .withPath("other.name", QTest.test.other.name)
                .build();
                
//Parse the query string into a QueryDSL JPAQuery or JPAEvaluatedQuery object
JPAEvaluatedQuery jpaQuery = parser.parseAndFind(query, context);

//List applying the projections fields (name and age)
List<Test> list = jpaQuery.listWithProjections();

MongoDB (Bson)

<dependency>
    <groupId>org.evcode.queryfy</groupId>
    <artifactId>queryfy-mongodb</artifactId>
    <version>1.2.2</version>
</dependency>
String query = "select name, age where age > 18 order by name limit 0, 100"; 
MongodbQueryParser parser = new MongodbQueryParser();

//Create an evaluation context. All paths added here will be available on the query syntax
MongodbContext context = MongodbContext.builder()
                .withPath("name")
                .withPath("age")
                .withPath("otherId", "other.id")
                .build();
                
MongoCollection<Document> collection = ....;

//The parseAndFind method will parse the query and return a MongoDB FindIterable. you can also use the parseAndApply method
//to set the parameters on an existing FindIterable object.
FindIterable<Document> result = parser.parseAndFind(collection, query, context);

See more

Documentation

Versions

Version
1.2.2
1.2.1
1.2.0
1.0.0
v1.0.0