Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A simple dsl for criteria and hql with scala
Scala Java Groovy
branch: master

This branch is 11 commits ahead of asouza:master

Failed to load latest commit information.
out
src
.gitignore
LICENSE
README
build.gradle lacking of tests... sad... i have to use the magic list method

README

Just a simple dsl for criteria and hql with scala. 

Just some examples of string way:

1)session.from[User].orderBy("name".asc).orderBy("age".desc).asList[User]

2) session.from[User].where("age" >= 20).and("name" like "alberto").asList[User]

3) session.from[Address].join("user").where("user.name" equal "alberto2").asList[Address]

4) session.from[Address].join("user").where("user.name" equal "alberto2").and("user.age" >= 20).asList[Address]

5) session.query("from User where name=:name and age =:age").withParams("name" -> "alberto","age" -> alberto.getAge).asList[User]

6) session.from[User].where.hasMany("address").asList[User]

Just some examples of type safe way:

val user = new User
val address = new Address 

	session.from[User].orderBy(_.getName).list
	session.from[User].orderBy(_.getName).asc.list
	session.from[User].orderBy(_.getName).asc.orderBy(_.getAge).desc.list
    val addresses = session.from[Address].join(_.getUser).orderBy(_.getName).list
    val addresses = session.from[Address].join(_.getUser).where("user.name" equal "guilherme").list

	session.from[User].orderBy(_.getName).asc.orderBy(_.getAge).desc.asList[User]

	session.from[User].where(_.getAge \>= 20).where(_.getName like "alberto").asList[User]

	session.from[Address].join(_.getUser).where(_.getName equal "alberto2").asList[Address]

	session.query("from User where name=:name and age =:age").withParams("name" -> "alberto","age" -> alberto.getAge).asList[User]

	session.from[User].where.hasMany(_.getAddresses).asList[User]
Something went wrong with that request. Please try again.