mirror of https://github.com/apache/openjpa.git
OPENJPA-1413: fix NPE when update using CASE expression on Derby
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@886991 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f697798fd8
commit
3f3d586c73
|
@ -106,7 +106,8 @@ abstract class CompareEqualExpression
|
||||||
boolean val2Null = _val2 instanceof Const
|
boolean val2Null = _val2 instanceof Const
|
||||||
&& ((Const) _val2).isSQLValueNull(sel, ctx, bstate.state2);
|
&& ((Const) _val2).isSQLValueNull(sel, ctx, bstate.state2);
|
||||||
appendTo(sel, ctx, bstate, buf, val1Null, val2Null);
|
appendTo(sel, ctx, bstate, buf, val1Null, val2Null);
|
||||||
sel.append(buf, state.joins);
|
if (sel != null)
|
||||||
|
sel.append(buf, state.joins);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectColumns(Select sel, ExpContext ctx, ExpState state,
|
public void selectColumns(Select sel, ExpContext ctx, ExpState state,
|
||||||
|
|
|
@ -249,22 +249,19 @@ public class TestJPQLScalarExpressions extends AbstractTestCase {
|
||||||
assertEquals("the name is not Jacob", "Jacob", result3[0]);
|
assertEquals("the name is not Jacob", "Jacob", result3[0]);
|
||||||
assertEquals("the credit rating is not 'POOR'", "POOR", result3[1]);
|
assertEquals("the credit rating is not 'POOR'", "POOR", result3[1]);
|
||||||
|
|
||||||
/*
|
|
||||||
// this jpql fail with NPE in Derby. It works with DB2
|
|
||||||
String update2 = "update CompUser c set c.creditRating = " +
|
String update2 = "update CompUser c set c.creditRating = " +
|
||||||
" CASE WHEN c.name ='Jacob' THEN " +
|
" CASE WHEN c.name ='Jacob' THEN " +
|
||||||
"org.apache.openjpa.persistence.common.apps.CompUser$
|
"org.apache.openjpa.persistence.common.apps.CompUser$CreditRating.POOR" +
|
||||||
CreditRating.POOR" +
|
|
||||||
" WHEN c.name = 'Ugo' THEN " +
|
" WHEN c.name = 'Ugo' THEN " +
|
||||||
"org.apache.openjpa.persistence.common.apps.CompUser$
|
"org.apache.openjpa.persistence.common.apps.CompUser$CreditRating.GOOD " +
|
||||||
CreditRating.GOOD " +
|
|
||||||
" ELSE " +
|
" ELSE " +
|
||||||
"org.apache.openjpa.persistence.common.apps.CompUser$
|
"org.apache.openjpa.persistence.common.apps.CompUser$CreditRating.EXCELLENT " +
|
||||||
CreditRating.EXCELLENT " +
|
|
||||||
" END ";
|
" END ";
|
||||||
*/
|
int updateCount = em.createQuery(update2).executeUpdate();
|
||||||
|
assertEquals("the result is not 6", 6, updateCount);
|
||||||
|
|
||||||
String update2 = "update CompUser c set c.creditRating = " +
|
|
||||||
|
String update3 = "update CompUser c set c.creditRating = " +
|
||||||
" CASE WHEN c.age > 30 THEN " +
|
" CASE WHEN c.age > 30 THEN " +
|
||||||
"org.apache.openjpa.persistence.common.apps." +
|
"org.apache.openjpa.persistence.common.apps." +
|
||||||
"CompUser$CreditRating.POOR" +
|
"CompUser$CreditRating.POOR" +
|
||||||
|
@ -275,7 +272,7 @@ public class TestJPQLScalarExpressions extends AbstractTestCase {
|
||||||
"org.apache.openjpa.persistence.common.apps." +
|
"org.apache.openjpa.persistence.common.apps." +
|
||||||
"CompUser$CreditRating.EXCELLENT " +
|
"CompUser$CreditRating.EXCELLENT " +
|
||||||
" END ";
|
" END ";
|
||||||
int updateCount = em.createQuery(update2).executeUpdate();
|
updateCount = em.createQuery(update3).executeUpdate();
|
||||||
assertEquals("the result is not 6", 6, updateCount);
|
assertEquals("the result is not 6", 6, updateCount);
|
||||||
|
|
||||||
String query4 = "select e.name, e.creditRating from CompUser e " +
|
String query4 = "select e.name, e.creditRating from CompUser e " +
|
||||||
|
@ -300,7 +297,7 @@ public class TestJPQLScalarExpressions extends AbstractTestCase {
|
||||||
((org.apache.openjpa.persistence.common.apps.CompUser.CreditRating)
|
((org.apache.openjpa.persistence.common.apps.CompUser.CreditRating)
|
||||||
result4[1]).name());
|
result4[1]).name());
|
||||||
|
|
||||||
String update3 = "update CompUser c set c.creditRating = " +
|
String update4 = "update CompUser c set c.creditRating = " +
|
||||||
" CASE c.age WHEN 35 THEN " +
|
" CASE c.age WHEN 35 THEN " +
|
||||||
"org.apache.openjpa.persistence.common.apps." +
|
"org.apache.openjpa.persistence.common.apps." +
|
||||||
"CompUser$CreditRating.POOR" +
|
"CompUser$CreditRating.POOR" +
|
||||||
|
@ -311,7 +308,7 @@ public class TestJPQLScalarExpressions extends AbstractTestCase {
|
||||||
"org.apache.openjpa.persistence.common.apps." +
|
"org.apache.openjpa.persistence.common.apps." +
|
||||||
"CompUser$CreditRating.EXCELLENT " +
|
"CompUser$CreditRating.EXCELLENT " +
|
||||||
" END ";
|
" END ";
|
||||||
result = em.createQuery(update3).executeUpdate();
|
result = em.createQuery(update4).executeUpdate();
|
||||||
assertEquals("the result is not 6", 6, result);
|
assertEquals("the result is not 6", 6, result);
|
||||||
|
|
||||||
// Derby fails but DB2 works
|
// Derby fails but DB2 works
|
||||||
|
|
Loading…
Reference in New Issue