public void testFetchPlanIsolationHint() {
String hintName = "openjpa.FetchPlan.Isolation";
EntityManager em = emf.createEntityManager();
OpenJPAEntityManager oem = (OpenJPAEntityManager) em.getDelegate();
JDBCFetchPlan fPlan = (JDBCFetchPlan) oem.getFetchPlan();
JDBCFetchConfigurationImpl fConfig = (JDBCFetchConfigurationImpl)
((EntityManagerImpl) oem).getBroker().getFetchConfiguration();
isolationHintTest(oem, fPlan, fConfig, hintName, "default",
IsolationLevel.DEFAULT, -1);
isolationHintTest(oem, fPlan, fConfig, hintName, "DEFAULT",
IsolationLevel.DEFAULT, -1);
isolationHintTest(oem, fPlan, fConfig, hintName,
IsolationLevel.DEFAULT, IsolationLevel.DEFAULT, -1);
boolean supportIsolationForUpdate = ((JDBCConfiguration) fConfig
.getContext().getConfiguration()).getDBDictionaryInstance()
.supportsIsolationForUpdate();
if (supportIsolationForUpdate) {
isolationHintTest(oem, fPlan, fConfig, hintName, "none",
IsolationLevel.NONE, Connection.TRANSACTION_NONE);
isolationHintTest(oem, fPlan, fConfig, hintName, "NONE",
IsolationLevel.NONE, Connection.TRANSACTION_NONE);
isolationHintTest(oem, fPlan, fConfig, hintName,
IsolationLevel.NONE, IsolationLevel.NONE,
Connection.TRANSACTION_NONE);
isolationHintTest(oem, fPlan, fConfig, hintName,
"read-uncommitted", IsolationLevel.READ_UNCOMMITTED,
Connection.TRANSACTION_READ_UNCOMMITTED);
isolationHintTest(oem, fPlan, fConfig, hintName,
"READ_UNCOMMITTED", IsolationLevel.READ_UNCOMMITTED,
Connection.TRANSACTION_READ_UNCOMMITTED);
isolationHintTest(oem, fPlan, fConfig, hintName,
IsolationLevel.READ_UNCOMMITTED,
IsolationLevel.READ_UNCOMMITTED,
Connection.TRANSACTION_READ_UNCOMMITTED);
isolationHintTest(oem, fPlan, fConfig, hintName, "read-committed",
IsolationLevel.READ_COMMITTED,
Connection.TRANSACTION_READ_COMMITTED);
isolationHintTest(oem, fPlan, fConfig, hintName, "READ_COMMITTED",
IsolationLevel.READ_COMMITTED,
Connection.TRANSACTION_READ_COMMITTED);
isolationHintTest(oem, fPlan, fConfig, hintName,
IsolationLevel.READ_COMMITTED, IsolationLevel.READ_COMMITTED,
Connection.TRANSACTION_READ_COMMITTED);
isolationHintTest(oem, fPlan, fConfig, hintName, "repeatable-read",
IsolationLevel.REPEATABLE_READ,
Connection.TRANSACTION_REPEATABLE_READ);
isolationHintTest(oem, fPlan, fConfig, hintName, "REPEATABLE_READ",
IsolationLevel.REPEATABLE_READ,
Connection.TRANSACTION_REPEATABLE_READ);
isolationHintTest(oem, fPlan, fConfig, hintName,
IsolationLevel.REPEATABLE_READ, IsolationLevel.REPEATABLE_READ,
Connection.TRANSACTION_REPEATABLE_READ);
isolationHintTest(oem, fPlan, fConfig, hintName, "serializable",
IsolationLevel.SERIALIZABLE,
Connection.TRANSACTION_SERIALIZABLE);
isolationHintTest(oem, fPlan, fConfig, hintName, "SERIALIZABLE",
IsolationLevel.SERIALIZABLE,
Connection.TRANSACTION_SERIALIZABLE);
isolationHintTest(oem, fPlan, fConfig, hintName,
IsolationLevel.SERIALIZABLE, IsolationLevel.SERIALIZABLE,
Connection.TRANSACTION_SERIALIZABLE);
}
try {
fPlan.setHint(hintName, "xxxxx");
fPlan.setHint(hintName, "yyyyy");
fail("Expecting a IllegalArgumentException.");
} catch (Exception e) {
assertTrue("Caught expected exception",
IllegalArgumentException.class.isAssignableFrom(e.getClass()));
}
try {
fPlan.setHint(hintName, "12345");
fPlan.setHint(hintName, "67890");
fail("Expecting a a IllegalArgumentException.");
} catch (Exception e) {
assertTrue("Caught expected exception",
IllegalArgumentException.class.isAssignableFrom(e.getClass()));
}