public Object getObjectById( Class<?> clazz, Object id, String fetchGroup )
throws ObjectNotFoundException, ArchivaDatabaseException
{
if ( id == null )
{
throw new ObjectNotFoundException( "Unable to get object '" + clazz.getName() + "' from jdo using null id." );
}
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
if ( fetchGroup != null )
{
pm.getFetchPlan().addGroup( fetchGroup );
}
Object objectId = null;
if ( id instanceof CompoundKey )
{
objectId = pm.newObjectIdInstance( clazz, id.toString() );
}
else
{
objectId = pm.newObjectIdInstance( clazz, id );
}
Object object = pm.getObjectById( objectId );
object = pm.detachCopy( object );
tx.commit();
return object;
}
catch ( JDOObjectNotFoundException e )
{
throw new ObjectNotFoundException( "Unable to find Database Object [" + id + "] of type " + clazz.getName()
+ " using " + ( ( fetchGroup == null ) ? "no fetch-group" : "a fetch-group of [" + fetchGroup + "]" ),
e, id );
}
catch ( JDOException e )
{