mirror of https://github.com/apache/openjpa.git
OPENJPA-956 JPA2 Query support ElementCollection in FROM clause
add query test strings git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@758906 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7e6ca9043e
commit
c7fabe7ff7
|
@ -956,6 +956,20 @@ public class TestEmbeddable extends SingleEMFTestCase {
|
||||||
*/
|
*/
|
||||||
public void queryEntityA_Coll_String() {
|
public void queryEntityA_Coll_String() {
|
||||||
EntityManager em = emf.createEntityManager();
|
EntityManager em = emf.createEntityManager();
|
||||||
|
String[] query = {
|
||||||
|
"select e from " +
|
||||||
|
" EntityA_Coll_String a " +
|
||||||
|
" , in (a.nickNames) e order by a.id",
|
||||||
|
};
|
||||||
|
List rs = null;
|
||||||
|
for (int i = 0; i < query.length; i++) {
|
||||||
|
rs = em.createQuery(query[i]).getResultList();
|
||||||
|
if (rs.size() > 0) {
|
||||||
|
Object obj = rs.get(0);
|
||||||
|
assertTrue(obj instanceof String);
|
||||||
|
}
|
||||||
|
em.clear();
|
||||||
|
}
|
||||||
EntityTransaction tran = em.getTransaction();
|
EntityTransaction tran = em.getTransaction();
|
||||||
tran.begin();
|
tran.begin();
|
||||||
Query q = em.createQuery("select a from EntityA_Coll_String a");
|
Query q = em.createQuery("select a from EntityA_Coll_String a");
|
||||||
|
@ -988,6 +1002,33 @@ public class TestEmbeddable extends SingleEMFTestCase {
|
||||||
*/
|
*/
|
||||||
public void queryEntityA_Coll_Embed_ToOne() {
|
public void queryEntityA_Coll_Embed_ToOne() {
|
||||||
EntityManager em = emf.createEntityManager();
|
EntityManager em = emf.createEntityManager();
|
||||||
|
// test select embed object from element collection
|
||||||
|
String[] query = {
|
||||||
|
"select e, e.b from " +
|
||||||
|
" EntityA_Coll_Embed_ToOne a " +
|
||||||
|
" , in (a.embed1s) e order by e.name1",
|
||||||
|
"select e, a.id from EntityA_Coll_Embed_ToOne a " +
|
||||||
|
" , in (a.embed1s) e where e.b.id > 0 order by a.id",
|
||||||
|
"select e, e.b.id from " +
|
||||||
|
" EntityA_Coll_Embed_ToOne a " +
|
||||||
|
" , in (a.embed1s) e where e.name1 like '%1'" +
|
||||||
|
" order by e.name3",
|
||||||
|
};
|
||||||
|
List<Object[]> rs = null;
|
||||||
|
for (int i = 0; i < query.length; i++) {
|
||||||
|
rs = em.createQuery(query[i]).getResultList();
|
||||||
|
if (rs.size() > 0) {
|
||||||
|
Object obj = ((Object[]) rs.get(0))[0];
|
||||||
|
assertTrue(obj instanceof Embed_ToOne);
|
||||||
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
Object b = ((Object[]) rs.get(0))[1];
|
||||||
|
assertTrue(b instanceof EntityB1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
em.clear();
|
||||||
|
}
|
||||||
EntityTransaction tran = em.getTransaction();
|
EntityTransaction tran = em.getTransaction();
|
||||||
tran.begin();
|
tran.begin();
|
||||||
Query q = em.createQuery("select a from EntityA_Coll_Embed_ToOne a");
|
Query q = em.createQuery("select a from EntityA_Coll_Embed_ToOne a");
|
||||||
|
@ -1068,6 +1109,24 @@ public class TestEmbeddable extends SingleEMFTestCase {
|
||||||
*/
|
*/
|
||||||
public void queryEntityA_Coll_Embed_Embed() {
|
public void queryEntityA_Coll_Embed_Embed() {
|
||||||
EntityManager em = emf.createEntityManager();
|
EntityManager em = emf.createEntityManager();
|
||||||
|
// test select embed object from element collection
|
||||||
|
String[] query = {
|
||||||
|
"select e, e.intVal1, e.embed.intVal2 from " +
|
||||||
|
" EntityA_Coll_Embed_Embed a " +
|
||||||
|
" , in (a.embeds) e order by e.intVal3",
|
||||||
|
"select e, a.id from EntityA_Coll_Embed_Embed a " +
|
||||||
|
" , in (a.embeds) e order by a.id",
|
||||||
|
};
|
||||||
|
List rs = null;
|
||||||
|
for (int i = 0; i < query.length; i++) {
|
||||||
|
rs = em.createQuery(query[i]).getResultList();
|
||||||
|
if (rs != null && rs.size() > 0) {
|
||||||
|
Object obj = ((Object[]) rs.get(0))[0];
|
||||||
|
assertTrue(obj instanceof Embed_Embed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
em.clear();
|
||||||
|
|
||||||
EntityTransaction tran = em.getTransaction();
|
EntityTransaction tran = em.getTransaction();
|
||||||
tran.begin();
|
tran.begin();
|
||||||
Query q = em.createQuery("select a from EntityA_Coll_Embed_Embed a");
|
Query q = em.createQuery("select a from EntityA_Coll_Embed_Embed a");
|
||||||
|
@ -1084,27 +1143,6 @@ public class TestEmbeddable extends SingleEMFTestCase {
|
||||||
*/
|
*/
|
||||||
public void queryEntityA_Embed_Coll_Embed() {
|
public void queryEntityA_Embed_Coll_Embed() {
|
||||||
EntityManager em = emf.createEntityManager();
|
EntityManager em = emf.createEntityManager();
|
||||||
// test select embed object from element collection
|
|
||||||
String[] query = {
|
|
||||||
"select e, e.intVal1, e.embed.intVal2 from " +
|
|
||||||
" EntityA_Coll_Embed_Embed a " +
|
|
||||||
" , in (a.embeds) e order by e.intVal3",
|
|
||||||
"select e, a.id from EntityA_Coll_Embed_Embed a " +
|
|
||||||
" , in (a.embeds) e order by a.id",
|
|
||||||
"select e, e.intVal1, e.embed.intVal2 from " +
|
|
||||||
" EntityA_Coll_Embed_Embed a " +
|
|
||||||
" , in (a.embeds) e order by e.intVal3",
|
|
||||||
};
|
|
||||||
List<Object[]> rs = null;
|
|
||||||
for (int i = 0; i < query.length; i++) {
|
|
||||||
rs = em.createQuery(query[i]).getResultList();
|
|
||||||
if (rs.size() > 0) {
|
|
||||||
Object obj = ((Object[]) rs.get(0))[0];
|
|
||||||
assertTrue(obj instanceof Embed_Embed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
em.clear();
|
|
||||||
EntityTransaction tran = em.getTransaction();
|
EntityTransaction tran = em.getTransaction();
|
||||||
tran.begin();
|
tran.begin();
|
||||||
Query q = em.createQuery("select a from EntityA_Embed_Coll_Embed a");
|
Query q = em.createQuery("select a from EntityA_Embed_Coll_Embed a");
|
||||||
|
|
Loading…
Reference in New Issue