Thomas,

For Jadira with Hibernate, the proper dependencies are something like:

    <dependency>
      <groupId>org.jadira.usertype</groupId>
      <artifactId>usertype.core</artifactId>
      <version>3.1.0.CR7</version>
    </dependency>

    <dependency>
      <groupId>org.jadira.usertype</groupId>
      <artifactId>usertype.spi</artifactId>
      <version>3.1.0.CR7</version>
    </dependency>

    <dependency>
      <groupId>joda-time</groupId>
      <artifactId>joda-time</artifactId>
      <version>2.2</version>
    </dependency>

As well as @Column you need to declare the type:

    @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")

But all of this is for Hibernate. Your exception suggests you are using 
EclipseLink, for that you might find your answer here: 
http://code.google.com/p/joda-time-eclipselink-integration/


Regards Chris

From: Thomas Lionel SMETS (prof) [mailto:tsm...@a3-system.eu]
Sent: 04 June 2013 17:28
To: joda-interest@lists.sourceforge.net
Subject: [Joda-interest] Mapping with JPA2

Hi,

I have be trying various configuration / declaration for mapping my JodaTime 
attribute.
So far none worked ...
The simple
<code>
    @Column
    private DateTime expireTime = null;
</code>

I have in my pom.xml :
<code>
    <!-- Special libraries replaced for accurate persistence of JodaTime with 
Hibernate -->
    <dependency>
      <groupId>org.jadira.usertype</groupId>
      <artifactId>usertype.jodatime</artifactId>
      <version>2.0.1</version>
    </dependency>

    <dependency>
      <groupId>org.jadira.usertype</groupId>
      <artifactId>usertype.spi</artifactId>
      <version>2.0</version>
    </dependency>

    <dependency>
      <groupId>joda-time</groupId>
      <artifactId>joda-time</artifactId>
      <version>2.2</version>
    </dependency>
</code>

but it generates errors :


Struts has detected an unhandled exception:
Messages:


  1.  incompatible data type in conversion
  2.  incompatible data type in conversion
  3.  Internal Exception: java.sql.SQLSyntaxErrorException: incompatible data 
type in conversion Error Code: -5561 Call: INSERT INTO AUTHORIZED_TRAN... bla 
bla bla
  4.  Exception [EclipseLink-4002] (Eclipse Persistence Services - 
2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException 
Internal Exception: java.sql.SQLSyntaxErrorException: incompatible data type in 
conversion Error Code: -5561 Call: INSERT INTO AUTHORIZED_TRA... bla bla bla


Otherwise I can try to hoock it closer to Hibernate ...
with something like this :
<code>
    @Column
    @Type(type="org.joda.time.contrib.hibernate.PersistentDateTime")
    private DateTime expireTime = null;
</code>
I put in my pom.xml :
<code>
    <dependency>
      <groupId>joda-time</groupId>
      <artifactId>joda-time-hibernate</artifactId>
      <version>1.3</version>
    </dependency>
</code>

without the previous dependencies (of course)

And I get a



Struts has detected an unhandled exception:
Messages:


  1.  data exception: string data, right truncation
  2.  Internal Exception: java.sql.SQLDataException: data exception: string 
data, right truncation Error Code: -3401 Call: INSERT INTO AUTH... bla bla bla
  3.  Exception [EclipseLink-4002] (Eclipse Persistence Services - 
2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException 
Internal Exception: java.sql.SQLDataException: data exception: string data, 
right truncation Error Code: -3401 Call: INSERT INTO AUTHORIZED_TRANSA... bla 
bla bla



Any help would be appreciated :)


\T,











--
Thomas Lionel SMETS, CISSP (385434)
m : +32 497 44 68 12
ph : +32 2 852 3341
skype : thomas.lionel.smets

PGP = FDF0 8FB8 4F37 3F79 1011 05AB 0DCE 9BAB 5DD0 0E10
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to