@param hash The hash code we are looking for
@return An array of matching PhotoInfo objects or <code>null</code>
if none found.
*/
static public PhotoInfo[] retrieveByOrigHash(byte[] hash) {
ODMGXAWrapper txw = new ODMGXAWrapper();
Implementation odmg = ODMG.getODMGImplementation();
Transaction tx = odmg.currentTransaction();
PhotoInfo photos[] = null;
try {
PersistenceBroker broker = ((HasBroker) tx).getBroker();
Criteria crit = new Criteria();
crit.addEqualTo( "origInstanceHash", hash );
QueryByCriteria q = new QueryByCriteria( PhotoInfo.class, crit );
Collection result = broker.getCollectionByQuery( q );
if ( result.size() > 0 ) {
photos = (PhotoInfo[]) result.toArray( new PhotoInfo[result.size()] );
}
txw.commit();
} catch ( Exception e ) {
log.warn( "Error executing query: " + e.getMessage() );
e.printStackTrace( System.out );
txw.abort();
}
return photos;
}