/**
* Returns the entity for the connection.
*/
public Entity getEntity(EntityItem item)
{
Entity itemEntity = item.getEntity();
Class cl = itemEntity.getClass();
Object pk = itemEntity.__caucho_getPrimaryKey();
Entity entity = getEntity(cl, pk);
if (entity != null) {
if (entity.__caucho_getEntityState().isManaged())
return entity;
// else
// jpa/0g40: the copy object was created at some point in
// findEntityItem, but it is still not loaded.
}
else {
try {
entity = item.createEntity(this, pk);
} catch (SQLException e) {
throw new AmberRuntimeException(e);
}
/*
// Create a new entity for the given class and primary key.
try {
entity = (Entity) cl.newInstance();
} catch (Exception e) {
throw new AmberRuntimeException(e);
}
*/
// entity.__caucho_setEntityState(EntityState.P_NON_TRANSACTIONAL);
// entity.__caucho_setPrimaryKey(pk);
// jpa/1000: avoids extra allocations.
addInternalEntity(entity);
}
// jpa/0l43
//_persistenceUnit.copyFromCacheItem(this, entity, item);
// jpa/0l4a
entity.__caucho_retrieve_eager(this);
return entity;
}