A simple dsl for criteria and hql with scala
Scala Java Groovy
Pull request Compare This branch is 11 commits ahead of asouza:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
out supporting simple selects on for comprehensions Nov 9, 2011
src
.gitignore
LICENSE
README
build.gradle lacking of tests... sad... i have to use the magic list method Mar 3, 2011

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]