View | Details | Raw Unified | Return to bug 215079
Collapse All | Expand All

(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/framework/TestCase.java (-1 / +1 lines)
Lines 653-659 Link Here
653
     */
653
     */
654
    public void checkNoWaitSupported() {
654
    public void checkNoWaitSupported() {
655
        DatabasePlatform platform = getSession().getPlatform();
655
        DatabasePlatform platform = getSession().getPlatform();
656
        if (platform.isDB2() || platform.isAccess() || platform.isSybase() || platform.isSQLAnywhere() || platform.isDerby() || platform.isMySQL() || platform.isTimesTen()) {
656
        if (platform.isH2() || platform.isDB2() || platform.isAccess() || platform.isSybase() || platform.isSQLAnywhere() || platform.isDerby() || platform.isMySQL() || platform.isTimesTen()) {
657
            throw new TestWarningException("This database does not support NOWAIT");        
657
            throw new TestWarningException("This database does not support NOWAIT");        
658
        }
658
        }
659
    }
659
    }
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/framework/TestSystem.java (+13 lines)
Lines 221-226 Link Here
221
    }
221
    }
222
222
223
    /**
223
    /**
224
     * You must have the H2 driver loaded.
225
     */
226
    public void useH2() {
227
        DatabaseLogin login = new DatabaseLogin(new org.eclipse.persistence.platform.database.H2Platform());
228
        login.setDriverClassName("org.h2.Driver");
229
        login.setDriverURLHeader("jdbc:h2:");
230
        login.setDatabaseURL("test");
231
        login.setUserName("sa");
232
        login.setPassword("");
233
        setLogin(login);
234
    }
235
236
    /**
224
     * You must have the Postgres driver loaded.
237
     * You must have the Postgres driver loaded.
225
     */
238
     */
226
    public void usePostgres() {
239
    public void usePostgres() {
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/framework/ui/TestingBrowserPanel.java (+3 lines)
Lines 1005-1010 Link Here
1005
            system.useDB2DataDirect();
1005
            system.useDB2DataDirect();
1006
        } else if (platform.equals("Derby")) {
1006
        } else if (platform.equals("Derby")) {
1007
            system.useDerby();
1007
            system.useDerby();
1008
        } else if (platform.equals("H2")) {
1009
            system.useH2();
1008
        } else if (platform.equals("PostgreSQL")) {
1010
        } else if (platform.equals("PostgreSQL")) {
1009
            system.usePostgres();
1011
            system.usePostgres();
1010
        } else if (platform.equals("Informix IDS 11.1")) {
1012
        } else if (platform.equals("Informix IDS 11.1")) {
Lines 1152-1157 Link Here
1152
        getLoginChoice().addItem("DB2 (Universal Driver)");
1154
        getLoginChoice().addItem("DB2 (Universal Driver)");
1153
        getLoginChoice().addItem("DB2 (DataDirect)");
1155
        getLoginChoice().addItem("DB2 (DataDirect)");
1154
        getLoginChoice().addItem("Derby");
1156
        getLoginChoice().addItem("Derby");
1157
        getLoginChoice().addItem("H2");
1155
        getLoginChoice().addItem("PostgreSQL");
1158
        getLoginChoice().addItem("PostgreSQL");
1156
        getLoginChoice().addItem("Informix IDS 11.1");        
1159
        getLoginChoice().addItem("Informix IDS 11.1");        
1157
        getLoginChoice().addItem("Sybase (JConnect)");
1160
        getLoginChoice().addItem("Sybase (JConnect)");
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/expressions/ExpressionUnitTestSuite.java (-20 / +4 lines)
Lines 802-814 Link Here
802
        test.setExpression(expression);
802
        test.setExpression(expression);
803
        test.setName("MonthsBetweenTest");
803
        test.setName("MonthsBetweenTest");
804
        test.setDescription("Test monthsBetween expression");
804
        test.setDescription("Test monthsBetween expression");
805
        test.addUnsupportedPlatform(DB2Platform.class);
805
        test.addSupportedPlatform(OraclePlatform.class);
806
        test.addUnsupportedPlatform(SybasePlatform.class);
807
        test.addUnsupportedPlatform(SQLAnywherePlatform.class);
808
        test.addUnsupportedPlatform(SQLServerPlatform.class);
809
        test.addUnsupportedPlatform(MySQLPlatform.class);
810
        test.addUnsupportedPlatform(TimesTenPlatform.class);
811
        test.addUnsupportedPlatform(PostgreSQLPlatform.class);
812
        addTest(test);
806
        addTest(test);
813
    }
807
    }
814
808
Lines 820-832 Link Here
820
        test.setExpression(expression);
814
        test.setExpression(expression);
821
        test.setName("NextDayTest");
815
        test.setName("NextDayTest");
822
        test.setDescription("Test nextDay expression");
816
        test.setDescription("Test nextDay expression");
823
        test.addUnsupportedPlatform(DB2Platform.class);
817
        test.addSupportedPlatform(OraclePlatform.class);
824
        test.addUnsupportedPlatform(SybasePlatform.class);
825
        test.addUnsupportedPlatform(SQLAnywherePlatform.class);
826
        test.addUnsupportedPlatform(SQLServerPlatform.class);
827
        test.addUnsupportedPlatform(MySQLPlatform.class);
828
        test.addUnsupportedPlatform(TimesTenPlatform.class);
829
        test.addUnsupportedPlatform(PostgreSQLPlatform.class);
830
        addTest(test);
818
        addTest(test);
831
    }
819
    }
832
820
Lines 1265-1276 Link Here
1265
        test.setExpression(expression);
1253
        test.setExpression(expression);
1266
        test.setName("ToUpperCasedWordsTest");
1254
        test.setName("ToUpperCasedWordsTest");
1267
        test.setDescription("Test toUpperCasedWords expression");
1255
        test.setDescription("Test toUpperCasedWords expression");
1268
        test.addUnsupportedPlatform(DB2Platform.class);
1256
        test.addSupportedPlatform(OraclePlatform.class);
1269
        test.addUnsupportedPlatform(SybasePlatform.class);
1257
        test.addSupportedPlatform(PostgreSQLPlatform.class);
1270
        test.addUnsupportedPlatform(SQLAnywherePlatform.class);
1271
        test.addUnsupportedPlatform(SQLServerPlatform.class);
1272
        test.addUnsupportedPlatform(MySQLPlatform.class);
1273
        test.addUnsupportedPlatform(TimesTenPlatform.class);
1274
        addTest(test);
1258
        addTest(test);
1275
    }
1259
    }
1276
1260
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/interfaces/VariableOneToOneNonPrivatelyOwnedTest.java (-1 / +9 lines)
Lines 12-17 Link Here
12
 ******************************************************************************/  
12
 ******************************************************************************/  
13
package org.eclipse.persistence.testing.tests.interfaces;
13
package org.eclipse.persistence.testing.tests.interfaces;
14
14
15
import java.util.List;
16
15
import org.eclipse.persistence.testing.framework.*;
17
import org.eclipse.persistence.testing.framework.*;
16
import org.eclipse.persistence.testing.models.interfaces.*;
18
import org.eclipse.persistence.testing.models.interfaces.*;
17
19
Lines 25-31 Link Here
25
    public ContactHolder origional;
27
    public ContactHolder origional;
26
28
27
    public void test() {
29
    public void test() {
28
        this.contact = (Contact)getSession().readObject(Phone.class);
30
        List<Phone> phones = getSession().readAllObjects(Phone.class);
31
        for (Phone phone : phones) {
32
            if (phone.getEmp() != null) {
33
                this.contact = phone;
34
                break;
35
            }
36
        }
29
        this.origional = (ContactHolder)this.contact.getEmp().clone();
37
        this.origional = (ContactHolder)this.contact.getEmp().clone();
30
        ContactHolder holder = this.contact.getEmp();
38
        ContactHolder holder = this.contact.getEmp();
31
        if (holder instanceof Employee) {
39
        if (holder instanceof Employee) {
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/orderedlist/OrderListTestModel.java (-2 / +12 lines)
Lines 101-108 Link Here
101
    public OrderListTestModel() {
101
    public OrderListTestModel() {
102
        setDescription("This model tests ordered list.");
102
        setDescription("This model tests ordered list.");
103
        isTopLevel = true;
103
        isTopLevel = true;
104
        
105
        addModels();
106
    }
104
    }
107
105
108
    /*
106
    /*
Lines 143-148 Link Here
143
     * Cuts the models with invalid configurations, configurations that don't make any difference.
141
     * Cuts the models with invalid configurations, configurations that don't make any difference.
144
     */
142
     */
145
    boolean shouldAddModel() {
143
    boolean shouldAddModel() {
144
        // H2 has an issue with large outer joins, causes null-pointer in driver.
145
        if (getSession().getPlatform().isH2() && useSecondaryTable && (joinFetchOrBatchRead == JoinFetchOrBatchRead.OUTER_JOIN)) {
146
            return false;
147
        }
148
        // VARCHAR order causes errors on H2, but I can't see how it could really work on anything,
149
        // as "1" + 1 = "11" not 2.
150
        if (getSession().getPlatform().isH2() && useVarcharOrder) {
151
            return false;
152
        }
153
            
146
        // listOrderField is not used 
154
        // listOrderField is not used 
147
        if(!useListOrderField) {
155
        if(!useListOrderField) {
148
            // explicitly asked not to run the model that don't use listOrderField.
156
            // explicitly asked not to run the model that don't use listOrderField.
Lines 308-313 Link Here
308
            }
316
            }
309
            
317
            
310
            addTest(new CreateManagersTest());
318
            addTest(new CreateManagersTest());
319
        } else {
320
            addModels();
311
        }
321
        }
312
    }
322
    }
313
    
323
    
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/performance/emulateddb/EmulatedStatement.java (+2 lines)
Lines 61-66 Link Here
61
                }
61
                }
62
                rows.add(row);
62
                rows.add(row);
63
            }
63
            }
64
            result.close();
65
            statement.close();
64
        }
66
        }
65
        this.connection.putRows(this.sql, rows);
67
        this.connection.putRows(this.sql, rows);
66
        return rows;
68
        return rows;
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/queries/inmemory/UnitOfWorkConformWithOrderTest.java (-4 / +5 lines)
Lines 30-47 Link Here
30
30
31
    public void test() {
31
    public void test() {
32
        // Make a query an search Number greaterThan "00005"
32
        // Make a query an search Number greaterThan "00005"
33
        ExpressionBuilder emp = new ExpressionBuilder();
33
        ExpressionBuilder phone = new ExpressionBuilder();
34
        Expression exp = emp.get("areaCode").equal(613);
34
        Expression exp = phone.get("areaCode").equal(613);
35
        ReadAllQuery query = new ReadAllQuery(PhoneNumber.class);
35
        ReadAllQuery query = new ReadAllQuery(PhoneNumber.class);
36
        query.setSelectionCriteria(exp);
36
        query.setSelectionCriteria(exp);
37
        query.conformResultsInUnitOfWork();// set Conforming
37
        query.conformResultsInUnitOfWork();// set Conforming
38
        query.addOrdering(emp.get("owner").get("lastName").descending());
38
        query.addOrdering(phone.get("owner").get("id").descending());
39
        query.addOrdering(phone.get("type").descending());
39
        UnitOfWork uow = getSession().acquireUnitOfWork();
40
        UnitOfWork uow = getSession().acquireUnitOfWork();
40
        Vector v = (Vector)uow.executeQuery(query);
41
        Vector v = (Vector)uow.executeQuery(query);
41
        Vector v2 = (Vector)uow.executeQuery(query);
42
        Vector v2 = (Vector)uow.executeQuery(query);
42
43
43
        if (!v.equals(v2)) {
44
        if (!v.equals(v2)) {
44
            throw new TestErrorException("Order not maintained when conforming");
45
            throw new TestErrorException("Order not maintained when conforming:" + v + " != " + v2);
45
        }
46
        }
46
    }
47
    }
47
}
48
}
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/queries/options/ClearQueryOptionsOnStatementTest.java (-1 / +8 lines)
Lines 102-107 Link Here
102
    }
102
    }
103
103
104
    public void testResultSetFetchSizeReset(Session session) {
104
    public void testResultSetFetchSizeReset(Session session) {
105
        // H2 sets the query fetch size on the connection, and does not clear it, so this will fail.
106
        if (getSession().getLogin().getDatasourcePlatform().isH2()) {
107
            return;            
108
        }
105
        // Resultset fetch size
109
        // Resultset fetch size
106
        ReadAllQuery query = new ReadAllQuery(QueryOptionEmployee.class);
110
        ReadAllQuery query = new ReadAllQuery(QueryOptionEmployee.class);
107
        if(TYPE_SCROLL_INSENSITIVE_isSupported && CONCUR_UPDATABLE_isSupported) {
111
        if(TYPE_SCROLL_INSENSITIVE_isSupported && CONCUR_UPDATABLE_isSupported) {
Lines 176-182 Link Here
176
    public void testQueryTimeoutReset(Session session) {
180
    public void testQueryTimeoutReset(Session session) {
177
        boolean query1TimedOut = false;
181
        boolean query1TimedOut = false;
178
        boolean query2TimedOut = false;
182
        boolean query2TimedOut = false;
179
        
183
        // H2 sets the query timeout on the connection, and does not clear it, so this will fail.
184
        if (getSession().getLogin().getDatasourcePlatform().isH2()) {
185
            return;            
186
        }
180
        String sql;
187
        String sql;
181
        if (getSession().getLogin().getDatasourcePlatform().isDB2() || getSession().getLogin().getDatasourcePlatform().isMySQL()) {
188
        if (getSession().getLogin().getDatasourcePlatform().isDB2() || getSession().getLogin().getDatasourcePlatform().isMySQL()) {
182
          sql = "SELECT SUM(e.EMP_ID) from EMPLOYEE e , EMPLOYEE b, EMPLOYEE c,EMPLOYEE d";
189
          sql = "SELECT SUM(e.EMP_ID) from EMPLOYEE e , EMPLOYEE b, EMPLOYEE c,EMPLOYEE d";
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/queries/PessimisticLockFineGrainedTest.java (-2 / +2 lines)
Lines 75-82 Link Here
75
    public void test() throws Exception {
75
    public void test() throws Exception {
76
        checkSelectForUpateSupported();
76
        checkSelectForUpateSupported();
77
77
78
        if ((getSession().getPlatform().isMySQL() || getSession().getPlatform().isTimesTen()) && lockMode == org.eclipse.persistence.queries.ObjectLevelReadQuery.LOCK_NOWAIT) {
78
        if (lockMode == org.eclipse.persistence.queries.ObjectLevelReadQuery.LOCK_NOWAIT) {
79
            throw new TestWarningException("This database does not support NOWAIT");        
79
            checkNoWaitSupported();
80
        }
80
        }
81
    
81
    
82
        uow = getSession().acquireUnitOfWork();
82
        uow = getSession().acquireUnitOfWork();
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/queries/report/ReportQueryFunctionTypeTestCase.java (-28 / +17 lines)
Lines 110-153 Link Here
110
        
110
        
111
            //To fix bug 6217517, AVG(t1.SALARY) returns an Integer value with DB2
111
            //To fix bug 6217517, AVG(t1.SALARY) returns an Integer value with DB2
112
            // The Integer also returned by SyBase (JConnect 6.05) and SQLServer 2005 (SQL Server  Version: 9.00.2050; Driver: Microsoft SQL Server 2005 JDBC Driver  Version: 1.2.2828.100) 
112
            // The Integer also returned by SyBase (JConnect 6.05) and SQLServer 2005 (SQL Server  Version: 9.00.2050; Driver: Microsoft SQL Server 2005 JDBC Driver  Version: 1.2.2828.100) 
113
            value = result.get("salary-ave");
113
            if (getSession().getDatasourcePlatform().isOracle()) {
114
            if (value instanceof Integer && !(getSession().getDatasourcePlatform().isDB2() || getSession().getDatasourcePlatform().isSybase() || getSession().getDatasourcePlatform().isSQLServer())) {
114
                value = result.get("salary-ave");
115
                throw new TestErrorException("Incorrect result type for average function of report query.");
115
                if (value instanceof Integer) {
116
            }
116
                    throw new TestErrorException("Incorrect result type for average function of report query.");
117
        
117
                }
118
            if (getSession().getDatasourcePlatform().isOracle()) {  
119
                value = result.get("salary-var");
118
                value = result.get("salary-var");
120
                if (value instanceof Integer) {
119
                if (value instanceof Integer) {
121
                    throw new TestErrorException("Incorrect result type for variance function of report query.");
120
                    throw new TestErrorException("Incorrect result type for variance function of report query.");
122
                }
121
                }
122
                value = result.get("id-sum");
123
                if (value instanceof BigDecimal) {
124
                    throw new TestErrorException("Incorrect result type for sum function of report query.");
125
                }
126
                value = result.get("id-min");
127
                if (value instanceof BigDecimal) {
128
                    throw new TestErrorException("Incorrect result type for min function of report query.");
129
                }
130
                value = result.get("id-max");
131
                if (value instanceof BigDecimal) {
132
                    throw new TestErrorException("Incorrect result type for max function of report query.");
133
                }
123
            }
134
            }
124
        
135
        
125
            value = result.get("salary-std");
136
            value = result.get("salary-std");
126
            if (value instanceof Integer) {
137
            if (value instanceof Integer) {
127
                throw new TestErrorException("Incorrect result type for standard deviation function of report query.");
138
                throw new TestErrorException("Incorrect result type for standard deviation function of report query.");
128
            }
139
            }
129
        
130
            //To fix bug 6217517, SUM(t0.EMP_ID) returns an Integer value with DB2
131
            value = result.get("id-sum");
132
            if (! (value instanceof BigDecimal || (value instanceof Integer && getSession().getDatasourcePlatform().isDB2()))) {
133
                throw new TestErrorException("Incorrect result type for sum function of report query.");
134
            }
135
        
136
            //To fix bug 6217517, MIN(t0.EMP_ID) returns an Integer value with DB2; Long on MySQL
137
            value = result.get("id-min");
138
            if (! (value instanceof BigDecimal || (value instanceof Integer && getSession().getDatasourcePlatform().isDB2())
139
                                               || (value instanceof Long && getSession().getDatasourcePlatform().isMySQL()
140
                                               || (value instanceof Long && getSession().getDatasourcePlatform().isPostgreSQL())))) {
141
                throw new TestErrorException("Incorrect result type for min function of report query.");
142
            }
143
        
144
            //To fix bug 6217517, MAX(t0.EMP_ID) returns an Integer value with DB2; Long on MySQL
145
            value = result.get("id-max");
146
            if (! (value instanceof BigDecimal || (value instanceof Integer && getSession().getDatasourcePlatform().isDB2())
147
                                               || (value instanceof Long && getSession().getDatasourcePlatform().isMySQL()
148
                                               || (value instanceof Long && getSession().getDatasourcePlatform().isPostgreSQL())))) {
149
                throw new TestErrorException("Incorrect result type for max function of report query.");
150
            }
151
        }
140
        }
152
    }
141
    }
153
    
142
    
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/unitofwork/UnitOfWorkClientSessionTestModel.java (+5 lines)
Lines 13-18 Link Here
13
package org.eclipse.persistence.testing.tests.unitofwork;
13
package org.eclipse.persistence.testing.tests.unitofwork;
14
14
15
import org.eclipse.persistence.sessions.Session;
15
import org.eclipse.persistence.sessions.Session;
16
import org.eclipse.persistence.testing.framework.TestWarningException;
16
import org.eclipse.persistence.testing.models.employee.relational.EmployeeSystem;
17
import org.eclipse.persistence.testing.models.employee.relational.EmployeeSystem;
17
import org.eclipse.persistence.testing.models.inheritance.InheritanceSystem;
18
import org.eclipse.persistence.testing.models.inheritance.InheritanceSystem;
18
import org.eclipse.persistence.testing.models.insurance.InsuranceSystem;
19
import org.eclipse.persistence.testing.models.insurance.InsuranceSystem;
Lines 30-35 Link Here
30
    public Session originalSession;
31
    public Session originalSession;
31
32
32
    public void addRequiredSystems() {
33
    public void addRequiredSystems() {
34
        // H2 has locking issue with multiple connections.
35
        if (getSession().getPlatform().isH2()) {
36
            throw new TestWarningException("H2 has locking issue with multiple connections");
37
        }
33
        addRequiredSystem(new OwnershipSystem());
38
        addRequiredSystem(new OwnershipSystem());
34
        addRequiredSystem(new IndirectListSystem());
39
        addRequiredSystem(new IndirectListSystem());
35
        addRequiredSystem(new EmployeeSystem());
40
        addRequiredSystem(new EmployeeSystem());
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/workbenchintegration/CMWorkbenchIntegrationSystem.java (+1 lines)
Lines 65-70 Link Here
65
    public static DatabaseQuery buildPersistenceTestEqualCalendarQuery() {
65
    public static DatabaseQuery buildPersistenceTestEqualCalendarQuery() {
66
        ExpressionBuilder builder = new ExpressionBuilder(ConversionDataObject.class);
66
        ExpressionBuilder builder = new ExpressionBuilder(ConversionDataObject.class);
67
        GregorianCalendar month = new GregorianCalendar();
67
        GregorianCalendar month = new GregorianCalendar();
68
        month.clear();
68
        month.set(2001, 6, 1, 11, 24, 36);
69
        month.set(2001, 6, 1, 11, 24, 36);
69
        Expression expression = builder.get("aCalendar").equal(month);
70
        Expression expression = builder.get("aCalendar").equal(month);
70
        ReadObjectQuery query = new ReadObjectQuery(ConversionDataObject.class);
71
        ReadObjectQuery query = new ReadObjectQuery(ConversionDataObject.class);
(-)foundation/org.eclipse.persistence.core/resource/org/eclipse/persistence/internal/helper/VendorNameToPlatformMapping.properties (+2 lines)
Lines 26-31 Link Here
26
(?i)mysql.*=org.eclipse.persistence.platform.database.MySQLPlatform
26
(?i)mysql.*=org.eclipse.persistence.platform.database.MySQLPlatform
27
(?i)informix.*=org.eclipse.persistence.platform.database.InformixPlatform
27
(?i)informix.*=org.eclipse.persistence.platform.database.InformixPlatform
28
(?i)postgresql.*=org.eclipse.persistence.platform.database.PostgreSQLPlatform
28
(?i)postgresql.*=org.eclipse.persistence.platform.database.PostgreSQLPlatform
29
(?i)h2.*=org.eclipse.persistence.platform.database.H2Platform
30
(?i)hsqldb.*=org.eclipse.persistence.platform.database.HSQLPlatform
29
31
30
32
31
33
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/config/PersistenceUnitProperties.java (+6 lines)
Lines 420-425 Link Here
420
    public static final String NATIVE_SQL = "eclipselink.jdbc.native-sql";
420
    public static final String NATIVE_SQL = "eclipselink.jdbc.native-sql";
421
    
421
    
422
    /**
422
    /**
423
     * Allows the CAST SQL operation to be disabled on platforms that support casting.
424
     * Casting is normally not required, and can cause issue when used.
425
     */
426
    public static final String SQL_CAST = "eclipselink.jdbc.sql-cast";
427
    
428
    /**
423
     * When native SQL queries are used, the JDBC meta-data may return column names in lower case on some platforms.
429
     * When native SQL queries are used, the JDBC meta-data may return column names in lower case on some platforms.
424
     * If the column names are uppercase in the mappings (default) then they will not match.
430
     * If the column names are uppercase in the mappings (default) then they will not match.
425
     * This setting allows for forcing the column names from the meta-data to uppercase.
431
     * This setting allows for forcing the column names from the meta-data to uppercase.
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/databaseaccess/DatabasePlatform.java (-11 / +41 lines)
Lines 56-61 Link Here
56
import org.eclipse.persistence.internal.helper.DatabaseTable;
56
import org.eclipse.persistence.internal.helper.DatabaseTable;
57
import org.eclipse.persistence.internal.helper.Helper;
57
import org.eclipse.persistence.internal.helper.Helper;
58
import org.eclipse.persistence.internal.sequencing.Sequencing;
58
import org.eclipse.persistence.internal.sequencing.Sequencing;
59
import org.eclipse.persistence.internal.sessions.AbstractRecord;
59
import org.eclipse.persistence.internal.sessions.AbstractSession;
60
import org.eclipse.persistence.internal.sessions.AbstractSession;
60
import org.eclipse.persistence.logging.SessionLog;
61
import org.eclipse.persistence.logging.SessionLog;
61
import org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField;
62
import org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField;
Lines 92-98 Link Here
92
 */
93
 */
93
public class DatabasePlatform extends DatasourcePlatform {
94
public class DatabasePlatform extends DatasourcePlatform {
94
95
95
    /** Holds a hashtable of values used to map JAVA types to database types for table creation */
96
    /** Holds a map of values used to map JAVA types to database types for table creation */
96
    protected transient Hashtable fieldTypes;
97
    protected transient Hashtable fieldTypes;
97
98
98
    /** Indicates that native SQL should be used for literal values instead of ODBC escape format
99
    /** Indicates that native SQL should be used for literal values instead of ODBC escape format
Lines 166-175 Link Here
166
    protected static boolean shouldIgnoreCaseOnFieldComparisons = false;
167
    protected static boolean shouldIgnoreCaseOnFieldComparisons = false;
167
168
168
169
169
	/** Bug#3214927 The default is 32000 for DynamicSQLBatchWritingMechanism.  
170
    /** Bug#3214927 The default is 32000 for DynamicSQLBatchWritingMechanism.  
170
	 * It would become 100 when switched to ParameterizedSQLBatchWritingMechanism. */
171
     * It would become 100 when switched to ParameterizedSQLBatchWritingMechanism.
171
	public static int DEFAULT_MAX_BATCH_WRITING_SIZE = 32000;
172
     */
172
	public static int DEFAULT_PARAMETERIZED_MAX_BATCH_WRITING_SIZE = 100;
173
    public static int DEFAULT_MAX_BATCH_WRITING_SIZE = 32000;
174
    public static int DEFAULT_PARAMETERIZED_MAX_BATCH_WRITING_SIZE = 100;
173
    
175
    
174
    /** This attribute will store the SQL query that will be used to 'ping' the database
176
    /** This attribute will store the SQL query that will be used to 'ping' the database
175
     * connection in order to check the health of a connection.
177
     * connection in order to check the health of a connection.
Lines 187-192 Link Here
187
     * specified in SQL.  This setting allows it to be enabled/disabled
189
     * specified in SQL.  This setting allows it to be enabled/disabled
188
     */ 
190
     */ 
189
    protected boolean useRownumFiltering = true;
191
    protected boolean useRownumFiltering = true;
192
    
193
    /** 
194
     * Allow platform specific cast to be disabled.
195
     */ 
196
    protected boolean isCastRequired = true;
190
197
191
    /* NCLOB sql type is defined in java.sql.Types in jdk 1.6, but not in jdk 1.5.
198
    /* NCLOB sql type is defined in java.sql.Types in jdk 1.6, but not in jdk 1.5.
192
     * Redefined here for backward compatibility:
199
     * Redefined here for backward compatibility:
Lines 216-223 Link Here
216
        this.startDelimiter = "\"";
223
        this.startDelimiter = "\"";
217
        this.endDelimiter = "\"";
224
        this.endDelimiter = "\"";
218
    }
225
    }
226
    
227
    /**
228
     * Return if casting is enabled for platforms that support it.
229
     * Allow platform specific cast to be disabled.
230
     */ 
231
    public boolean isCastRequired() {
232
        return isCastRequired;
233
    }
219
234
220
    /**
235
    /**
236
     * Set if casting is enabled for platforms that support it.
237
     * Allow platform specific cast to be disabled.
238
     */ 
239
    public void setIsCastRequired(boolean isCastRequired) {
240
        this.isCastRequired = isCastRequired;
241
    }
242
243
    /**
221
     * INTERNAL:
244
     * INTERNAL:
222
     * Get the map of StructConverters that will be used to preprocess
245
     * Get the map of StructConverters that will be used to preprocess
223
     * STRUCT data as it is read
246
     * STRUCT data as it is read
Lines 2633-2639 Link Here
2633
        }
2656
        }
2634
    }
2657
    }
2635
2658
2636
    public void writeParameterMarker(Writer writer, ParameterExpression expression) throws IOException {
2659
    public void writeParameterMarker(Writer writer, ParameterExpression expression, AbstractRecord record) throws IOException {
2637
        writer.write("?");
2660
        writer.write("?");
2638
    }
2661
    }
2639
2662
Lines 2807-2835 Link Here
2807
    
2830
    
2808
    /**
2831
    /**
2809
     * INTERNAL:
2832
     * INTERNAL:
2810
     * Override this method if the platform supports sequence objects.
2811
     * Returns sql used to create sequence object in the database.
2833
     * Returns sql used to create sequence object in the database.
2812
     */
2834
     */
2813
    public Writer buildSequenceObjectCreationWriter(Writer writer, String fullSeqName, int increment, int start) throws IOException {
2835
    public Writer buildSequenceObjectCreationWriter(Writer writer, String fullSeqName, int increment, int start) throws IOException {
2836
        writer.write("CREATE SEQUENCE ");
2837
        writer.write(fullSeqName);
2838
        if (increment != 1) {
2839
            writer.write(" INCREMENT BY " + increment);
2840
        }
2841
        writer.write(" START WITH " + start);
2814
        return writer;
2842
        return writer;
2815
    }
2843
    }
2816
2844
 
2817
    /**
2845
    /**
2818
     * INTERNAL:
2846
     * INTERNAL:
2819
     * Override this method if the platform supports sequence objects.
2820
     * Returns sql used to delete sequence object from the database.
2847
     * Returns sql used to delete sequence object from the database.
2821
     */
2848
     */
2822
    public Writer buildSequenceObjectDeletionWriter(Writer writer, String fullSeqName) throws IOException {
2849
    public Writer buildSequenceObjectDeletionWriter(Writer writer, String fullSeqName) throws IOException {
2850
        writer.write("DROP SEQUENCE ");
2851
        writer.write(fullSeqName);
2823
        return writer;
2852
        return writer;
2824
    }
2853
    }
2825
2854
2826
    /**
2855
    /**
2827
     * INTERNAL:
2856
     * INTERNAL:
2828
     * Override this method if the platform supports sequence objects
2829
     * and isAlterSequenceObjectSupported returns true.
2830
     * Returns sql used to alter sequence object's increment in the database.
2857
     * Returns sql used to alter sequence object's increment in the database.
2831
     */
2858
     */
2832
    public Writer buildSequenceObjectAlterIncrementWriter(Writer writer, String fullSeqName, int increment) throws IOException {
2859
    public Writer buildSequenceObjectAlterIncrementWriter(Writer writer, String fullSeqName, int increment) throws IOException {
2860
        writer.write("ALTER SEQUENCE ");
2861
        writer.write(fullSeqName);
2862
        writer.write(" INCREMENT BY " + increment);
2833
        return writer;
2863
        return writer;
2834
    }
2864
    }
2835
    
2865
    
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/databaseaccess/DatasourcePlatform.java (+5 lines)
Lines 353-358 Link Here
353
        addOperator(ExpressionOperator.locate());
353
        addOperator(ExpressionOperator.locate());
354
        addOperator(ExpressionOperator.locate2());
354
        addOperator(ExpressionOperator.locate2());
355
        addOperator(ExpressionOperator.nullIf());
355
        addOperator(ExpressionOperator.nullIf());
356
        addOperator(ExpressionOperator.ifNull());
356
357
357
        // Date
358
        // Date
358
        addOperator(ExpressionOperator.addMonths());
359
        addOperator(ExpressionOperator.addMonths());
Lines 429-434 Link Here
429
        return false;
430
        return false;
430
    }
431
    }
431
432
433
    public boolean isH2() {
434
        return false;
435
    }
436
432
    public boolean isDBase() {
437
    public boolean isDBase() {
433
        return false;
438
        return false;
434
    }
439
    }
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/databaseaccess/Platform.java (+1 lines)
Lines 76-81 Link Here
76
     */
76
     */
77
    public ValueReadQuery getTimestampQuery();
77
    public ValueReadQuery getTimestampQuery();
78
78
79
    public boolean isH2();
79
80
80
    public boolean isAccess();
81
    public boolean isAccess();
81
82
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/expressions/ExpressionSQLPrinter.java (-1 / +1 lines)
Lines 148-154 Link Here
148
148
149
    public void printParameter(ParameterExpression expression) {
149
    public void printParameter(ParameterExpression expression) {
150
        try {
150
        try {
151
            getCall().appendTranslationParameter(getWriter(), expression, getPlatform());
151
            getCall().appendTranslationParameter(getWriter(), expression, getPlatform(), getTranslationRow());
152
152
153
        } catch (IOException exception) {
153
        } catch (IOException exception) {
154
            throw ValidationException.fileError(exception);
154
            throw ValidationException.fileError(exception);
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/DB2Platform.java (-2 / +3 lines)
Lines 19-24 Link Here
19
import org.eclipse.persistence.exceptions.ValidationException;
19
import org.eclipse.persistence.exceptions.ValidationException;
20
import org.eclipse.persistence.expressions.*;
20
import org.eclipse.persistence.expressions.*;
21
import org.eclipse.persistence.internal.helper.*;
21
import org.eclipse.persistence.internal.helper.*;
22
import org.eclipse.persistence.internal.sessions.AbstractRecord;
22
import org.eclipse.persistence.internal.sessions.AbstractSession;
23
import org.eclipse.persistence.internal.sessions.AbstractSession;
23
import org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition;
24
import org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition;
24
import org.eclipse.persistence.internal.expressions.ParameterExpression;
25
import org.eclipse.persistence.internal.expressions.ParameterExpression;
Lines 537-550 Link Here
537
        return false;
538
        return false;
538
    }
539
    }
539
540
540
    public void writeParameterMarker(Writer writer, ParameterExpression parameter) throws IOException {
541
    public void writeParameterMarker(Writer writer, ParameterExpression parameter, AbstractRecord record) throws IOException {
541
        // DB2 requires cast around parameter markers if both operands of certain
542
        // DB2 requires cast around parameter markers if both operands of certain
542
        // operators are parameter markers
543
        // operators are parameter markers
543
        // This method generates CAST for parameter markers whose type is correctly
544
        // This method generates CAST for parameter markers whose type is correctly
544
        // identified by the query compiler
545
        // identified by the query compiler
545
        String paramaterMarker = "?";
546
        String paramaterMarker = "?";
546
        Object type = parameter.getType();
547
        Object type = parameter.getType();
547
        if(type != null) {
548
        if (this.isCastRequired && (type != null)) {
548
            BasicTypeHelperImpl typeHelper = BasicTypeHelperImpl.getInstance();
549
            BasicTypeHelperImpl typeHelper = BasicTypeHelperImpl.getInstance();
549
            String castType = null;
550
            String castType = null;
550
            if (typeHelper.isBooleanType(type) || typeHelper.isByteType(type) || typeHelper.isShortType(type)) {
551
            if (typeHelper.isBooleanType(type) || typeHelper.isByteType(type) || typeHelper.isShortType(type)) {
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/H2Platform.java (+268 lines)
Line 0 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 1998, 2009 Oracle. All rights reserved.
3
 * This program and the accompanying materials are made available under the 
4
 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 
5
 * which accompanies this distribution. 
6
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7
 * and the Eclipse Distribution License is available at 
8
 * http://www.eclipse.org/org/documents/edl-v10.php.
9
 *
10
 * Contributors:
11
 *     Mike Keith
12
 * 
13
 * Patterned after:
14
 *   org.eclipse.persistence.platform.database.DB2MainframePlatform      
15
 ******************************************************************************/
16
package org.eclipse.persistence.platform.database;
17
18
import java.io.*;
19
import java.util.*;
20
21
import org.eclipse.persistence.internal.databaseaccess.DatabaseCall;
22
import org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition;
23
import org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter;
24
import org.eclipse.persistence.internal.expressions.ParameterExpression;
25
import org.eclipse.persistence.internal.expressions.SQLSelectStatement;
26
import org.eclipse.persistence.internal.helper.BasicTypeHelperImpl;
27
import org.eclipse.persistence.internal.helper.ClassConstants;
28
import org.eclipse.persistence.internal.helper.DatabaseField;
29
import org.eclipse.persistence.internal.helper.DatabaseTable;
30
import org.eclipse.persistence.internal.sessions.AbstractRecord;
31
import org.eclipse.persistence.platform.database.HSQLPlatform;
32
import org.eclipse.persistence.queries.ValueReadQuery;
33
import org.eclipse.persistence.exceptions.ValidationException;
34
import org.eclipse.persistence.expressions.ExpressionOperator;
35
import org.eclipse.persistence.sequencing.Sequence;
36
import org.eclipse.persistence.sequencing.NativeSequence;
37
38
public class H2Platform extends HSQLPlatform {
39
    private static final long serialVersionUID = -2935483687958482934L;
40
41
    public H2Platform() {
42
        super();
43
        setPingSQL("SELECT 1");
44
        setSupportsAutoCommit(true);
45
    }
46
47
    @Override
48
    public final boolean isHSQL() {
49
        return false;
50
    }
51
52
    /**
53
     * Print the pagination SQL using H2 syntax " LIMIT <max> OFFSET <first>".
54
     */
55
    @Override
56
    public void printSQLSelectStatement(DatabaseCall call, ExpressionSQLPrinter printer, SQLSelectStatement statement) {
57
        int max = 0;
58
        if (statement.getQuery() != null) {
59
            max = statement.getQuery().getMaxRows();
60
        }
61
        if (max <= 0  || !(this.shouldUseRownumFiltering())) {
62
            super.printSQLSelectStatement(call, printer, statement);
63
            return;
64
        }
65
        statement.setUseUniqueFieldAliases(true);
66
        call.setFields(statement.printSQL(printer));
67
        printer.printString(" LIMIT ");
68
        printer.printParameter(DatabaseCall.MAXROW_FIELD);
69
        printer.printString(" OFFSET ");
70
        printer.printParameter(DatabaseCall.FIRSTRESULT_FIELD);
71
        call.setIgnoreFirstRowMaxResultsSettings(true);
72
    }
73
    
74
    
75
    /**
76
     * INTERNAL:
77
     * Use the JDBC maxResults and firstResultIndex setting to compute a value to use when
78
     * limiting the results of a query in SQL.  These limits tend to be used in two ways.
79
     * 
80
     * 1. MaxRows is the index of the last row to be returned (like JDBC maxResults)
81
     * 2. MaxRows is the number of rows to be returned
82
     * 
83
     * H2 uses case #2 and therefore the maxResults has to be altered based on the firstResultIndex.
84
     */
85
    @Override
86
    public int computeMaxRowsForSQL(int firstResultIndex, int maxResults){
87
        return maxResults - ((firstResultIndex >= 0) ? firstResultIndex : 0);
88
    }
89
    
90
    @Override
91
    @SuppressWarnings("unchecked")
92
    protected Hashtable buildFieldTypes() {
93
        Hashtable fieldTypeMapping = super.buildFieldTypes();
94
        fieldTypeMapping.put(java.sql.Date.class, new FieldTypeDefinition("DATE", false));
95
        fieldTypeMapping.put(java.sql.Time.class, new FieldTypeDefinition("TIME", false));
96
        fieldTypeMapping.put(java.sql.Timestamp.class, new FieldTypeDefinition("TIMESTAMP", false));
97
        fieldTypeMapping.put(java.sql.Blob.class, new FieldTypeDefinition("BLOB", false));
98
        fieldTypeMapping.put(java.sql.Clob.class, new FieldTypeDefinition("CLOB", false));
99
        fieldTypeMapping.put(Float.class, new FieldTypeDefinition("DOUBLE", false));
100
        fieldTypeMapping.put(Double.class, new FieldTypeDefinition("DOUBLE", false));
101
        fieldTypeMapping.put(Boolean.class, new FieldTypeDefinition("BOOLEAN", false));
102
        return fieldTypeMapping;
103
    }
104
105
    @Override
106
    public boolean isAlterSequenceObjectSupported() {
107
        return true;
108
    }
109
110
    @Override
111
    public ValueReadQuery buildSelectQueryForSequenceObject(String seqName, Integer size) {
112
        return new ValueReadQuery(new StringBuilder(20 + seqName.length()).append("CALL NEXT VALUE FOR ").append(seqName).toString());
113
    }
114
115
    @Override
116
    protected Sequence createPlatformDefaultSequence() {
117
        return new NativeSequence();
118
    }
119
120
    @Override
121
    public boolean supportsIdentity() {
122
        return true;
123
    }
124
125
    @Override
126
    public boolean supportsSequenceObjects() {
127
        return true;
128
    }
129
130
    @Override
131
    public ValueReadQuery buildSelectQueryForIdentity() {
132
        return new ValueReadQuery("CALL IDENTITY()");
133
    }
134
135
    @Override
136
    public void printFieldIdentityClause(Writer writer) throws ValidationException {
137
        try {
138
            writer.append(" IDENTITY");
139
        } catch (IOException e) {
140
            throw ValidationException.logIOError(e);
141
        }
142
    }
143
144
    @Override
145
    public boolean supportsForeignKeyConstraints() {
146
        return true;
147
    }
148
149
    @Override
150
    public boolean supportsLocalTempTables() {
151
        return true;
152
    }
153
154
    @Override
155
    public boolean supportsGlobalTempTables() {
156
        return true;
157
    }
158
159
    @Override
160
    protected String getCreateTempTableSqlPrefix() {
161
        return "CREATE TEMPORARY TABLE IF NOT EXISTS ";
162
    }
163
164
    /**
165
     * H2 does not allow using () in the update if only one field.
166
     */
167
    @Override
168
    public void writeUpdateOriginalFromTempTableSql(Writer writer, DatabaseTable table,
169
                                                     Collection pkFields,
170
                                                     Collection assignedFields) throws IOException 
171
    {
172
        writer.write("UPDATE ");
173
        String tableName = table.getQualifiedNameDelimited(this);
174
        writer.write(tableName);
175
        writer.write(" SET ");
176
        if (assignedFields.size() > 1) {
177
            writer.write("(");            
178
        }
179
        writeFieldsList(writer, assignedFields, this);
180
        if (assignedFields.size() > 1) {
181
            writer.write(")");            
182
        }
183
        writer.write(" = (SELECT ");        
184
        writeFieldsList(writer, assignedFields, this);
185
        writer.write(" FROM ");
186
        String tempTableName = getTempTableForTable(table).getQualifiedNameDelimited(this);
187
        writer.write(tempTableName);
188
        writeAutoJoinWhereClause(writer, null, tableName, pkFields, this);
189
        writer.write(") WHERE EXISTS(SELECT ");
190
        writer.write(((DatabaseField)pkFields.iterator().next()).getNameDelimited(this));
191
        writer.write(" FROM ");
192
        writer.write(tempTableName);
193
        writeAutoJoinWhereClause(writer, null, tableName, pkFields, this);
194
        writer.write(")");
195
    }
196
197
    @Override
198
    public boolean supportsNativeSequenceNumbers() {
199
        return true;
200
    }
201
202
    @Override
203
    public boolean supportsStoredFunctions() {
204
        return true;
205
    }
206
207
    @Override
208
    public ValueReadQuery getTimestampQuery() {
209
        return new ValueReadQuery("SELECT CURRENT_TIMESTAMP()");
210
    }
211
212
    @Override
213
    protected void initializePlatformOperators() {
214
        super.initializePlatformOperators();
215
        addOperator(ExpressionOperator.simpleMath(ExpressionOperator.Concat, "||"));
216
        addOperator(ExpressionOperator.simpleFunction(ExpressionOperator.Ceil, "CEILING"));
217
        addOperator(ExpressionOperator.simpleTwoArgumentFunction(ExpressionOperator.Nvl, "IFNULL"));
218
        addOperator(toNumberOperator());
219
        addOperator(monthsBetweenOperator());
220
    }
221
222
    /**
223
     * INTERNAL:
224
     * Use CONVERT function for toNumber.
225
     */
226
    public static ExpressionOperator toNumberOperator() {
227
        ExpressionOperator exOperator = new ExpressionOperator();
228
        exOperator.setType(ExpressionOperator.FunctionOperator);
229
        exOperator.setSelector(ExpressionOperator.ToNumber);
230
        Vector v = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(2);
231
        v.addElement("CONVERT(");
232
        v.addElement(",DECIMAL)");
233
        exOperator.printsAs(v);
234
        exOperator.bePrefix();
235
        exOperator.setNodeClass(ClassConstants.FunctionExpression_Class);
236
        return exOperator;
237
    }
238
239
    /**
240
     * INTERNAL:
241
     * Use MONTH function for MONTH_BETWEEN.
242
     */
243
    public static ExpressionOperator monthsBetweenOperator() {
244
        ExpressionOperator exOperator = new ExpressionOperator();
245
        exOperator.setType(ExpressionOperator.FunctionOperator);
246
        exOperator.setSelector(ExpressionOperator.MonthsBetween);
247
        Vector v = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(2);
248
        v.addElement("(MONTH(");
249
        v.addElement(") - MONTH(");
250
        v.addElement("))");
251
        exOperator.printsAs(v);
252
        exOperator.bePrefix();
253
        exOperator.setNodeClass(ClassConstants.FunctionExpression_Class);
254
        return exOperator;
255
    }
256
257
    /**
258
     * INTERNAL
259
     * H2 has some issue with un-typed parameters, this allows a workaround to these issues using literals.
260
     */
261
    public boolean shouldBindLiterals() {
262
        return false;
263
    }
264
265
    public boolean isH2() {
266
        return true;
267
    }
268
}
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/InformixPlatform.java (-39 lines)
Lines 285-333 Link Here
285
 
285
 
286
    /**
286
    /**
287
     * INTERNAL:
287
     * INTERNAL:
288
     * Override this method if the platform supports sequence objects.
289
     * Returns sql used to create sequence object in the database.
290
     */
291
    public Writer buildSequenceObjectCreationWriter(Writer writer, String fullSeqName, int increment, int start) throws IOException {
292
        writer.write("CREATE SEQUENCE ");
293
        writer.write(fullSeqName);
294
        if (increment != 1) {
295
            writer.write(" INCREMENT BY " + increment);
296
        }
297
        writer.write(" START WITH " + start);
298
        return writer;
299
    }
300
 
301
    /**
302
     * INTERNAL:
303
     * Override this method if the platform supports sequence objects.
304
     * Returns sql used to delete sequence object from the database.
305
     */
306
    public Writer buildSequenceObjectDeletionWriter(Writer writer, String fullSeqName) throws IOException {
307
        writer.write("DROP SEQUENCE ");
308
        writer.write(fullSeqName);
309
        return writer;
310
    }
311
 
312
    /**
313
     * INTERNAL:
314
     * Override this method if the platform supports sequence objects
288
     * Override this method if the platform supports sequence objects
315
     * and it's possible to alter sequence object's increment in the database.
289
     * and it's possible to alter sequence object's increment in the database.
316
     */
290
     */
317
    public boolean isAlterSequenceObjectSupported() {
291
    public boolean isAlterSequenceObjectSupported() {
318
        return true;
292
        return true;
319
    }
293
    }
320
 
321
    /**
322
     * INTERNAL:
323
     * Override this method if the platform supports sequence objects
324
     * and isAlterSequenceObjectSupported returns true.
325
     * Returns sql used to alter sequence object's increment in the database.
326
     */
327
    public Writer buildSequenceObjectAlterIncrementWriter(Writer writer, String fullSeqName, int increment) throws IOException {
328
        writer.write("ALTER SEQUENCE ");
329
        writer.write(fullSeqName);
330
        writer.write(" INCREMENT BY " + increment);
331
        return writer;
332
    }
333
}
294
}
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/OraclePlatform.java (-39 lines)
Lines 719-764 Link Here
719
719
720
    /**
720
    /**
721
     * INTERNAL:
721
     * INTERNAL:
722
     * Override this method if the platform supports sequence objects.
723
     * Returns sql used to create sequence object in the database.
724
     */
725
    public Writer buildSequenceObjectCreationWriter(Writer writer, String fullSeqName, int increment, int start) throws IOException {
726
        writer.write("CREATE SEQUENCE ");
727
        writer.write(fullSeqName);
728
        if (increment != 1) {
729
            writer.write(" INCREMENT BY " + increment);
730
        }
731
        writer.write(" START WITH " + start);
732
        return writer;
733
    }
734
735
    /**
736
     * INTERNAL:
737
     * Override this method if the platform supports sequence objects.
738
     * Returns sql used to delete sequence object from the database.
739
     */
740
    public Writer buildSequenceObjectDeletionWriter(Writer writer, String fullSeqName) throws IOException {
741
        writer.write("DROP SEQUENCE ");
742
        writer.write(fullSeqName);
743
        return writer;
744
    }
745
746
    /**
747
     * INTERNAL:
748
     * Override this method if the platform supports sequence objects
722
     * Override this method if the platform supports sequence objects
749
     * and isAlterSequenceObjectSupported returns true.
750
     * Returns sql used to alter sequence object's increment in the database.
751
     */
752
    public Writer buildSequenceObjectAlterIncrementWriter(Writer writer, String fullSeqName, int increment) throws IOException {
753
        writer.write("ALTER SEQUENCE ");
754
        writer.write(fullSeqName);
755
        writer.write(" INCREMENT BY " + increment);
756
        return writer;
757
    }
758
759
    /**
760
     * INTERNAL:
761
     * Override this method if the platform supports sequence objects
762
     * and it's possible to alter sequence object's increment in the database.
723
     * and it's possible to alter sequence object's increment in the database.
763
     */
724
     */
764
    public boolean isAlterSequenceObjectSupported() {
725
    public boolean isAlterSequenceObjectSupported() {
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/PostgreSQLPlatform.java (-39 lines)
Lines 419-464 Link Here
419
419
420
    /**
420
    /**
421
     * INTERNAL:
421
     * INTERNAL:
422
     * Override this method if the platform supports sequence objects.
423
     * Returns sql used to create sequence object in the database.
424
     */
425
    public Writer buildSequenceObjectCreationWriter(Writer writer, String fullSeqName, int increment, int start) throws IOException {
426
        writer.write("CREATE SEQUENCE ");
427
        writer.write(fullSeqName);
428
        if (increment != 1) {
429
            writer.write(" INCREMENT BY " + increment);
430
        }
431
        writer.write(" START WITH " + start);
432
        return writer;
433
    }
434
435
    /**
436
     * INTERNAL:
437
     * Override this method if the platform supports sequence objects.
438
     * Returns sql used to delete sequence object from the database.
439
     */
440
    public Writer buildSequenceObjectDeletionWriter(Writer writer, String fullSeqName) throws IOException {
441
        writer.write("DROP SEQUENCE ");
442
        writer.write(fullSeqName);
443
        return writer;
444
    }
445
446
    /**
447
     * INTERNAL:
448
     * Override this method if the platform supports sequence objects
422
     * Override this method if the platform supports sequence objects
449
     * and isAlterSequenceObjectSupported returns true.
450
     * Returns sql used to alter sequence object's increment in the database.
451
     */
452
    public Writer buildSequenceObjectAlterIncrementWriter(Writer writer, String fullSeqName, int increment) throws IOException {
453
        writer.write("ALTER SEQUENCE ");
454
        writer.write(fullSeqName);
455
        writer.write(" INCREMENT BY " + increment);
456
        return writer;
457
    }
458
459
    /**
460
     * INTERNAL:
461
     * Override this method if the platform supports sequence objects
462
     * and it's possible to alter sequence object's increment in the database.
423
     * and it's possible to alter sequence object's increment in the database.
463
     */
424
     */
464
    public boolean isAlterSequenceObjectSupported() {
425
    public boolean isAlterSequenceObjectSupported() {
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/TimesTenPlatform.java (-28 / +3 lines)
Lines 21-26 Link Here
21
import org.eclipse.persistence.internal.expressions.ParameterExpression;
21
import org.eclipse.persistence.internal.expressions.ParameterExpression;
22
import org.eclipse.persistence.internal.expressions.RelationExpression;
22
import org.eclipse.persistence.internal.expressions.RelationExpression;
23
import org.eclipse.persistence.internal.helper.Helper;
23
import org.eclipse.persistence.internal.helper.Helper;
24
import org.eclipse.persistence.internal.sessions.AbstractRecord;
24
import org.eclipse.persistence.queries.ValueReadQuery;
25
import org.eclipse.persistence.queries.ValueReadQuery;
25
26
26
public class TimesTenPlatform extends DatabasePlatform {
27
public class TimesTenPlatform extends DatabasePlatform {
Lines 228-268 Link Here
228
229
229
    /**
230
    /**
230
     * INTERNAL:
231
     * INTERNAL:
231
     * Override this method if the platform supports sequence objects.
232
     * Returns sql used to create sequence object in the database.
233
     */
234
    public Writer buildSequenceObjectCreationWriter(Writer writer, String fullSeqName, int increment, int start) throws IOException {
235
        writer.write("CREATE SEQUENCE ");
236
        writer.write(fullSeqName);
237
        if (increment != 1) {
238
            writer.write(" INCREMENT BY " + increment);
239
        }
240
        writer.write(" START WITH " + start);
241
        return writer;
242
    }
243
244
    /**
245
     * INTERNAL:
246
     * Override this method if the platform supports sequence objects.
247
     * Returns sql used to delete sequence object from the database.
248
     */
249
    public Writer buildSequenceObjectDeletionWriter(Writer writer, String fullSeqName) throws IOException {
250
        writer.write("DROP SEQUENCE ");
251
        writer.write(fullSeqName);
252
        return writer;
253
    }
254
255
    /**
256
     * INTERNAL:
257
     * TimesTen and DB2 require cast around parameter markers if both operands of certain
232
     * TimesTen and DB2 require cast around parameter markers if both operands of certain
258
     * operators are parameter markers
233
     * operators are parameter markers
259
     * This method generates CAST for parameter markers whose type is correctly
234
     * This method generates CAST for parameter markers whose type is correctly
260
     * identified by the query compiler
235
     * identified by the query compiler
261
     */
236
     */
262
    public void writeParameterMarker(Writer writer, ParameterExpression parameter) throws IOException {
237
    public void writeParameterMarker(Writer writer, ParameterExpression parameter, AbstractRecord record) throws IOException {
263
        String parameterMarker = "?";
238
        String parameterMarker = "?";
264
        Object type = parameter.getType();
239
        Object type = parameter.getType();
265
        if(type != null) {
240
        if (this.isCastRequired && (type != null)) {
266
            FieldTypeDefinition fieldType;
241
            FieldTypeDefinition fieldType;
267
            fieldType = getFieldTypeDefinition((Class)type);
242
            fieldType = getFieldTypeDefinition((Class)type);
268
            if (fieldType != null){
243
            if (fieldType != null){
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/queries/SQLCall.java (-2 / +3 lines)
Lines 16-21 Link Here
16
import java.io.*;
16
import java.io.*;
17
import org.eclipse.persistence.internal.databaseaccess.*;
17
import org.eclipse.persistence.internal.databaseaccess.*;
18
import org.eclipse.persistence.internal.helper.DatabaseField;
18
import org.eclipse.persistence.internal.helper.DatabaseField;
19
import org.eclipse.persistence.internal.sessions.AbstractRecord;
19
import org.eclipse.persistence.internal.sessions.AbstractSession;
20
import org.eclipse.persistence.internal.sessions.AbstractSession;
20
import org.eclipse.persistence.exceptions.ValidationException;
21
import org.eclipse.persistence.exceptions.ValidationException;
21
import org.eclipse.persistence.internal.expressions.ParameterExpression;
22
import org.eclipse.persistence.internal.expressions.ParameterExpression;
Lines 271-279 Link Here
271
     * INTERNAL:
272
     * INTERNAL:
272
     * All values are printed as ? to allow for parameter binding or translation during the execute of the call.
273
     * All values are printed as ? to allow for parameter binding or translation during the execute of the call.
273
     */
274
     */
274
    public void appendTranslationParameter(Writer writer, ParameterExpression expression, DatabasePlatform platform) throws IOException {
275
    public void appendTranslationParameter(Writer writer, ParameterExpression expression, DatabasePlatform platform, AbstractRecord record) throws IOException {
275
        try {
276
        try {
276
            platform.writeParameterMarker(writer, expression);
277
            platform.writeParameterMarker(writer, expression, record);
277
        } catch (IOException exception) {
278
        } catch (IOException exception) {
278
            throw ValidationException.fileError(exception);
279
            throw ValidationException.fileError(exception);
279
        }
280
        }
(-)jpa/eclipselink.jpa.test/resource/eclipselink-xml-only-model/inherited-entity-mappings.xml (-2 / +2 lines)
Lines 194-201 Link Here
194
        <exclude-superclass-listeners/>
194
        <exclude-superclass-listeners/>
195
        <attributes>
195
        <attributes>
196
            <id name="id">
196
            <id name="id">
197
                <generated-value strategy="AUTO"/>
197
                <!--generated-value strategy="AUTO"/-->
198
                <!-- generated-value strategy="TABLE" generator="XML_CERTIFICATION_TABLE_GENERATOR"/ -->
198
                <generated-value strategy="TABLE" generator="XML_CERTIFICATION_TABLE_GENERATOR"/>
199
            </id>
199
            </id>
200
            <basic name="description"/>
200
            <basic name="description"/>
201
            <many-to-one name="beerConsumer" target-entity="org.eclipse.persistence.testing.models.jpa.xml.inherited.BeerConsumer">
201
            <many-to-one name="beerConsumer" target-entity="org.eclipse.persistence.testing.models.jpa.xml.inherited.BeerConsumer">
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/framework/junit/JUnitTestCase.java (-2 / +3 lines)
Lines 514-520 Link Here
514
        DatabasePlatform platform = getServerSession().getPlatform();
514
        DatabasePlatform platform = getServerSession().getPlatform();
515
        // Both DB2 and Derby support pessimistic locking only for a single-table queries.
515
        // Both DB2 and Derby support pessimistic locking only for a single-table queries.
516
        // PostgreSQL supports for update, but not on outerjoins, which the test uses.
516
        // PostgreSQL supports for update, but not on outerjoins, which the test uses.
517
        if (platform.isDB2() || platform.isAccess() || platform.isSybase() || platform.isSQLAnywhere() || platform.isDerby() || platform.isPostgreSQL()) {
517
        // H2 supports pessimistic locking, but has table lock issues with multiple connections used in the tests.
518
        if (platform.isH2() || platform.isDB2() || platform.isAccess() || platform.isSybase() || platform.isSQLAnywhere() || platform.isDerby() || platform.isPostgreSQL()) {
518
            warning("This database does not support FOR UPDATE.");
519
            warning("This database does not support FOR UPDATE.");
519
            return false;
520
            return false;
520
        }
521
        }
Lines 527-533 Link Here
527
     */
528
     */
528
    public boolean isSelectForUpateNoWaitSupported() {
529
    public boolean isSelectForUpateNoWaitSupported() {
529
        DatabasePlatform platform = getServerSession().getPlatform();
530
        DatabasePlatform platform = getServerSession().getPlatform();
530
        if (platform.isDB2() || platform.isAccess() || platform.isSybase() || platform.isSQLAnywhere() || platform.isDerby() || platform.isPostgreSQL() || platform.isMySQL() || platform.isTimesTen()) {
531
        if (platform.isH2() || platform.isDB2() || platform.isAccess() || platform.isSybase() || platform.isSQLAnywhere() || platform.isDerby() || platform.isPostgreSQL() || platform.isMySQL() || platform.isTimesTen()) {
531
            warning("This database does not support NOWAIT.");
532
            warning("This database does not support NOWAIT.");
532
            return false;        
533
            return false;        
533
        }
534
        }
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/jpaadvancedproperties/JPAPropertiesRelationshipTableManager.java (-5 / +5 lines)
Lines 59-65 Link Here
59
        fieldCUST_ID.setSize(15);
59
        fieldCUST_ID.setSize(15);
60
        fieldCUST_ID.setSubSize(0);
60
        fieldCUST_ID.setSubSize(0);
61
        fieldCUST_ID.setIsPrimaryKey(true);
61
        fieldCUST_ID.setIsPrimaryKey(true);
62
        fieldCUST_ID.setIsIdentity(false);
62
        fieldCUST_ID.setIsIdentity(true);
63
        fieldCUST_ID.setUnique(false);
63
        fieldCUST_ID.setUnique(false);
64
        fieldCUST_ID.setShouldAllowNull(false);
64
        fieldCUST_ID.setShouldAllowNull(false);
65
        table.addField(fieldCUST_ID);
65
        table.addField(fieldCUST_ID);
Lines 109-115 Link Here
109
        fieldITEM_ID.setSize(15);
109
        fieldITEM_ID.setSize(15);
110
        fieldITEM_ID.setSubSize(0);
110
        fieldITEM_ID.setSubSize(0);
111
        fieldITEM_ID.setIsPrimaryKey(true);
111
        fieldITEM_ID.setIsPrimaryKey(true);
112
        fieldITEM_ID.setIsIdentity(false);
112
        fieldITEM_ID.setIsIdentity(true);
113
        fieldITEM_ID.setUnique(false);
113
        fieldITEM_ID.setUnique(false);
114
        fieldITEM_ID.setShouldAllowNull(false);
114
        fieldITEM_ID.setShouldAllowNull(false);
115
        table.addField(fieldITEM_ID);
115
        table.addField(fieldITEM_ID);
Lines 149-155 Link Here
149
        fieldITEM_ID.setSize(15);
149
        fieldITEM_ID.setSize(15);
150
        fieldITEM_ID.setSubSize(0);
150
        fieldITEM_ID.setSubSize(0);
151
        fieldITEM_ID.setIsPrimaryKey(true);
151
        fieldITEM_ID.setIsPrimaryKey(true);
152
        fieldITEM_ID.setIsIdentity(false);
152
        fieldITEM_ID.setIsIdentity(true);
153
        fieldITEM_ID.setUnique(false);
153
        fieldITEM_ID.setUnique(false);
154
        fieldITEM_ID.setShouldAllowNull(false);
154
        fieldITEM_ID.setShouldAllowNull(false);
155
        table.addField(fieldITEM_ID);
155
        table.addField(fieldITEM_ID);
Lines 232-238 Link Here
232
        fieldORDER_ID.setSize(15);
232
        fieldORDER_ID.setSize(15);
233
        fieldORDER_ID.setSubSize(0);
233
        fieldORDER_ID.setSubSize(0);
234
        fieldORDER_ID.setIsPrimaryKey(true);
234
        fieldORDER_ID.setIsPrimaryKey(true);
235
        fieldORDER_ID.setIsIdentity(false);
235
        fieldORDER_ID.setIsIdentity(true);
236
        fieldORDER_ID.setUnique(false);
236
        fieldORDER_ID.setUnique(false);
237
        fieldORDER_ID.setShouldAllowNull(false);
237
        fieldORDER_ID.setShouldAllowNull(false);
238
        table.addField(fieldORDER_ID);
238
        table.addField(fieldORDER_ID);
Lines 311-317 Link Here
311
        fieldID.setSize(15);
311
        fieldID.setSize(15);
312
        fieldID.setSubSize(0);
312
        fieldID.setSubSize(0);
313
        fieldID.setIsPrimaryKey(true);
313
        fieldID.setIsPrimaryKey(true);
314
        fieldID.setIsIdentity(false);
314
        fieldID.setIsIdentity(true);
315
        fieldID.setUnique(false);
315
        fieldID.setUnique(false);
316
        fieldID.setShouldAllowNull(false);
316
        fieldID.setShouldAllowNull(false);
317
        table.addField(fieldID);
317
        table.addField(fieldID);
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/performance/CacheCoordinationSessionCustomizer.java (+6 lines)
Lines 20-27 Link Here
20
import oracle.eclipselink.coherence.integrated.querying.UpdateObjectToCoherence;*/
20
import oracle.eclipselink.coherence.integrated.querying.UpdateObjectToCoherence;*/
21
21
22
import org.eclipse.persistence.config.SessionCustomizer;
22
import org.eclipse.persistence.config.SessionCustomizer;
23
//import org.eclipse.persistence.descriptors.ClassDescriptor;
23
import org.eclipse.persistence.sessions.Session;
24
import org.eclipse.persistence.sessions.Session;
25
//import org.eclipse.persistence.internal.sessions.DatabaseSessionImpl;
24
26
27
//import org.eclipse.persistence.sessions.coordination.RemoteCommandManager;
28
//import org.eclipse.persistence.sessions.coordination.TransportManager;
29
//import org.eclipse.persistence.sessions.coordination.jms.JMSTopicTransportManager;
30
25
public class CacheCoordinationSessionCustomizer implements SessionCustomizer {
31
public class CacheCoordinationSessionCustomizer implements SessionCustomizer {
26
32
27
    public void customize(Session session) throws Exception {
33
    public void customize(Session session) throws Exception {
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/xml/inherited/InheritedTableManager.java (-1 / +1 lines)
Lines 388-394 Link Here
388
        ID_field.setSize(15);
388
        ID_field.setSize(15);
389
        ID_field.setIsPrimaryKey(true);
389
        ID_field.setIsPrimaryKey(true);
390
        ID_field.setUnique(false);
390
        ID_field.setUnique(false);
391
        ID_field.setIsIdentity(false);
391
        ID_field.setIsIdentity(true);
392
        ID_field.setShouldAllowNull(false);
392
        ID_field.setShouldAllowNull(false);
393
        table.addField(ID_field);
393
        table.addField(ID_field);
394
394
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EMModifyAndCommitTest.java (-2 / +2 lines)
Lines 216-222 Link Here
216
        if (!employee.getAddress().getStreet().equals("324 Bay Street")){
216
        if (!employee.getAddress().getStreet().equals("324 Bay Street")){
217
            throw new TestErrorException("Employee ID :" + empIDs[2] + " Address not Updated");
217
            throw new TestErrorException("Employee ID :" + empIDs[2] + " Address not Updated");
218
        }
218
        }
219
        if (employee.getPeriod().getEndDate().getTime() >= System.currentTimeMillis()){
219
        if (employee.getPeriod().getEndDate().getTime() > System.currentTimeMillis()){
220
            throw new TestErrorException("Employee ID :" + empIDs[2] + " EndDate not Updated");
220
            throw new TestErrorException("Employee ID :" + empIDs[2] + " EndDate not Updated");
221
        }
221
        }
222
        if (employee.getSalary() != 0){
222
        if (employee.getSalary() != 0){
Lines 259-265 Link Here
259
        if (!employee.getAddress().getStreet().equals("324 Bay Street")){
259
        if (!employee.getAddress().getStreet().equals("324 Bay Street")){
260
            throw new TestErrorException("Employee ID :" + empIDs[2] + " Address not Updated on Database");
260
            throw new TestErrorException("Employee ID :" + empIDs[2] + " Address not Updated on Database");
261
        }
261
        }
262
        if (employee.getPeriod().getEndDate().getTime() >= System.currentTimeMillis()){
262
        if (employee.getPeriod().getEndDate().getTime() > System.currentTimeMillis()){
263
            throw new TestErrorException("Employee ID :" + empIDs[2] + " EndDate not Updated on Database");
263
            throw new TestErrorException("Employee ID :" + empIDs[2] + " EndDate not Updated on Database");
264
        }
264
        }
265
        if (employee.getSalary() != 0){
265
        if (employee.getSalary() != 0){
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EntityManagerJUnitTestSuite.java (-1 / +1 lines)
Lines 8241-8247 Link Here
8241
        }
8241
        }
8242
        
8242
        
8243
        // normally false; set to true for debug output for just this single test
8243
        // normally false; set to true for debug output for just this single test
8244
        boolean shouldForceFinest = true;
8244
        boolean shouldForceFinest = false;
8245
        int originalLogLevel = -1; 
8245
        int originalLogLevel = -1; 
8246
        
8246
        
8247
        ServerSession ss = ((EntityManagerFactoryImpl)getEntityManagerFactory()).getServerSession();
8247
        ServerSession ss = ((EntityManagerFactoryImpl)getEntityManagerFactory()).getServerSession();
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/cacheable/CacheableModelJunitTest.java (-1 lines)
Lines 168-174 Link Here
168
    public void setUp() {
168
    public void setUp() {
169
        super.setUp();
169
        super.setUp();
170
        clearDSCache();
170
        clearDSCache();
171
        getDSServerSession().setLogLevel(0);
172
    }
171
    }
173
    
172
    
174
    public static Test suite() {
173
    public static Test suite() {
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/complexaggregate/AggregatePrimaryKeyOrderByTest.java (-19 / +3 lines)
Lines 17-23 Link Here
17
import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
17
import org.eclipse.persistence.internal.jpa.EntityManagerImpl;
18
import org.eclipse.persistence.testing.models.jpa.complexaggregate.*;
18
import org.eclipse.persistence.testing.models.jpa.complexaggregate.*;
19
import org.eclipse.persistence.testing.tests.jpa.EntityContainerTestBase;
19
import org.eclipse.persistence.testing.tests.jpa.EntityContainerTestBase;
20
import org.eclipse.persistence.testing.framework.TestErrorException;
21
20
22
/**
21
/**
23
 * @author Guy Pelletier
22
 * @author Guy Pelletier
Lines 25-32 Link Here
25
 * @version 1.0
24
 * @version 1.0
26
 */
25
 */
27
public class AggregatePrimaryKeyOrderByTest extends EntityContainerTestBase {
26
public class AggregatePrimaryKeyOrderByTest extends EntityContainerTestBase {
28
    protected boolean m_reset = false;    // reset gets called twice on error
29
    protected Exception m_exception;
30
    protected boolean citySlickersAreOrdered;
27
    protected boolean citySlickersAreOrdered;
31
    protected boolean countryDwellersAreOrdered;
28
    protected boolean countryDwellersAreOrdered;
32
        
29
        
Lines 35-44 Link Here
35
    }
32
    }
36
    
33
    
37
    public void setup () {
34
    public void setup () {
38
        super.setup();
35
        super.setup();        
39
        m_reset = true;
40
        m_exception = null;
41
        
42
        ((EntityManagerImpl)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
36
        ((EntityManagerImpl)getEntityManager()).getActiveSession().getIdentityMapAccessor().initializeAllIdentityMaps();
43
    }
37
    }
44
    
38
    
Lines 146-166 Link Here
146
        
140
        
147
        } catch (RuntimeException e) {
141
        } catch (RuntimeException e) {
148
            rollbackTransaction();
142
            rollbackTransaction();
149
            m_exception = e;
143
            throw e;
150
        }
144
        }
151
    }
145
    }
152
    
146
    
153
    public void reset () {
147
    public void verify() {        
154
        if (m_reset) {
155
            m_reset = false;
156
        }
157
    }
158
    
159
    public void verify() {
160
        if (m_exception != null) {
161
            throw new TestErrorException("Error encountered during testing: " + m_exception.getMessage());
162
        }
163
        
164
        // JBS - Ordering check removed as order is random based on class method order which is not consistent in Java.
148
        // JBS - Ordering check removed as order is random based on class method order which is not consistent in Java.
165
        //if (!citySlickersAreOrdered) {
149
        //if (!citySlickersAreOrdered) {
166
        //    throw new TestErrorException("The city slickers were not ordered properly.");
150
        //    throw new TestErrorException("The city slickers were not ordered properly.");
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/inherited/InheritedModelJunitTest.java (-1 lines)
Lines 489-495 Link Here
489
                        
489
                        
490
            em.persist(beerConsumer);
490
            em.persist(beerConsumer);
491
            m_expertBeerConsumerId = beerConsumer.getId();
491
            m_expertBeerConsumerId = beerConsumer.getId();
492
            getServerSession().setLogLevel(0);
493
            commitTransaction(em);    
492
            commitTransaction(em);    
494
        } catch (RuntimeException e) {
493
        } catch (RuntimeException e) {
495
            if (isTransactionActive(em)){
494
            if (isTransactionActive(em)){
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/jpaadvancedproperties/JPAAdvPropertiesJUnitTestCase.java (+2 lines)
Lines 87-92 Link Here
87
            beginTransaction(em);
87
            beginTransaction(em);
88
            Customer customer = ModelExamples.customerExample1();
88
            Customer customer = ModelExamples.customerExample1();
89
            em.persist(customer);
89
            em.persist(customer);
90
            em.flush();
90
            Integer customerId = customer.getCustomerId();            
91
            Integer customerId = customer.getCustomerId();            
91
            commitTransaction(em);
92
            commitTransaction(em);
92
            
93
            
Lines 268-273 Link Here
268
            orders.add(ModelExamples.orderExample3());
269
            orders.add(ModelExamples.orderExample3());
269
            customer.setOrders(orders);
270
            customer.setOrders(orders);
270
            em.persist(customer);
271
            em.persist(customer);
272
            em.flush();
271
            customerId = customer.getCustomerId();
273
            customerId = customer.getCustomerId();
272
            commitTransaction(em);    
274
            commitTransaction(em);    
273
        } catch (RuntimeException e) {
275
        } catch (RuntimeException e) {
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/jpql/JUnitJPQLExamplesTestSuite.java (-2 / +9 lines)
Lines 449-456 Link Here
449
449
450
        if (result.containsAll(expectedResult) && expectedResult.containsAll(result))
450
        if (result.containsAll(expectedResult) && expectedResult.containsAll(result))
451
            testPass = true;
451
            testPass = true;
452
452
        
453
        Assert.assertEquals("All Expression test failed: data validation error", result.size(), 12);
453
        if (result.size() != 12) {
454
            // H2 ALL does not work correctly if the result is empty.
455
            if (getServerSession().getPlatform().isH2()) {
456
                warning("ALL fails on H2 as H2 has an SQL bug in ALL of none");
457
            } else {
458
                fail("All Expression test failed: data validation error: " + result.size() + " != " + 12);                
459
            }
460
        }
454
        Assert.assertTrue("All Expression test failed", testPass);
461
        Assert.assertTrue("All Expression test failed", testPass);
455
    }
462
    }
456
463
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/jpql/JUnitJPQLSimpleTestSuite.java (-4 / +12 lines)
Lines 33-38 Link Here
33
import junit.framework.Test;
33
import junit.framework.Test;
34
import junit.framework.TestSuite;
34
import junit.framework.TestSuite;
35
35
36
import org.eclipse.persistence.config.QueryHints;
36
import org.eclipse.persistence.expressions.Expression;
37
import org.eclipse.persistence.expressions.Expression;
37
import org.eclipse.persistence.expressions.ExpressionBuilder;
38
import org.eclipse.persistence.expressions.ExpressionBuilder;
38
import org.eclipse.persistence.expressions.ExpressionMath;
39
import org.eclipse.persistence.expressions.ExpressionMath;
Lines 222-227 Link Here
222
	        query = em.createQuery("SELECT e FROM Employee e WHERE :arg1=:arg2");
223
	        query = em.createQuery("SELECT e FROM Employee e WHERE :arg1=:arg2");
223
	        query.setParameter("arg1", 1);
224
	        query.setParameter("arg1", 1);
224
	        query.setParameter("arg2", 1);
225
	        query.setParameter("arg2", 1);
226
	        if (getServerSession().getPlatform().isDB2() || getServerSession().getPlatform().isH2() || getServerSession().getPlatform().isDerby()) {
227
        	        warning(":param=:param fail on Derby/Db2/H2, disabling binding");
228
        	        query.setHint(QueryHints.BIND_PARAMETERS, "false");
229
	        }
225
	        emps = query.getResultList();
230
	        emps = query.getResultList();
226
	
231
	
227
	        Assert.assertNotNull(emps);
232
	        Assert.assertNotNull(emps);
Lines 266-271 Link Here
266
        //preload employees into the cache so that phonenumbers are not prefetched
271
        //preload employees into the cache so that phonenumbers are not prefetched
267
        String ejbqlString = "SELECT e FROM Employee e";
272
        String ejbqlString = "SELECT e FROM Employee e";
268
        List result = em.createQuery(ejbqlString).getResultList();
273
        List result = em.createQuery(ejbqlString).getResultList();
274
        result.size();
269
        // run the simpleJoinFetchTest and verify all employees have phonenumbers fetched.
275
        // run the simpleJoinFetchTest and verify all employees have phonenumbers fetched.
270
        simpleJoinFetchTest(em);
276
        simpleJoinFetchTest(em);
271
    }
277
    }
Lines 1058-1064 Link Here
1058
        Vector parameters = new Vector();
1064
        Vector parameters = new Vector();
1059
        parameters.add(expectedResult.getFirstName());
1065
        parameters.add(expectedResult.getFirstName());
1060
1066
1061
        Vector employees = (Vector)getServerSession().executeQuery(raq, parameters);
1067
        List employees = (List)getServerSession().executeQuery(raq, parameters);
1068
        employees.size();
1062
1069
1063
        clearCache();
1070
        clearCache();
1064
1071
Lines 1423-1429 Link Here
1423
    }
1430
    }
1424
1431
1425
    public void conformResultsInUnitOfWorkTest() {
1432
    public void conformResultsInUnitOfWorkTest() {
1426
        EntityManager em = createEntityManager();
1427
        ReadObjectQuery readObjectQuery = new ReadObjectQuery();
1433
        ReadObjectQuery readObjectQuery = new ReadObjectQuery();
1428
1434
1429
        readObjectQuery.setReferenceClass(Employee.class);
1435
        readObjectQuery.setReferenceClass(Employee.class);
Lines 1953-1958 Link Here
1953
        ejbqlString = "SELECT emp FROM Employee emp WHERE ";
1959
        ejbqlString = "SELECT emp FROM Employee emp WHERE ";
1954
        ejbqlString = ejbqlString + "emp.status =  org.eclipse.persistence.testing.models.jpa.advanced.Employee.EmployeeStatus.FULL_TIME";
1960
        ejbqlString = ejbqlString + "emp.status =  org.eclipse.persistence.testing.models.jpa.advanced.Employee.EmployeeStatus.FULL_TIME";
1955
        List result = em.createQuery(ejbqlString).getResultList();
1961
        List result = em.createQuery(ejbqlString).getResultList();
1962
        result.size();
1956
    }
1963
    }
1957
1964
1958
    public void selectNamedNativeQueryWithPositionalParameterTest() {
1965
    public void selectNamedNativeQueryWithPositionalParameterTest() {
Lines 2128-2134 Link Here
2128
2135
2129
        Date date = Date.valueOf("1901-01-01");
2136
        Date date = Date.valueOf("1901-01-01");
2130
        Expression exp = (new ExpressionBuilder()).get("period").get("startDate").greaterThan(date);
2137
        Expression exp = (new ExpressionBuilder()).get("period").get("startDate").greaterThan(date);
2131
        Vector expectedResult = (Vector)getServerSession().readAllObjects(Employee.class, exp);
2138
        List expectedResult = getServerSession().readAllObjects(Employee.class, exp);
2132
        
2139
        
2133
        clearCache();
2140
        clearCache();
2134
2141
Lines 2143-2149 Link Here
2143
        EntityManager em = createEntityManager();
2150
        EntityManager em = createEntityManager();
2144
2151
2145
        Expression exp = (new ExpressionBuilder()).get("firstName").equal("Bob");
2152
        Expression exp = (new ExpressionBuilder()).get("firstName").equal("Bob");
2146
        Vector expectedResult = (Vector)getServerSession().readAllObjects(Employee.class, exp);
2153
        List expectedResult = getServerSession().readAllObjects(Employee.class, exp);
2154
        expectedResult.size();
2147
        
2155
        
2148
        clearCache();
2156
        clearCache();
2149
2157
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/relationships/RelationshipModelJUnitTestSuite.java (-3 / +1 lines)
Lines 250-258 Link Here
250
        Order order1 = new Order();
250
        Order order1 = new Order();
251
        Order order2 = new Order();
251
        Order order2 = new Order();
252
        Auditor auditor = new Auditor();
252
        Auditor auditor = new Auditor();
253
        
253
                
254
        getServerSession().setLogLevel(0);
255
        
256
        try {
254
        try {
257
            OrderCard order1Card = new OrderCard();
255
            OrderCard order1Card = new OrderCard();
258
            OrderLabel order1Label = new OrderLabel();
256
            OrderLabel order1Label = new OrderLabel();
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/xml/relationships/EntityMappingsRelationshipsJUnitTestCase.java (-1 lines)
Lines 479-485 Link Here
479
        Order order1 = new Order();
479
        Order order1 = new Order();
480
        Order order2 = new Order();
480
        Order order2 = new Order();
481
        Auditor auditor = new Auditor();
481
        Auditor auditor = new Auditor();
482
        
483
        try {
482
        try {
484
            OrderCard order1Card = new OrderCard();
483
            OrderCard order1Card = new OrderCard();
485
            OrderLabel order1Label = new OrderLabel();
484
            OrderLabel order1Label = new OrderLabel();
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/weaving/SimpleWeaverTestSuite.java (-1 / +3 lines)
Lines 23-28 Link Here
23
import org.eclipse.persistence.testing.models.weaving.SimpleProject;
23
import org.eclipse.persistence.testing.models.weaving.SimpleProject;
24
import org.eclipse.persistence.sessions.server.ServerSession;
24
import org.eclipse.persistence.sessions.server.ServerSession;
25
import org.eclipse.persistence.internal.weaving.*;
25
import org.eclipse.persistence.internal.weaving.*;
26
import org.eclipse.persistence.internal.jpa.metadata.MetadataLogger;
27
import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAsmFactory;
26
import org.eclipse.persistence.internal.jpa.weaving.*;
28
import org.eclipse.persistence.internal.jpa.weaving.*;
27
29
28
public class SimpleWeaverTestSuite extends TestCase {
30
public class SimpleWeaverTestSuite extends TestCase {
Lines 40-46 Link Here
40
		InputStream is = simpleClassLoader.getResourceAsStream(SimpleObject.class.getName().replace('.','/') + ".class");
42
		InputStream is = simpleClassLoader.getResourceAsStream(SimpleObject.class.getName().replace('.','/') + ".class");
41
		originalBytes = readStreamContentsIntoByteArray(is);
43
		originalBytes = readStreamContentsIntoByteArray(is);
42
		entities = new ArrayList();
44
		entities = new ArrayList();
43
		entities.add(SimpleObject.class);
45
		entities.add(new MetadataAsmFactory(new MetadataLogger(null), SimpleWeaverTestSuite.class.getClassLoader()).getMetadataClass(SimpleObject.class.getName()));
44
	}
46
	}
45
	public static void tearDownFixtures() {
47
	public static void tearDownFixtures() {
46
		simpleClassLoader = null;
48
		simpleClassLoader = null;
(-)jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/EntityManagerSetupImpl.java (+18 lines)
Lines 1400-1405 Link Here
1400
        updateBatchWritingSetting(m);
1400
        updateBatchWritingSetting(m);
1401
1401
1402
        updateNativeSQLSetting(m);
1402
        updateNativeSQLSetting(m);
1403
        updateSQLCastSetting(m);
1403
        updateUppercaseSetting(m);
1404
        updateUppercaseSetting(m);
1404
        updateCacheStatementSettings(m);
1405
        updateCacheStatementSettings(m);
1405
        updateTemporalMutableSetting(m);
1406
        updateTemporalMutableSetting(m);
Lines 1706-1711 Link Here
1706
    }
1707
    }
1707
    
1708
    
1708
    /**
1709
    /**
1710
     * Enable or disable SQL casting.
1711
     */
1712
    protected void updateSQLCastSetting(Map m) {
1713
        //Set Native SQL flag if it was specified.
1714
        String sqlCastString = EntityManagerFactoryProvider.getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.SQL_CAST, m, session);
1715
        if (sqlCastString != null) {
1716
           if (sqlCastString.equalsIgnoreCase("true")) {
1717
                 session.getProject().getLogin().getPlatform().setIsCastRequired(true);
1718
           } else if (sqlCastString.equalsIgnoreCase("false")) {
1719
               session.getProject().getLogin().getPlatform().setIsCastRequired(false);
1720
           } else {
1721
                 session.handleException(ValidationException.invalidBooleanValueForProperty(sqlCastString, PersistenceUnitProperties.SQL_CAST));
1722
           }
1723
        }
1724
    }
1725
    
1726
    /**
1709
     * Enable or disable forcing field names to uppercase.  
1727
     * Enable or disable forcing field names to uppercase.  
1710
     * The method needs to be called in deploy stage.
1728
     * The method needs to be called in deploy stage.
1711
     */
1729
     */
(-)jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProject.java (-1 / +1 lines)
Lines 1235-1241 Link Here
1235
                            if (defaultAutoSequence != null) {
1235
                            if (defaultAutoSequence != null) {
1236
                                seqName = defaultAutoSequence.getName();
1236
                                seqName = defaultAutoSequence.getName();
1237
                            } else {
1237
                            } else {
1238
                                seqName = DEFAULT_AUTO_GENERATOR; 
1238
                                seqName = DEFAULT_AUTO_GENERATOR;
1239
                            }
1239
                            }
1240
                        } else {
1240
                        } else {
1241
                            seqName = generatorName;
1241
                            seqName = generatorName;

Return to bug 215079