public void testConcatFunc2() {
EntityManager em = currentEntityManager();
startTx(em);
CompUser user = em.find(CompUser.class, userid1);
assertNotNull("the user is null", user);
assertEquals("the users name is not seetha", user.getName(), "Seetha");
String query = "UPDATE CompUser e " +
"SET e.name = " +
"CONCAT('', '') WHERE e.name='Seetha'";
int result = em.createQuery(query).executeUpdate();
assertEquals(1, result);
user = em.find(CompUser.class, userid1);
em.refresh(user);
assertNotNull(user);
// Empty strings are stored as null on Oracle so the assertion below
// must be handled differently on that DB. The docs indicate that
// this may not be the case in future releases so either result is
// allowed.
// The note in this section of Oracle doc explains the behavior:
// http://download.oracle.com/docs/cd/B14117_01/server.101/ +
// b10759/sql_elements005.htm#sthref511
DBDictionary dict = ((JDBCConfiguration) getEmf().getConfiguration())
.getDBDictionaryInstance();
if (dict instanceof OracleDictionary) {
assertTrue(user.getName() == null ||
"".equals(user.getName()));
} else if (dict instanceof SybaseDictionary) {
assertEquals(" ", user.getName());
} else {
assertEquals("", user.getName());
}
endTx(em);
endEm(em);
}