@SuppressWarnings("unchecked")
private void testCustomObjectCRUDInternal(EntityManager entityManager) {
deleteAll(NewCustomObject.class);
final String name = "Sample CustomObject";
NewCustomObject entity = new NewCustomObject();
entity.setName(name);
entity.setSomeCustomField("value1");
persistForceObject(entityManager, entity);
// First try with find()
entity = entityManager.find(entity.getClass(), entity.getId());
assertEquals(entity.getName(), name, "Name did not match.");
// Then try with query()
List<NewCustomObject> results = entityManager.createQuery("Select t From NewCustomObject t").getResultList();
entity = results.iterator().next();
assertEquals(entity.getName(), name, "Name did not match.");
// Now we need to make sure update works on MappsedSuperclass entities
final String newName = "Renamed CustomObject";
entity.setName(newName);
mergeForceObject(entityManager, entity);
// Read back upated object
results = entityManager.createQuery("Select t From NewCustomObject t where name = ?1")
.setParameter(1, newName).getResultList();
NewCustomObject entity1 = results.iterator().next();
assertEquals(entity1.getId(), entity.getId(), "Ids did not match.");
}