Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO/Hibernate] Date Types
[CDO/Hibernate] Date Types [message #989045] Tue, 04 December 2012 12:27 Go to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Hello

What are your experiences with date types (DATE, TIME, DATETIME) using CDO with the Hibernate store? Are there any known best practices?

In my case, I would like to the database columns to be created with the respective types (DATE, TIME, DATETIME). From a coding point of view it would probably be the easiest to work with java.util.Date or java.util.Calendar. The model should automatically discard unwanted information (i.e. the TIME information for a DATE field).

There are lots of possibilities, including but not limited to:
- using EDate and setting the column type in the mapping
- wrapping java.util.Date or java.util.Calendar
- wrapping Long as in java.util.Date.getTime
- using XMLGregorianCalendar

Any pointers on how to get started are most welcome Smile

Thanks
Christoph

Re: [CDO/Hibernate] Date Types [message #989410 is a reply to message #989045] Thu, 06 December 2012 06:41 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Christoph,

You must decide which Java type fulfills your requirements best and then wrap it into a custom EDataType. That can be
persisted by CDO. Please note that only the Ecore data types are transfered in binary form over the network. CDO
serializes custom data types as Strings.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Am 04.12.2012 13:27, schrieb Christoph Keimel:
> Hello
>
> What are your experiences with date types (DATE, TIME, DATETIME) using CDO with the Hibernate store? Are there any
> known best practices?
>
> In my case, I would like to the database columns to be created with the respective types (DATE, TIME, DATETIME). From
> a coding point of view it would probably be the easiest to work with java.util.Date or java.util.Calendar. The model
> should automatically discard unwanted information (i.e. the TIME information for a DATE field).
>
> There are lots of possibilities, including but not limited to:
> - using EDate and setting the column type in the mapping
> - wrapping java.util.Date or java.util.Calendar
> - wrapping Long as in java.util.Date.getTime
> - using XMLGregorianCalendar
>
> Any pointers on how to get started are most welcome :)
>
> Thanks
> Christoph
>
>


Re: [CDO/Hibernate] Date Types [message #989429 is a reply to message #989410] Thu, 06 December 2012 08:20 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
He Christoph,
Missed your post... I always use java.util.Date myself as this is best-known for most developers. But Dates are a bit
messy in java, especially if you using time zones. Another option is to store them as longs in the database. But this is
less readable if external tools need to directly access the database.

gr. Martin

On 12/06/2012 07:41 AM, Eike Stepper wrote:
> Hi Christoph,
>
> You must decide which Java type fulfills your requirements best and then wrap it into a custom EDataType. That can be
> persisted by CDO. Please note that only the Ecore data types are transfered in binary form over the network. CDO
> serializes custom data types as Strings.
>
> Cheers
> /Eike
>
> ----
> http://www.esc-net.de
> http://thegordian.blogspot.com
> http://twitter.com/eikestepper
>
>
> Am 04.12.2012 13:27, schrieb Christoph Keimel:
>> Hello
>>
>> What are your experiences with date types (DATE, TIME, DATETIME) using CDO with the Hibernate store? Are there any
>> known best practices?
>>
>> In my case, I would like to the database columns to be created with the respective types (DATE, TIME, DATETIME). From
>> a coding point of view it would probably be the easiest to work with java.util.Date or java.util.Calendar. The model
>> should automatically discard unwanted information (i.e. the TIME information for a DATE field).
>>
>> There are lots of possibilities, including but not limited to:
>> - using EDate and setting the column type in the mapping
>> - wrapping java.util.Date or java.util.Calendar
>> - wrapping Long as in java.util.Date.getTime
>> - using XMLGregorianCalendar
>>
>> Any pointers on how to get started are most welcome :)
>>
>> Thanks
>> Christoph
>>
>>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Previous Topic:Property Sheet is empty when selecting an (EMF-)object in tree viewer using a custom ViewPart
Next Topic:[CDO] org.eclipse.emf.cdo.common.util.PartialCollectionLoadingNotSupportedException
Goto Forum:
  


Current Time: Fri Apr 26 21:23:37 GMT 2024

Powered by FUDForum. Page generated in 0.05247 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top