From: Dain S. <da...@da...> - 2002-09-12 16:02:44
|
Brian Macy wrote: > I'm having a difficult time as several important pieces of behavior in > my system rely on checks against existence. Right now I just have to > catch the FinderException and handle it there. The problem is that it > appears the FinderException is occurring when there are some transient > database problems too. > > What I need is a finder like function that returns null for not found, > the object if found, and throws exceptions when there are errors. Last time I checked that is the way the EJB 2.1 spec will work. Unfortunately, it will not be final for a while and is targeted for JBoss 4.0. > What's really hurting is that this is causing data integrity issues > (FinderException thrown, so I end up adding a duplicate item, which then > causes every finder method that assumes it is returning a single object > to also throw an exception). I can deal with some of this by adding > constraints directly to the DB but a significant reason for using J2EE > was to be DB independent. You should definitely have pk constraints so you can't get dupes. > Anyways, the death of the system ends up being: > > - sudden high load on the DB > - followed by transactions rollback (DB load stays high) > - removing bean with tx set errors I think Bill fixed the last one of these yesterday (or you have a bad custom primary key class). > - OutOfMemory Exceptions and SQL DB running out of connections > - If I'm lucky the system tries to shutdown > > > Actually, maybe I just partially solved my problem. It looks like there > is an ObjectNotFoundException sublcassing FinderException... assuming it > is thrown only when a successful query is made and nothing is found I > should be generally ok. Still, something that returns null would be much > better (without having to return a Collection). You should always get an ObjectNotFoundException when the object is not found and a FinderException when a real problem happens. -dain |