Possible gap in my understanding, but I would expect an exception in this case
based on section 3.2.5 of the JPA 2.0 specification: "If [entity] X is new,
detached, or removed entity, the IllegalArgumentException is thrown".
try {
TestEntity refreshDetached = new TestEntity("refresh detached");
em.persist(refreshDetached);
em.flush();
em.detach(refreshDetached);
em.refresh(refreshDetached);
logger.error("ERROR: No exception from em.refresh(detached)");
} catch (IllegalArgumentException e) {
logger.info("SUCCESS: Refresh detached");
} catch (Exception e) {
logger.error("ERROR: Unexpected exception from em.refresh(detached): "
+ e.toString());
}
ERROR: No exception from em.refresh(detached)