Buggy code:
public class TestSubquery extends SingleEMFTestCase { public void setUp ( ) { <START_BUG> setUp ( Customer . class , CustomerKey . class , Order . class , OrderItem . class , Magazine . class , Publisher . class , Employee . class , Dependent . class , DependentId . class , CLEAR_TABLES ) ; <END_BUG> } static String [ ] querys = new String [ ] { "select<seq2seq4repair_space>o1.oid<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o1<seq2seq4repair_space>where<seq2seq4repair_space>o1.oid<seq2seq4repair_space>in<seq2seq4repair_space>" + ( "<seq2seq4repair_space>(select<seq2seq4repair_space>distinct<seq2seq4repair_space>o.oid<seq2seq4repair_space>from<seq2seq4repair_space>OrderItem<seq2seq4repair_space>i,<seq2seq4repair_space>Order<seq2seq4repair_space>o" + "<seq2seq4repair_space>where<seq2seq4repair_space>i.quantity<seq2seq4repair_space>><seq2seq4repair_space>10<seq2seq4repair_space>and<seq2seq4repair_space>o.amount<seq2seq4repair_space>><seq2seq4repair_space>1000<seq2seq4repair_space>and<seq2seq4repair_space>i.lid<seq2seq4repair_space>=<seq2seq4repair_space>o.oid)" ) , "select<seq2seq4repair_space>o.oid<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o<seq2seq4repair_space>where<seq2seq4repair_space>o.customer.name<seq2seq4repair_space>=" + ( "<seq2seq4repair_space>(select<seq2seq4repair_space>max(o2.customer.name)<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o2" + "<seq2seq4repair_space>where<seq2seq4repair_space>o.customer.cid.id<seq2seq4repair_space>=<seq2seq4repair_space>o2.customer.cid.id)" ) , "select<seq2seq4repair_space>o<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o<seq2seq4repair_space>where<seq2seq4repair_space>o.customer.name<seq2seq4repair_space>=" + ( "<seq2seq4repair_space>(select<seq2seq4repair_space>max(o2.customer.name)<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o2" + "<seq2seq4repair_space>where<seq2seq4repair_space>o.customer.cid.id<seq2seq4repair_space>=<seq2seq4repair_space>o2.customer.cid.id)" ) , "select<seq2seq4repair_space>o.oid<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o<seq2seq4repair_space>where<seq2seq4repair_space>o.amount<seq2seq4repair_space>>" + "<seq2seq4repair_space>(select<seq2seq4repair_space>count(i)<seq2seq4repair_space>from<seq2seq4repair_space>o.lineitems<seq2seq4repair_space>i)" , "select<seq2seq4repair_space>o.oid<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o<seq2seq4repair_space>where<seq2seq4repair_space>o.amount<seq2seq4repair_space>>" + "<seq2seq4repair_space>(select<seq2seq4repair_space>count(o.amount)<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o)" , "select<seq2seq4repair_space>o.oid<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o<seq2seq4repair_space>where<seq2seq4repair_space>o.amount<seq2seq4repair_space>>" + "<seq2seq4repair_space>(select<seq2seq4repair_space>count(o.oid)<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o)" , "select<seq2seq4repair_space>o.oid<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o<seq2seq4repair_space>where<seq2seq4repair_space>o.amount<seq2seq4repair_space>>" + "<seq2seq4repair_space>(select<seq2seq4repair_space>avg(o.amount)<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o)" , "select<seq2seq4repair_space>c.name<seq2seq4repair_space>from<seq2seq4repair_space>Customer<seq2seq4repair_space>c<seq2seq4repair_space>where<seq2seq4repair_space>exists" + ( "<seq2seq4repair_space>(select<seq2seq4repair_space>o<seq2seq4repair_space>from<seq2seq4repair_space>c.orders<seq2seq4repair_space>o<seq2seq4repair_space>where<seq2seq4repair_space>o.oid<seq2seq4repair_space>=<seq2seq4repair_space>1)<seq2seq4repair_space>or<seq2seq4repair_space>exists" + "<seq2seq4repair_space>(select<seq2seq4repair_space>o<seq2seq4repair_space>from<seq2seq4repair_space>c.orders<seq2seq4repair_space>o<seq2seq4repair_space>where<seq2seq4repair_space>o.oid<seq2seq4repair_space>=<seq2seq4repair_space>2)" ) , "select<seq2seq4repair_space>c.name<seq2seq4repair_space>from<seq2seq4repair_space>Customer<seq2seq4repair_space>c,<seq2seq4repair_space>in(c.orders)<seq2seq4repair_space>o<seq2seq4repair_space>where<seq2seq4repair_space>o.amount<seq2seq4repair_space>between" + ( "<seq2seq4repair_space>(select<seq2seq4repair_space>max(o.amount)<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o)<seq2seq4repair_space>and" + "<seq2seq4repair_space>(select<seq2seq4repair_space>avg(o.amount)<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o)<seq2seq4repair_space>" ) , "select<seq2seq4repair_space>o.oid<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o<seq2seq4repair_space>where<seq2seq4repair_space>o.amount<seq2seq4repair_space>>" + "<seq2seq4repair_space>(select<seq2seq4repair_space>sum(o2.amount)<seq2seq4repair_space>from<seq2seq4repair_space>Customer<seq2seq4repair_space>c,<seq2seq4repair_space>in(c.orders)<seq2seq4repair_space>o2)<seq2seq4repair_space>" , "select<seq2seq4repair_space>o.oid<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o<seq2seq4repair_space>where<seq2seq4repair_space>o.amount<seq2seq4repair_space>between" + ( "<seq2seq4repair_space>(select<seq2seq4repair_space>avg(o2.amount)<seq2seq4repair_space>from<seq2seq4repair_space>Customer<seq2seq4repair_space>c,<seq2seq4repair_space>in(c.orders)<seq2seq4repair_space>o2)" + "<seq2seq4repair_space>and<seq2seq4repair_space>(select<seq2seq4repair_space>min(o2.amount)<seq2seq4repair_space>from<seq2seq4repair_space>Customer<seq2seq4repair_space>c,<seq2seq4repair_space>in(c.orders)<seq2seq4repair_space>o2)" ) , "select<seq2seq4repair_space>o.oid<seq2seq4repair_space>from<seq2seq4repair_space>Customer<seq2seq4repair_space>c,<seq2seq4repair_space>in(c.orders)o<seq2seq4repair_space>where<seq2seq4repair_space>o.amount<seq2seq4repair_space>>" + "<seq2seq4repair_space>(select<seq2seq4repair_space>sum(o2.amount)<seq2seq4repair_space>from<seq2seq4repair_space>c.orders<seq2seq4repair_space>o2)" , "select<seq2seq4repair_space>o1.oid,<seq2seq4repair_space>c.name<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o1,<seq2seq4repair_space>Customer<seq2seq4repair_space>c<seq2seq4repair_space>where<seq2seq4repair_space>o1.amount<seq2seq4repair_space>=<seq2seq4repair_space>" + "<seq2seq4repair_space>any(select<seq2seq4repair_space>o2.amount<seq2seq4repair_space>from<seq2seq4repair_space>in(c.orders)<seq2seq4repair_space>o2)" , "SELECT<seq2seq4repair_space>p,<seq2seq4repair_space>m<seq2seq4repair_space>" + ( ( ( ( ( ( ( ( "FROM<seq2seq4repair_space>Publisher<seq2seq4repair_space>p<seq2seq4repair_space>" + "LEFT<seq2seq4repair_space>OUTER<seq2seq4repair_space>JOIN<seq2seq4repair_space>p.magazineCollection<seq2seq4repair_space>m<seq2seq4repair_space>" ) + "WHERE<seq2seq4repair_space>m.id<seq2seq4repair_space>=<seq2seq4repair_space>(SELECT<seq2seq4repair_space>MAX(m2.id)<seq2seq4repair_space>" ) + "FROM<seq2seq4repair_space>Magazine<seq2seq4repair_space>m2<seq2seq4repair_space>" ) + "WHERE<seq2seq4repair_space>m2.idPublisher.id<seq2seq4repair_space>=<seq2seq4repair_space>p.id<seq2seq4repair_space>" ) + "AND<seq2seq4repair_space>m2.datePublished<seq2seq4repair_space>=<seq2seq4repair_space>" ) + "(SELECT<seq2seq4repair_space>MAX(m3.datePublished)<seq2seq4repair_space>" ) + "FROM<seq2seq4repair_space>Magazine<seq2seq4repair_space>m3<seq2seq4repair_space>" ) + "WHERE<seq2seq4repair_space>m3.idPublisher.id<seq2seq4repair_space>=<seq2seq4repair_space>p.id))<seq2seq4repair_space>" ) } ; static String [ ] querys_jpa20 = new String [ ] { "select<seq2seq4repair_space>o.oid<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o<seq2seq4repair_space>where<seq2seq4repair_space>o.delivered<seq2seq4repair_space>=" + ( ( ( ( ( ( "<seq2seq4repair_space>(select<seq2seq4repair_space>" + "<seq2seq4repair_space>CASE<seq2seq4repair_space>WHEN<seq2seq4repair_space>o2.amount<seq2seq4repair_space>><seq2seq4repair_space>10<seq2seq4repair_space>THEN<seq2seq4repair_space>true" ) + "<seq2seq4repair_space>WHEN<seq2seq4repair_space>o2.amount<seq2seq4repair_space>=<seq2seq4repair_space>10<seq2seq4repair_space>THEN<seq2seq4repair_space>false<seq2seq4repair_space>" ) + "<seq2seq4repair_space>ELSE<seq2seq4repair_space>false<seq2seq4repair_space>" ) + "<seq2seq4repair_space>END<seq2seq4repair_space>" ) + "<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o2" ) + "<seq2seq4repair_space>where<seq2seq4repair_space>o.customer.cid.id<seq2seq4repair_space>=<seq2seq4repair_space>o2.customer.cid.id)" ) , "select<seq2seq4repair_space>o1.oid<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o1<seq2seq4repair_space>where<seq2seq4repair_space>o1.amount<seq2seq4repair_space>><seq2seq4repair_space>" + ( "<seq2seq4repair_space>(select<seq2seq4repair_space>o.amount*0.8<seq2seq4repair_space>from<seq2seq4repair_space>OrderItem<seq2seq4repair_space>i,<seq2seq4repair_space>Order<seq2seq4repair_space>o" + "<seq2seq4repair_space>where<seq2seq4repair_space>i.quantity<seq2seq4repair_space>><seq2seq4repair_space>10<seq2seq4repair_space>and<seq2seq4repair_space>o.amount<seq2seq4repair_space>><seq2seq4repair_space>1000<seq2seq4repair_space>and<seq2seq4repair_space>i.lid<seq2seq4repair_space>=<seq2seq4repair_space>o.oid)" ) , "select<seq2seq4repair_space>o.oid<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o<seq2seq4repair_space>where<seq2seq4repair_space>o.customer.name<seq2seq4repair_space>=" + ( "<seq2seq4repair_space>(select<seq2seq4repair_space>substring(o2.customer.name,<seq2seq4repair_space>3)<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o2" + "<seq2seq4repair_space>where<seq2seq4repair_space>o.customer.cid.id<seq2seq4repair_space>=<seq2seq4repair_space>o2.customer.cid.id)" ) , "select<seq2seq4repair_space>o.oid<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o<seq2seq4repair_space>where<seq2seq4repair_space>o.orderTs<seq2seq4repair_space>>" + "<seq2seq4repair_space>(select<seq2seq4repair_space>CURRENT_TIMESTAMP<seq2seq4repair_space>from<seq2seq4repair_space>o.lineitems<seq2seq4repair_space>i)" , "select<seq2seq4repair_space>o.oid<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o<seq2seq4repair_space>where<seq2seq4repair_space>o.amount<seq2seq4repair_space>>" + "<seq2seq4repair_space>(select<seq2seq4repair_space>SQRT(o.amount)<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o<seq2seq4repair_space>where<seq2seq4repair_space>o.delivered<seq2seq4repair_space>=<seq2seq4repair_space>true)" , "select<seq2seq4repair_space>o.oid<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o<seq2seq4repair_space>where<seq2seq4repair_space>o.customer.name<seq2seq4repair_space>in" + ( "<seq2seq4repair_space>(select<seq2seq4repair_space>CONCAT(o.customer.name,<seq2seq4repair_space>'XX')<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o" + "<seq2seq4repair_space>where<seq2seq4repair_space>o.amount<seq2seq4repair_space>><seq2seq4repair_space>10)" ) , "select<seq2seq4repair_space>c<seq2seq4repair_space>from<seq2seq4repair_space>Customer<seq2seq4repair_space>c<seq2seq4repair_space>where<seq2seq4repair_space>c.creditRating<seq2seq4repair_space>=" + ( ( ( ( ( ( ( ( ( "<seq2seq4repair_space>(select<seq2seq4repair_space>" + "<seq2seq4repair_space>CASE<seq2seq4repair_space>WHEN<seq2seq4repair_space>o2.amount<seq2seq4repair_space>><seq2seq4repair_space>10<seq2seq4repair_space>THEN<seq2seq4repair_space>" ) + "org.apache.openjpa.persistence.query.Customer$CreditRating.POOR" ) + "<seq2seq4repair_space>WHEN<seq2seq4repair_space>o2.amount<seq2seq4repair_space>=<seq2seq4repair_space>10<seq2seq4repair_space>THEN<seq2seq4repair_space>" ) + "org.apache.openjpa.persistence.query.Customer$CreditRating.GOOD<seq2seq4repair_space>" ) + "<seq2seq4repair_space>ELSE<seq2seq4repair_space>" ) + "org.apache.openjpa.persistence.query.Customer$CreditRating.EXCELLENT<seq2seq4repair_space>" ) + "<seq2seq4repair_space>END<seq2seq4repair_space>" ) + "<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o2" ) + "<seq2seq4repair_space>where<seq2seq4repair_space>c.cid.id<seq2seq4repair_space>=<seq2seq4repair_space>o2.customer.cid.id)" ) , "select<seq2seq4repair_space>c<seq2seq4repair_space>from<seq2seq4repair_space>Customer<seq2seq4repair_space>c<seq2seq4repair_space>" + ( ( "where<seq2seq4repair_space>c.creditRating<seq2seq4repair_space>=<seq2seq4repair_space>(select<seq2seq4repair_space>COALESCE<seq2seq4repair_space>(c1.creditRating,<seq2seq4repair_space>" + "org.apache.openjpa.persistence.query.Customer$CreditRating.POOR)<seq2seq4repair_space>" ) + "from<seq2seq4repair_space>Customer<seq2seq4repair_space>c1<seq2seq4repair_space>where<seq2seq4repair_space>c1.name<seq2seq4repair_space>=<seq2seq4repair_space>'Famzy')<seq2seq4repair_space>order<seq2seq4repair_space>by<seq2seq4repair_space>c.name<seq2seq4repair_space>DESC" ) , "select<seq2seq4repair_space>c<seq2seq4repair_space>from<seq2seq4repair_space>Customer<seq2seq4repair_space>c<seq2seq4repair_space>" + ( ( "where<seq2seq4repair_space>c.creditRating<seq2seq4repair_space>=<seq2seq4repair_space>(select<seq2seq4repair_space>NULLIF<seq2seq4repair_space>(c1.creditRating,<seq2seq4repair_space>" + "org.apache.openjpa.persistence.query.Customer$CreditRating.POOR)<seq2seq4repair_space>" ) + "from<seq2seq4repair_space>Customer<seq2seq4repair_space>c1<seq2seq4repair_space>where<seq2seq4repair_space>c1.name<seq2seq4repair_space>=<seq2seq4repair_space>'Famzy')<seq2seq4repair_space>order<seq2seq4repair_space>by<seq2seq4repair_space>c.name<seq2seq4repair_space>DESC" ) } ; static String [ ] updates = new String [ ] { "update<seq2seq4repair_space>Order<seq2seq4repair_space>o<seq2seq4repair_space>set<seq2seq4repair_space>o.amount<seq2seq4repair_space>=<seq2seq4repair_space>1000<seq2seq4repair_space>where<seq2seq4repair_space>o.customer.name<seq2seq4repair_space>=<seq2seq4repair_space>" + ( "<seq2seq4repair_space>(select<seq2seq4repair_space>max(o2.customer.name)<seq2seq4repair_space>from<seq2seq4repair_space>Order<seq2seq4repair_space>o2<seq2seq4repair_space>" + "<seq2seq4repair_space>where<seq2seq4repair_space>o.customer.cid.id<seq2seq4repair_space>=<seq2seq4repair_space>o2.customer.cid.id)" ) } ; public void testSubquery ( ) { } public void testSubSelectMaxDateRange ( ) { } }

Fix:
setUp ( Customer . class , CustomerKey . class , Order . class , OrderItem . class , Magazine . class , Publisher . class , Employee . class , Dependent . class , DependentId . class , DROP_TABLES ) ;