Hibernate – passing a complete object to HQL or find()

I’m currently experimenting with Hibernate (hope I’d get back to OFBiz soon; or that OFBiz uses Hibernate sooner).

Is there a way that I can retrieve (find/load) records from the database using my an object in the following manner:

{% highlight java %} …
//foo and bar does not relate to the Object’s primary keys
//Other properties have null or unset values

List list = session.find(myObject);
// looks up an object in the database that matches foo (f) and bar(b)
{% endhighlight %}

Is there a similar thing in Hibernate that would allow to load / find an object from the database by passing a temp object filled with the required criteria into a Hibernate function?

Appreciate the help.


Found it – Thanks for the folks at Hibernate Beginner’s Forum and anthony from Hibernate team:

The folks at Hibernate have done a great job. It is already there. I’ll try it tomorrow.

It’s called “Example Queries” (Query By Example – QBE) Pardon my ignorance – it seems that it’s already widespread.