619 words

Wrong data stored in date only fileds

#1
2015-11-08 00:10

Hi,

we have an object with the following fields:

 

    private Date startDateTime;   // Time stamp: start of recording in local time zone
    private Date startDate;         // Date: date part of startDateTime
    private Date startTime;         // Time: time part of startDateTime
 
    @Basic(optional = false)
    @Temporal(TemporalType.TIMESTAMP)
    public Date getStartDateTime() {
        return startDateTime;
    }
 
    public void setStartDateTime(Date startDateTime) {
        this.startDateTime = startDateTime;
    }
 
    @Basic(optional = false)
    @Temporal(TemporalType.DATE)
    public Date getStartDate() {
        return startDate;
    }
 
    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }
 
    @Basic(optional = false)
    @Temporal(TemporalType.TIME)
    public Date getStartTime() {
        return startTime;
    }
 
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

 

When adding records to the DB close to time when a clock change is expected, for example 2am on the 25/10/2015 Madrid time (when clock goes back 1 hour at 3am), Object DB puts wrong data in the fields annotated with Temporal.DATE.

The attached DB shows the problem and can easily be reproduced.

Here are the values used to set the fields before adding the objects (in the attached DB) to the DB:

 

Record 1:

    startDateTime = Sun Oct 25 02:00:25 CEST 2015

    startDate = Sun Oct 25 00:00:00 CEST 2015

    startTime = Thu Jan 01 02:00:25 CET 1970

Record 2:

    startDateTime = Sun Oct 25 02:00:34 CEST 2015

    startDate = Sun Oct 25 00:00:00 CEST 2015

    startTime = Thu Jan 01 02:00:34 CET 1970

Record 3:

    startDateTime = Sun Oct 25 02:00:44 CEST 2015

    startDate = Sun Oct 25 00:00:00 CEST 2015

    startTime = Thu Jan 01 02:00:44 CET 1970

Record 4:

    startDateTime = Sun Oct 25 02:00:54 CEST 2015

    startDate = Sun Oct 25 00:00:00 CEST 2015

    startTime = Thu Jan 01 02:00:54 CET 1970

Record 5:

    startDateTime = Sun Oct 25 02:01:04 CEST 2015

    startDate = Sun Oct 25 00:00:00 CEST 2015

    startTime = Thu Jan 01 02:01:04 CET 1970

 

In the DB you will notice that the startDate field is set to "Sat Oct 24 00:00:00 CEST 2015", i.e. one day before 25th. The other two fields are correct.

 

This does not happen on other days. For example if add objects with the same time but on the 26th of October, the startDate is set to the 26th.

 

We would be grateful if you provide an explanation of what is going on.

 

Thank you

Emil

 

 

prolancer
prolancer's picture
Joined on 2013-07-17
User Post #31
#2
2015-11-09 14:05

It seems to be a regression of version 2.5.5 (following fixing another clock change issue).

Please try build 2.6.4_03 which should work well. Thank you for this report.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #2,333
#3
2015-11-09 21:25

Hi,

2.6.4_03 appears to fix the problem (more testing pending), however there are duplicate fields in the DB. For example we now have startDate and startDate_odbHidden. All fields have an _odbHidden partner.

Is this a debug code leftover?

Thank you

Emil

prolancer
prolancer's picture
Joined on 2013-07-17
User Post #32
#4
2015-11-09 21:29

Enhanced classes have __odbHidden methods added by the Enhancer. There is a change in this build, following this forum thread, but it should not generate new fields or properties.

You may however need to rebuild your project for this new build. If this doesn't help please provide more information about this new issue.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #2,338
#5
2015-11-09 21:57

Thank you.

A fresh build with 2.6.4_03 enhancer does not show the _odbHidden fields.

Emil

prolancer
prolancer's picture
Joined on 2013-07-17
User Post #33

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Attachments:
Maximum file size: 32 MB
Cancel