Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Weird problems while saving and reading Calendar in jpa(Weird problems while saving and reading Calendar in jpa(eclipslink))
Weird problems while saving and reading Calendar in jpa [message #905575] Thu, 30 August 2012 13:03 Go to next message
Khurshed Salimov is currently offline Khurshed Salimov
Messages: 7
Registered: July 2012
Junior Member
I am running in weird situation with java Calendar in jpa. The problem is while saving and reading back java.Calendar I not getting consistent date?
Re: Weird problems while saving and reading Calendar in jpa [message #905577 is a reply to message #905575] Thu, 30 August 2012 13:05 Go to previous messageGo to next message
Khurshed Salimov is currently offline Khurshed Salimov
Messages: 7
Registered: July 2012
Junior Member
The problem was in caching of entities . So I disabled caching by using the following annotation on entities :

@Cacheable(false)

I used that annotation on entities with java.Calendar field
Re: Weird problems while saving and reading Calendar in jpa [message #905661 is a reply to message #905577] Thu, 30 August 2012 16:34 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom Eugelink
Messages: 807
Registered: July 2009
Senior Member
Calendars are scary things, because they are mutable.

Tom


On 2012-08-30 19:05, Khurshed Salimov wrote:
> The problem was in caching of entities . So I disabled caching by using the following annotation on entities :
>
> @Cacheable(false)
>
> I used that annotation on entities with java.Calendar field
Re: Weird problems while saving and reading Calendar in jpa [message #909039 is a reply to message #905661] Thu, 06 September 2012 08:56 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

You could also try the persistence unit property,

"eclipselink.temporal.mutable"="true"


James : Wiki : Book : Blog : Twitter
Re: Weird problems while saving and reading Calendar in jpa [message #912543 is a reply to message #905577] Thu, 13 September 2012 14:39 Go to previous messageGo to next message
Eduardo Frazão is currently offline Eduardo Frazão
Messages: 118
Registered: January 2012
Senior Member
java.util.Date fields have this problem too?
Re: Weird problems while saving and reading Calendar in jpa [message #916058 is a reply to message #912543] Tue, 18 September 2012 09:17 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

The method on java.util.Date are mainly deprecated, so should not have this issue. In general, you should ensure you create a new Date/Calendar for a new Date/Calendar, not modify the existing one.

James : Wiki : Book : Blog : Twitter
Re: Weird problems while saving and reading Calendar in jpa [message #962625 is a reply to message #905575] Mon, 29 October 2012 03:52 Go to previous message
Khurshed Salimov is currently offline Khurshed Salimov
Messages: 7
Registered: July 2012
Junior Member
"eclipselink.temporal.mutable"="true" only makes changes to mutable data or Calendar to be able to track by persistence context. But problem was in shared cache. Because when inserting entity it will added to shared cache and while reading back from shared cache copy of calendar is created. That is the real cause of problem since here we are making new copy of calendar instance not building new one after executing database query.
Previous Topic:EntityListener not called (SOLVED)
Next Topic:Cannot generate SQL tables when @NoSQL entities are present
Goto Forum:
  


Current Time: Thu Aug 21 04:32:58 EDT 2014

Powered by FUDForum. Page generated in 0.09363 seconds