persistence@glassfish.java.net

Re: Some tests in JUnitEJBQLDateTimeTestSuite failed on Oracle

From: Michael Bouschen <Michael.Bouschen_at_Sun.COM>
Date: Tue, 19 Dec 2006 11:41:27 +0100

Hi Wonseok,

I could successfully run the entity-persistence-tests using a
10.2.0.1.0XE jdbc driver w/o getting the date problem you are facing.

Your changes looks ok to me. However, we should double check that this
is really an oracle jdbc driver problem. I'm just afraid of changing the
test case now which might hide the real problem.

Tom,
do you have some more insights about possible isses with the oracle 10.x
jdbc drivers?

Regards Michael

> Hi Tom, Michael
>
> This problem occurs only with 10.x drivers(10.1.0.2 <http://10.1.0.2>,
> 10.1.0.5 <http://10.1.0.5>, 10.2.0.1 <http://10.2.0.1>, 10.2.0.2
> <http://10.2.0.2> ) in my environment, but with 9.x drivers it works
> fine. Server version(I tried on 9.2.0.1 <http://9.2.0.1> and
> 10.2.0.1-XE) doesn't matter.
>
> I found the date value "1901-12-31 23:59:59.999" is inserted as
> "1902-01-01 00.00.00.999" with 10.x drivers, but not with 9.x drivers.
> But if I change the value to "1911-12-31 23:59:59.999", it is inserted
> correctly with 10.x drivers.
> So I suspect that the very old date value is not handled well with
> 10.x drivers in specific timezone.
>
> To avoid this problem, I would like to change date values from
> "1901-12-31 23:59:59.999" to "1911-12-31 23:59:59.999" occuring in
> DateTimePopulator and JUnitEJBQLDateTimeTestSuite. There was no
> problem in other tests.
> Please review the attached diff.
>
> Thanks,
> -Wonseok
>
> On 12/19/06, *Tom Ware* <tom.ware_at_oracle.com
> <mailto:tom.ware_at_oracle.com>> wrote:
>
> Hi Wonseok,
>
> I am also having trouble reproducing the issue you are
> seeing. When
> you run the type tests, it is important that the JDBC driver
> version and
> the DB version match. Is there a chance you are running with
> mismatched
> versions?
>
> -Tom
>
> Michael Bouschen wrote:
>
> > Hi Wonseok,
> >
> > yes, "ant clean-db" does the trick! I did run the tests on a clean
> > 10XE database which is why I did not see the errors there.
> >
> > Thanks for the info and sorry for the false alarm.
> >
> > Regards Michael
> >
> >> The two tests (testDDLUniqueKeysAsJoinColumns and
> >> testDDLSubclassEmbeddedIdPkColumnsInJoinedStrategy) fails
> because my
> >> last checked-in changed table name and column type of some
> entities.
> >>
> >> It will be okay if you run "ant clean-db" (clear existing
> tables and
> >> constraints). Really sorry for that.
> >> Every others maybe should clean existing tables (at least DDL_*
> >> tables) once due to remaining constraints(otherwise recreating
> >> DDL_CKENTB table fails).
> >>
> >> Regards,
> >> -Wonseok
> >>
> >> On 12/18/06, *Michael Bouschen* < Michael.Bouschen_at_sun.com
> <mailto:Michael.Bouschen_at_sun.com>
> >> <mailto:Michael.Bouschen_at_sun.com
> <mailto:Michael.Bouschen_at_sun.com>>> wrote:
> >>
> >> Hi Wonseok,
> >>
> >> I tried to reproduce the error, but the date tests succeed
> on my
> >> side.
> >>
> >> However, the specific version of the oracle database server and
> >> the jdbc driver matters! I see two ddl test errors
> >> (testDDLUniqueKeysAsJoinColumns and
> >> testDDLSubclassEmbeddedIdPkColumnsInJoinedStrategy) when
> running
> >> on an oracle database 9.2.0.7.0 and an oracle JDBC driver
> >> 9.0.2.0.0. A SQL INSERT statement on table DDL_CKENTB fails:
> >> ORA-01438: value larger than specified precision allows for
> this
> >> column.
> >>
> >> I also tried different combinations of oracle database
> server and
> >> jdbc driver, but they all succeed:
> >> - 9.2.0.7.0 database server with 10.2.0.1.0XE jdbc driver
> >> - 10XE (10.2.0.1.0) database server and 9.0.2.0.0 jdbc driver
> >> - 10XE ( 10.2.0.1.0) database server and 10.2.0.1.0XE jdbc
> driver
> >>
> >> In case you are interested, you find the output of the failing
> >> ddl tests below.
> >>
> >> Regards Michael
> >>
> >>
> >
>
>
> ------------------------------------------------------------------------
>
> Index: src/java/oracle/toplink/essentials/testing/models/cmp3/datetime/DateTimePopulator.java
> ===================================================================
> RCS file: /cvs/glassfish/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/models/cmp3/datetime/DateTimePopulator.java,v
> retrieving revision 1.3
> diff -c -w -r1.3 DateTimePopulator.java
> *** src/java/oracle/toplink/essentials/testing/models/cmp3/datetime/DateTimePopulator.java 6 Dec 2006 17:00:23 -0000 1.3
> --- src/java/oracle/toplink/essentials/testing/models/cmp3/datetime/DateTimePopulator.java 19 Dec 2006 03:03:14 -0000
> ***************
> *** 62,68 ****
>
> public DateTime example2() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1901, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> return buildAttributes(cal);
> --- 62,68 ----
>
> public DateTime example2() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1911, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> return buildAttributes(cal);
> ***************
> *** 84,90 ****
>
> public DateTime buildAttributes(Calendar cal) {
> DateTime dateTime = new DateTime();
> ! long time = cal.getTime().getTime();;
>
> dateTime.setDate(new java.sql.Date(time));
> dateTime.setTime(new Time(cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND)));
> --- 84,90 ----
>
> public DateTime buildAttributes(Calendar cal) {
> DateTime dateTime = new DateTime();
> ! long time = cal.getTime().getTime();
>
> dateTime.setDate(new java.sql.Date(time));
> dateTime.setTime(new Time(cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND)));
> Index: src/java/oracle/toplink/essentials/testing/tests/ejb/ejbqltesting/JUnitEJBQLDateTimeTestSuite.java
> ===================================================================
> RCS file: /cvs/glassfish/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/ejb/ejbqltesting/JUnitEJBQLDateTimeTestSuite.java,v
> retrieving revision 1.6
> diff -c -w -r1.6 JUnitEJBQLDateTimeTestSuite.java
> *** src/java/oracle/toplink/essentials/testing/tests/ejb/ejbqltesting/JUnitEJBQLDateTimeTestSuite.java 6 Jun 2006 13:30:05 -0000 1.6
> --- src/java/oracle/toplink/essentials/testing/tests/ejb/ejbqltesting/JUnitEJBQLDateTimeTestSuite.java 19 Dec 2006 03:03:15 -0000
> ***************
> *** 40,46 ****
>
> public void testSqlDate() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1901, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.date = :date").
> --- 40,46 ----
>
> public void testSqlDate() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1911, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.date = :date").
> ***************
> *** 52,58 ****
>
> public void testSqlDateToTS() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1901, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.date = :date").
> --- 52,58 ----
>
> public void testSqlDateToTS() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1911, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.date = :date").
> ***************
> *** 64,70 ****
>
> public void testTime() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1901, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.time = :time").
> --- 64,70 ----
>
> public void testTime() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1911, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.time = :time").
> ***************
> *** 76,82 ****
>
> public void testTimeToTS() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1901, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.time = :time").
> --- 76,82 ----
>
> public void testTimeToTS() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1911, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.time = :time").
> ***************
> *** 88,94 ****
>
> public void testTimestamp() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1901, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.timestamp = :timestamp").
> --- 88,94 ----
>
> public void testTimestamp() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1911, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.timestamp = :timestamp").
> ***************
> *** 100,106 ****
>
> public void testTimestampToDate() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1901, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.timestamp = :timestamp").
> --- 100,106 ----
>
> public void testTimestampToDate() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1911, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.timestamp = :timestamp").
> ***************
> *** 112,118 ****
>
> public void testTimestampToTime() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1901, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.timestamp = :timestamp").
> --- 112,118 ----
>
> public void testTimestampToTime() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1911, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.timestamp = :timestamp").
> ***************
> *** 124,130 ****
>
> public void testUtilDate() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1901, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.utilDate = :utilDate").
> --- 124,130 ----
>
> public void testUtilDate() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1911, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.utilDate = :utilDate").
> ***************
> *** 136,142 ****
>
> public void testCalenderWithUtilDate() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1901, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.calendar = :calendar").
> --- 136,142 ----
>
> public void testCalenderWithUtilDate() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1911, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.calendar = :calendar").
> ***************
> *** 148,154 ****
>
> public void testSqlDateWithCal() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1901, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.date = :date").
> --- 148,154 ----
>
> public void testSqlDateWithCal() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1911, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.date = :date").
> ***************
> *** 160,166 ****
>
> public void testTimeWithCal() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1901, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.time = :time").
> --- 160,166 ----
>
> public void testTimeWithCal() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1911, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.time = :time").
> ***************
> *** 172,178 ****
>
> public void testTimestampWithCal() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1901, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.timestamp = :timestamp").
> --- 172,178 ----
>
> public void testTimestampWithCal() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1911, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.timestamp = :timestamp").
> ***************
> *** 184,190 ****
>
> public void testUtilDateWithCal() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1901, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.utilDate = :utilDate").
> --- 184,190 ----
>
> public void testUtilDateWithCal() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1911, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.utilDate = :utilDate").
> ***************
> *** 196,202 ****
>
> public void testCalendar() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1901, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.calendar = :calendar").
> --- 196,202 ----
>
> public void testCalendar() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1911, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.calendar = :calendar").
> ***************
> *** 208,214 ****
>
> public void testTimestampGreaterThan() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1901, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.timestamp > :timestamp").
> --- 208,214 ----
>
> public void testTimestampGreaterThan() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1911, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> List result = createEntityManager().createQuery("SELECT OBJECT(o) FROM DateTime o WHERE o.timestamp > :timestamp").
> ***************
> *** 233,239 ****
> //IN node is going to be fixed and then this test will run
> public void testTimestampIn() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1901, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> GregorianCalendar cal2 = new GregorianCalendar();
> --- 233,239 ----
> //IN node is going to be fixed and then this test will run
> public void testTimestampIn() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1911, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> GregorianCalendar cal2 = new GregorianCalendar();
> ***************
> *** 250,256 ****
>
> public void testTimestampBetween() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1901, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> Calendar cal2 = Calendar.getInstance();
> --- 250,256 ----
>
> public void testTimestampBetween() {
> GregorianCalendar cal = new GregorianCalendar();
> ! cal.set(1911, 11, 31, 23, 59, 59);
> cal.set(Calendar.MILLISECOND, 999);
>
> Calendar cal2 = Calendar.getInstance();
>