It occurs to me that I should probably share this. I've been using 
Jorge's wonderful Scala wrapper for JodaTime and I needed to persist 
DateTime and LocalDate. I found a Hibernate project that makes this 
possible. (Note that Jorge's wrapper is a work in progress and doesn't 
cover everything in JodaTime, but you can just use the JodaTime classes 
directly, which I did for DateTimeFormatter and DateTimeFormatterBuilder.)

In pom.xml:

<dependency>
   <groupId>org.scala-tools</groupId>
   <artifactId>time</artifactId>
   <version>2.7.5-0.2-SNAPSHOT</version>
</dependency>
<dependency>
   <groupId>joda-time</groupId>
   <artifactId>joda-time</artifactId>
   <version>1.6</version>
</dependency>
<dependency>
   <groupId>joda-time</groupId>
   <artifactId>joda-time-hibernate</artifactId>
   <version>1.1</version>
</dependency>

In the JPA entity classes:

@Type{val `type`="org.joda.time.contrib.hibernate.PersistentDateTime"}
@Column{val name="created_at", val updatable = false}
var createdAt: DateTime = DateTime.now

Gets persisted as a "timestamp without time zone" in PostgreSQL.

@Type{val `type`="org.joda.time.contrib.hibernate.PersistentLocalDate"}
@Column{val name = "born_on"}
var bornOn: LocalDate = new LocalDate()

Gets persisted as a "date" in PostgreSQL.

http://joda-time.sourceforge.net/
http://github.com/jorgeortiz85/scala-time
http://joda-time.sourceforge.net/contrib/hibernate/index.html

Chas.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to