Issue Details (XML | Word | Printable)

Key: OPENJPA-322
Type: Bug Bug
Status: Closed Closed
Resolution: Invalid
Priority: Minor Minor
Assignee: Srinivasa
Reporter: Srinivasa
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OpenJPA

Timezone on the Calendar object lost in proxying

Created: 17/Aug/07 10:14 PM   Updated: 31/Jan/08 07:12 PM
Return to search
Component/s: kernel
Affects Version/s: 1.0.0
Fix Version/s: 1.0.0, 1.0.2, 1.1.0

Time Tracking:
Not Specified

Resolution Date: 31/Jan/08 07:12 PM


 Description  « Hide
For the Calendar type when the proxy is created the Timezone information is lost.


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #567170 Fri Aug 17 23:20:43 UTC 2007 ssegu OPENJPA-322.Copying over the TimeZone to the proxy. 446787 seems to have accidentally removed this.
Files Changed
MODIFY /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java

Srinivasa made changes - 17/Aug/07 11:21 PM
Field Original Value New Value
Resolution Fixed [ 1 ]
Fix Version/s 1.0.0 [ 12312341 ]
Status Open [ 1 ] Resolved [ 5 ]
Marc Prud'hommeaux added a comment - 20/Oct/07 12:47 AM
I'm backing out this change, since it caused a regression in a test elsewhere.

The current documented behavior is that a Calendar field will always have set the TimeZone that the field was initialized with. For example, if you have a class that defines:

Calendar myCalendar = Calendar.getInstance(TimeZone.getTimeZone("Europe/Budapest"));

and then you later set the field to a different TimeZone, e.g.:

myCalendar = Calendar.getInstance(TimeZone.getTimeZone("America/New_York"));

when the instance is persisted and then retrieved, the TimeZone will revert to "Europe/Budapest". Note that this is the only way to maintain consistent behavior so long as we don't actually persist TimeZone data (which we don't).

Also, see section 2.1.1 of the EJB 3.0 Java Persistence API spec, which says: 'Note that an instance of Calendar must be fully initialized for the type that it is mapped to'. That suggests that they expect the TimeZone information in the initialized Calendar to be the one that is used over time.

Please close this issue if you agree with the reversion; otherwise, please put in a comment about why you think the current behavior is incorrect.

Marc Prud'hommeaux made changes - 20/Oct/07 12:47 AM
Assignee Srinivasa [ ssegu ]
Status Resolved [ 5 ] Reopened [ 4 ]
Resolution Fixed [ 1 ]
Repository Revision Date User Message
ASF #586649 Sat Oct 20 00:49:37 UTC 2007 mprudhom OPENJPA-322 reverted change #567170 to restore previous behavior of TimeZones in Calendar fields; added test case to confirm that the Calendar fields behave as expected
Files Changed
ADD /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestCalendarField.java
MODIFY /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java
MODIFY /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/test/SingleEMTestCase.java
MODIFY /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TemporalFieldTypes.java
MODIFY /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyCalendar.java

Patrick Linskey added a comment - 30/Jan/08 07:13 PM
Could you guys work out what the right behavior is for https://issues.apache.org/jira/browse/OPENJPA-322? I'd like to do a 1.0.2 release, and I noticed that this issue is still open, and that Marc's revert was not made in the 1.0.x branch.

Patrick Linskey made changes - 30/Jan/08 07:31 PM
Fix Version/s 1.1.0 [ 12312344 ]
Fix Version/s 1.0.2 [ 12312846 ]
Craig Russell added a comment - 31/Jan/08 06:58 PM
The JPA specification is a bit terse on the requirements, but does say that an @Temporal annotation is required for a persistent field or property of type Calendar, and that 'Note that an instance of Calendar must be fully initialized for the type that it is mapped to'. There are only three database types that the field can be mapped to:
public enum TemporalType {
DATE, //java.sql.Date
TIME, //java.sql.Time
TIMESTAMP //java.sql.Timestamp
}

None of these database types have any storage mechanism for the time zone of the Calendar, and therefore there is no way to construct a Calendar with the time zone of the original Calendar.

Until the specification is changed to allow for storage of the time zone using proprietary database APIs, the only thing I think we can do is to instantiate a Calendar using the default time zone of the caller at the time the field is fetched from the database.

Srinivasa added a comment - 31/Jan/08 07:12 PM
Discussed the same with Marc yesterday, closing the issue.

Srinivasa made changes - 31/Jan/08 07:12 PM
Resolution Invalid [ 6 ]
Status Reopened [ 4 ] Closed [ 6 ]