Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

pnowy/NativeCriteria

Repository files navigation

Development && Participation

If you want to participate on the development please perform the pull request to the develop branch.

Documentation

Documentation is available on http://nativecriteria.przemeknowak.com/

Library available on Maven Central Repository


<dependency>
<groupId>com.github.pnowy.ncgroupId>
<artifactId>nativeCriteria-coreartifactId>
<version>3.2.0version>
dependency>


<dependency>
<groupId>com.github.pnowy.ncgroupId>
<artifactId>nativeCriteria-springartifactId>
<version>3.2.0version>
dependency>

Simple example:

// SELECT a.city FROM address a WHERE a.zip_code IS NULL AND city := ? ORDER BY a.city ASC
NativeCriteria nc = new NativeCriteria(new JpaQueryProvider(entityManager), "address", "a")
.setProjection(NativeExps.projection().addProjection("a.city"))
.add(NativeExps.isNull("a.zip_code"));
.setOrder(NativeExps.order().add("a.city", OrderType.ASC));

// dynamic where part
if (StringUtils.isNotEmpty(city)) {
nc.add(NativeExps.eq("a.city", city))
}

// get the results
CriteriaResult res = c.criteriaResult();
List<String> cityNames = new ArrayList<>();
while (res.next()) {
resp.add(res.getString("a.city"));
}

About

Ultra lightweight lib to generate dynamic SQL based on hibernate session

Topics

Resources

Readme

Stars

Watchers

Forks

Packages

Contributors

Languages