mirror of https://github.com/apache/openjpa.git
OPENJPA-1425: Lieralize value if they appear in selection clause for databases that do not support parameters in selection terms.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@889490 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
77c3242465
commit
b1ee063aa4
|
@ -228,6 +228,9 @@ public class SelectConstructor
|
|||
Val resultVal;
|
||||
for (int i = 0; i < exps.projections.length; i++) {
|
||||
resultVal = (Val) exps.projections[i];
|
||||
if (!ctx.store.getDBDictionary().supportsParameterInSelect && resultVal instanceof Lit) {
|
||||
((Lit)resultVal).setRaw(true);
|
||||
}
|
||||
// have to join through to related type for pc object
|
||||
// projections; this ensures that we have all our joins cached
|
||||
state.projections[i] = resultVal.initialize(sel, ctx,
|
||||
|
|
|
@ -181,6 +181,7 @@ public class DBDictionary
|
|||
public int maxIndexNameLength = 128;
|
||||
public int maxIndexesPerTable = Integer.MAX_VALUE;
|
||||
public boolean supportsForeignKeys = true;
|
||||
public boolean supportsParameterInSelect = true;
|
||||
public boolean supportsForeignKeysComposite = true;
|
||||
public boolean supportsUniqueConstraints = true;
|
||||
public boolean supportsDeferredConstraints = true;
|
||||
|
|
|
@ -25,12 +25,14 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Parameter;
|
||||
import javax.persistence.Query;
|
||||
import javax.persistence.Tuple;
|
||||
import javax.persistence.TypedQuery;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Expression;
|
||||
import javax.persistence.criteria.Fetch;
|
||||
import javax.persistence.criteria.Join;
|
||||
import javax.persistence.criteria.JoinType;
|
||||
import javax.persistence.criteria.ListJoin;
|
||||
|
@ -1477,4 +1479,28 @@ public class TestTypesafeCriteria extends CriteriaTest {
|
|||
assertTrue(result.getClass() + " not instance of Time", result instanceof Time);
|
||||
|
||||
}
|
||||
|
||||
// public void testInMemoryAccessPath() {
|
||||
// em.getTransaction().begin();
|
||||
// // must have new/dirty managed instances to exercise the code path
|
||||
// em.persist(new Customer());
|
||||
// CriteriaQuery<Customer> cquery = cb.createQuery(Customer.class);
|
||||
// Root<Customer> customer = cquery.from(Customer.class);
|
||||
// Fetch<Customer, Account> c = customer.fetch("accounts", JoinType.LEFT);
|
||||
// cquery.where(cb.like(customer.<String>get("firstName"), "a%")).select(customer).distinct(true);
|
||||
// TypedQuery<Customer> tquery = em.createQuery(cquery);
|
||||
// tquery.setMaxResults(3);
|
||||
// List<Customer> result = tquery.getResultList();
|
||||
//
|
||||
// }
|
||||
|
||||
public void testLiteralInProjection() {
|
||||
String jpql = "select 'a' from Customer c where c.id=10";
|
||||
|
||||
CriteriaQuery<String> cq = cb.createQuery(String.class);
|
||||
Root<Customer> c = cq.from(Customer.class);
|
||||
cq.select(cb.toString(cb.literal('a')));
|
||||
cq.where(cb.equal(c.get(Customer_.id), 10));
|
||||
assertEquivalence(cq, jpql);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue