|
Lines 56-61
Link Here
|
| 56 |
|
56 |
|
| 57 |
import org.eclipse.persistence.testing.models.jpa.advanced.LargeProject; |
57 |
import org.eclipse.persistence.testing.models.jpa.advanced.LargeProject; |
| 58 |
import org.eclipse.persistence.testing.models.jpa.advanced.Project; |
58 |
import org.eclipse.persistence.testing.models.jpa.advanced.Project; |
|
|
59 |
import org.eclipse.persistence.testing.framework.QuerySQLTracker; |
| 59 |
import org.eclipse.persistence.testing.framework.junit.JUnitTestCase; |
60 |
import org.eclipse.persistence.testing.framework.junit.JUnitTestCase; |
| 60 |
|
61 |
|
| 61 |
import org.eclipse.persistence.sessions.DatabaseSession; |
62 |
import org.eclipse.persistence.sessions.DatabaseSession; |
|
Lines 225-230
Link Here
|
| 225 |
suite.addTest(new JUnitJPQLComplexTestSuite("testComplexLike")); |
226 |
suite.addTest(new JUnitJPQLComplexTestSuite("testComplexLike")); |
| 226 |
suite.addTest(new JUnitJPQLComplexTestSuite("testComplexIn")); |
227 |
suite.addTest(new JUnitJPQLComplexTestSuite("testComplexIn")); |
| 227 |
suite.addTest(new JUnitJPQLComplexTestSuite("testQueryKeys")); |
228 |
suite.addTest(new JUnitJPQLComplexTestSuite("testQueryKeys")); |
|
|
229 |
suite.addTest(new JUnitJPQLComplexTestSuite("complexOneToOneJoinOptimization")); |
| 228 |
|
230 |
|
| 229 |
return suite; |
231 |
return suite; |
| 230 |
} |
232 |
} |
|
Lines 3042-3054
Link Here
|
| 3042 |
EntityManager em = createEntityManager(); |
3044 |
EntityManager em = createEntityManager(); |
| 3043 |
String errorMsg = ""; |
3045 |
String errorMsg = ""; |
| 3044 |
Query query; |
3046 |
Query query; |
| 3045 |
for(int i=0; i < jpqlStrings.length; i++) { |
3047 |
for (int i = 0; i < jpqlStrings.length; i++) { |
| 3046 |
try{ |
3048 |
try { |
| 3047 |
query = em.createQuery(jpqlStrings[i]); |
3049 |
query = em.createQuery(jpqlStrings[i]); |
| 3048 |
List result = query.getResultList(); |
3050 |
query.getResultList(); |
| 3049 |
}catch(Exception ex){ |
3051 |
} catch (Exception ex) { |
| 3050 |
ex.printStackTrace(); |
3052 |
ex.printStackTrace(); |
| 3051 |
errorMsg += '\t' + jpqlStrings[i] + " - "+ex+'\n'; |
3053 |
errorMsg += '\t' + jpqlStrings[i] + " - " + ex + '\n'; |
| 3052 |
} |
3054 |
} |
| 3053 |
} |
3055 |
} |
| 3054 |
closeEntityManager(em); |
3056 |
closeEntityManager(em); |
|
Lines 3061-3084
Link Here
|
| 3061 |
|
3063 |
|
| 3062 |
/* Test nested functions with FUNC*/ |
3064 |
/* Test nested functions with FUNC*/ |
| 3063 |
public void testNestedFUNCs() { |
3065 |
public void testNestedFUNCs() { |
| 3064 |
if(!getServerSession().getPlatform().isOracle()) { |
3066 |
if (!getServerSession().getPlatform().isOracle()) { |
| 3065 |
warning("The test testNestedFUNCs is supported on Oracle only"); |
3067 |
warning("The test testNestedFUNCs is supported on Oracle only"); |
| 3066 |
return; |
3068 |
return; |
| 3067 |
}else{ |
3069 |
} else { |
| 3068 |
String jpqlString = "select FUNC('NVL',FUNC('TO_NUMBER', FUNC('DECODE', FUNC('SUBSTRB', e.firstName,1,1),' ', NULL,FUNC('SUBSTRB',e.lastName,1,10)), null), -99) from Employee e"; |
3070 |
String jpqlString = "select FUNC('NVL',FUNC('TO_NUMBER', FUNC('DECODE', FUNC('SUBSTRB', e.firstName,1,1),' ', NULL,FUNC('SUBSTRB',e.lastName,1,10)), null), -99) from Employee e"; |
| 3069 |
EntityManager em = createEntityManager(); |
3071 |
EntityManager em = createEntityManager(); |
| 3070 |
Query query; |
3072 |
Query query; |
| 3071 |
try{ |
3073 |
try { |
| 3072 |
query = em.createQuery(jpqlString); |
3074 |
query = em.createQuery(jpqlString); |
| 3073 |
List result = query.getResultList(); |
3075 |
query.getResultList(); |
| 3074 |
}catch(Exception ex){ |
3076 |
} catch (Exception ex) { |
| 3075 |
ex.printStackTrace(); |
3077 |
ex.printStackTrace(); |
| 3076 |
fail("nested fucntions don't work, the error is" + ex.getMessage()); |
3078 |
fail("nested fucntions don't work, the error is" + ex.getMessage()); |
| 3077 |
}finally{ |
3079 |
} finally { |
| 3078 |
closeEntityManager(em); |
3080 |
closeEntityManager(em); |
| 3079 |
} |
3081 |
} |
| 3080 |
} |
3082 |
} |
| 3081 |
} |
3083 |
} |
|
|
3084 |
|
| 3082 |
public void testFunctionInSelect() { |
3085 |
public void testFunctionInSelect() { |
| 3083 |
EntityManager em = createEntityManager(); |
3086 |
EntityManager em = createEntityManager(); |
| 3084 |
Query query = em.createQuery("Select UPPER(e.firstName) from Employee e"); |
3087 |
Query query = em.createQuery("Select UPPER(e.firstName) from Employee e"); |
|
Lines 3205-3208
Link Here
|
| 3205 |
query.getResultList(); |
3208 |
query.getResultList(); |
| 3206 |
closeEntityManager(em); |
3209 |
closeEntityManager(em); |
| 3207 |
} |
3210 |
} |
|
|
3211 |
|
| 3212 |
/** |
| 3213 |
* Test that id comparisons across relationships avoid the join. |
| 3214 |
*/ |
| 3215 |
public void complexOneToOneJoinOptimization() |
| 3216 |
{ |
| 3217 |
// Count SQL. |
| 3218 |
QuerySQLTracker counter = new QuerySQLTracker(getServerSession()); |
| 3219 |
try { |
| 3220 |
EntityManager em = createEntityManager(); |
| 3221 |
String jpql = "SELECT e FROM Employee e where e.address.ID = 5"; |
| 3222 |
Query query = em.createQuery(jpql); |
| 3223 |
query.getResultList(); |
| 3224 |
String sql = (String)counter.getSqlStatements().get(0); |
| 3225 |
if (sql.indexOf("CMP3_ADDRESS") != -1) { |
| 3226 |
fail("Join to address should have been optimized."); |
| 3227 |
} |
| 3228 |
} finally { |
| 3229 |
if (counter != null) { |
| 3230 |
counter.remove(); |
| 3231 |
} |
| 3232 |
} |
| 3233 |
} |
| 3208 |
} |
3234 |
} |