public void testConcatSubStringFunc() {
EntityManager em = currentEntityManager();
startTx(em);
CompUser user = em.find(CompUser.class, userid1);
assertNotNull("user is null", user);
assertEquals("the name is not seetha", "Seetha", user.getName());
String query = "UPDATE CompUser e SET e.name = " +
"CONCAT('Ablahum', SUBSTRING(e.name, LOCATE('e', e.name), 4)) " +
"WHERE e.name='Seetha'";
int result = em.createQuery(query).executeUpdate();
assertEquals("the result is not 1", 1, result);
user = em.find(CompUser.class, userid1);
em.refresh(user);
assertNotNull("the user is null", user);
assertEquals("the users name is not Ablahumeeth", "Ablahumeeth",
user.getName());
query = "UPDATE CompUser e SET e.name = " +
"CONCAT('XYZ', SUBSTRING(e.name, LOCATE('e', e.name))) " +
"WHERE e.name='Ablahumeeth'";
result = em.createQuery(query).executeUpdate();
assertEquals("the result is not 1", 1, result);
user = em.find(CompUser.class, userid1);
em.refresh(user);
assertNotNull("the user is null", user);
assertEquals("the users name is not XYZeeth", "XYZeeth",
user.getName());
query = "UPDATE CompUser e SET e.name = " +
"CONCAT('CAD', SUBSTRING(e.name, LOCATE('e', e.name, 5))) " +
"WHERE e.name='XYZeeth'";
result = em.createQuery(query).executeUpdate();
assertEquals("the result is not 1", 1, result);
user = em.find(CompUser.class, userid1);
em.refresh(user);
assertNotNull("the user is null", user);
assertEquals("the users name is not CADeth", "CADeth",
user.getName());
endTx(em);
endEm(em);
}