Skip to content
This repository

A simple dsl for criteria and hql with scala

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 out
Octocat-spinner-32 src
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README
Octocat-spinner-32 build.gradle
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.