Code:
public ReleaseOffice findByNumber( String number ) throws DomainObjectNotFoundException {
if( number == null ) throw new DomainObjectNotFoundException();
return (ReleaseOffice) findOne( "from ReleaseOffice where number = ?", number );
}
findOne() does this:
Code:
protected final Object findOne( String query, Object object ) throws DomainObjectNotFoundException {
return getFirst( findMany( query, object ), query );
}
findMany does this:
Code:
protected final List findMany( String query, Object object ) {
return getHibernateTemplate().find( query, object );
}
That's the lowest my code does. The rest is spring.
getFirst() does this:
Code:
private final Object getFirst( List list, String query ) throws DomainObjectNotFoundException {
if( list.isEmpty() ) {
throw new DomainObjectNotFoundException( "findOne() did not return a single object with the findMany '" + query + "'" );
}
return list.get( 0 );
}
The mapping is
Code:
<class name="com.upfactor.rns.domain.core.ReleaseOffice" table="release_office">
<cache usage="read-write" />
<id name="id" column="id" type="long" unsaved-value="0">
<generator class="sequence">
<param name="sequence">release_office_id_seq</param>
</generator>
</id>
<property name="name" column="name" />
<property name="number" column="number" />
</class>
The query and mapping is so obvious that I am really am baffled. Thanks so much for the help.[/code]