String hintName = "openjpa.jdbc.JoinSyntax";
EntityManager em = emf.createEntityManager();
OpenJPAEntityManager oem = (OpenJPAEntityManager) em.getDelegate();
JDBCFetchPlan fPlan = (JDBCFetchPlan) oem.getFetchPlan();
JDBCFetchConfigurationImpl fConfig = (JDBCFetchConfigurationImpl)
((EntityManagerImpl) oem).getBroker().getFetchConfiguration();
joinSyntaxHintTest(fPlan, fConfig, hintName, String
.valueOf(JoinSyntaxes.SYNTAX_SQL92), JoinSyntax.SQL92,
JoinSyntaxes.SYNTAX_SQL92);
joinSyntaxHintTest(fPlan, fConfig, hintName, JoinSyntaxes.SYNTAX_SQL92,
JoinSyntax.SQL92, JoinSyntaxes.SYNTAX_SQL92);
joinSyntaxHintTest(fPlan, fConfig, hintName, String
.valueOf(JoinSyntaxes.SYNTAX_TRADITIONAL), JoinSyntax.TRADITIONAL,
JoinSyntaxes.SYNTAX_TRADITIONAL);
joinSyntaxHintTest(fPlan, fConfig, hintName,
JoinSyntaxes.SYNTAX_TRADITIONAL, JoinSyntax.TRADITIONAL,
JoinSyntaxes.SYNTAX_TRADITIONAL);
joinSyntaxHintTest(fPlan, fConfig, hintName, String
.valueOf(JoinSyntaxes.SYNTAX_DATABASE), JoinSyntax.DATABASE,
JoinSyntaxes.SYNTAX_DATABASE);
joinSyntaxHintTest(fPlan, fConfig, hintName,
JoinSyntaxes.SYNTAX_DATABASE, JoinSyntax.DATABASE,
JoinSyntaxes.SYNTAX_DATABASE);
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 IllegalArgumentException.");
} catch (Exception e) {
assertTrue("Caught expected exception",
IllegalArgumentException.class.isAssignableFrom(e.getClass()));
}
try {
fPlan.setHint(hintName, -1);
fPlan.setHint(hintName, -2);
fail("Expecting a IllegalArgumentException.");
} catch (Exception e) {
assertTrue("Caught expected exception",
IllegalArgumentException.class.isAssignableFrom(e.getClass()));
}
try {
fPlan.setHint(hintName, FetchConfiguration.DEFAULT);
assertEquals(fConfig.getJoinSyntax(),
((JDBCConfiguration) fConfig.getContext().getConfiguration())
.getDBDictionaryInstance().joinSyntax);
} catch (Exception e) {
fail("Unexpected " + e.getClass().getName());
}
em.close();