Hi,

It's been like a ton of years since this  post, and I apologize:
http://www.mail-archive.com/joda-interest@lists.sourceforge.net/msg00520.html

I finally got some time to peek at joda-time-hibernate again, and
found the following:

1.- The package-info works  fine. You just map something like this in
your model class and it gets persisted as expected:

        @Type(type = "dateTime")
        private DateTime timestamp = new DateTime();

2.- It's weird, but this will not work (at least in my environment) if
you include it in joda-time-hibernate.jar. For me, it is only working
if I put the package-info file inside a "org.joda.time" package in the
same class folder that the model class. Putting it in a different jar
file gets it ignored.

I'm posting this just to get it documented somewhere. The package-info
file follows, to use it:

1.- Save this file as "package-info.java" inside a "org.joda.time"
package in your model class folder. It must get compiled just as any
java file.
2.- Add your persistent attributes as specified above.
3.- Test your persistence.

Sorry but I have not been able to put it inside the
joda-time-hibernate.jar. It is quite an obscure Hibernate feature,
maybe it gets improved in the future.

Regards,

===

/**
 * Annotations used to map type names to Hibernate UserType classes
 */
@org.hibernate.annotations.TypeDefs({
        @org.hibernate.annotations.TypeDef(
                        name="dateTime",
                        typeClass = 
org.joda.time.contrib.hibernate.PersistentDateTime.class
        ),
        @org.hibernate.annotations.TypeDef(
                        name="dateTimeTZ",
                        typeClass = 
org.joda.time.contrib.hibernate.PersistentDateTimeTZ.class
        ),
        @org.hibernate.annotations.TypeDef(
                        name="duration",
                        typeClass = 
org.joda.time.contrib.hibernate.PersistentDuration.class
        ),
        @org.hibernate.annotations.TypeDef(
                        name="interval",
                        typeClass = 
org.joda.time.contrib.hibernate.PersistentInterval.class
        ),
        @org.hibernate.annotations.TypeDef(
                        name="localDate",
                        typeClass = 
org.joda.time.contrib.hibernate.PersistentLocalDate.class
        ),
        @org.hibernate.annotations.TypeDef(
                        name="localTimeAsString",
                        typeClass = 
org.joda.time.contrib.hibernate.PersistentLocalTimeAsString.class
        ),
        @org.hibernate.annotations.TypeDef(
                        name="localTime",
                        typeClass = 
org.joda.time.contrib.hibernate.PersistentLocalTimeAsTime.class
        ),
        @org.hibernate.annotations.TypeDef(
                        name="localTimeExact",
                        typeClass = 
org.joda.time.contrib.hibernate.PersistentLocalTimeExact.class
        ),
        @org.hibernate.annotations.TypeDef(
                        name="period",
                        typeClass = 
org.joda.time.contrib.hibernate.PersistentPeriod.class
        ),
        @org.hibernate.annotations.TypeDef(
                        name="timeOfDay",
                        typeClass = 
org.joda.time.contrib.hibernate.PersistentTimeOfDay.class
        ),
        @org.hibernate.annotations.TypeDef(
                        name="timeOfDayExact",
                        typeClass = 
org.joda.time.contrib.hibernate.PersistentTimeOfDayExact.class
        ),
        @org.hibernate.annotations.TypeDef(
                        name="yearMonthDay",
                        typeClass = 
org.joda.time.contrib.hibernate.PersistentYearMonthDay.class
        )
})
package org.joda.time;

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to