Hello,

Personally I'm using the following pattern alot:

DomainObject o = Utils.getOne(session.find(xxxxxx));

When I expect to get exactly one from a query, or getOneorNone() if I expect one or zero results. I assume many people use something like that too, so I'd suggest creating findOne() / findOneOrNone() methods in Query / Session.

If findOne() finds 0 or more than 1 objects, it will throw an exception
If findOneOrNone() finds more than one object, it will throw an exception

findOneOrNone is a bit of a strange methodname in my ears.

Also, what about the unique properties? In the hibernate mapping, you can set "unique". Shouldn't there be a session.loadByUniqueProperty(String propertyName, Object value) ?(should throw an exception when it's not found, and when propertyName is not defined as unique)

I've created a report (http://opensource.atlassian.com/projects/hibernate/browse/HHH-820) and I'm creating the patch, which will be there in a couple of minutes if sourceforge works

Joris


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to