<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jadira &#8211; My Shitty Code</title>
	<atom:link href="https://myshittycode.com/tag/jadira/feed/" rel="self" type="application/rss+xml" />
	<link>https://myshittycode.com</link>
	<description>Embracing the Messiness in Search of Epic Solutions</description>
	<lastBuildDate>Fri, 06 Jan 2023 17:18:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://myshittycode.com/wp-content/uploads/2022/04/cropped-icon-32x32.png</url>
	<title>Jadira &#8211; My Shitty Code</title>
	<link>https://myshittycode.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">205304208</site>	<item>
		<title>Jadira Usertype: Under JDK 6 it may not be possible to handle DST transitions correctly</title>
		<link>https://myshittycode.com/2013/12/26/jadira-usertype-under-jdk-6-it-may-not-be-possible-to-handle-dst-transitions-correctly/</link>
					<comments>https://myshittycode.com/2013/12/26/jadira-usertype-under-jdk-6-it-may-not-be-possible-to-handle-dst-transitions-correctly/#respond</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Thu, 26 Dec 2013 14:51:54 +0000</pubDate>
				<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Jadira]]></category>
		<category><![CDATA[Joda-Time]]></category>
		<guid isPermaLink="false">http://myshittycode.com/?p=277</guid>

					<description><![CDATA[<p>PROBLEM When saving a Hibernate entity that contains Joda Time object, Jadira UserType throws the following warning:- This warning occurs when using this version:- SOLUTION Upgrade Jadira Usertype to the latest version, and the problem goes away:-</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2013/12/26/jadira-usertype-under-jdk-6-it-may-not-be-possible-to-handle-dst-transitions-correctly/">Jadira Usertype: Under JDK 6 it may not be possible to handle DST transitions correctly</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">PROBLEM</h2>



<p>When saving a Hibernate entity that contains Joda Time object, Jadira UserType throws the following warning:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&#x5B;WARN ] &#x5B;JavaTimeZoneWorkaroundHelper] &#x5B;&amp;lt;clinit&gt;:40] - Under JDK 6 it may not be possible
to handle DST transitions correctly
&#x5B;ERROR] &#x5B;JavaTimeZoneWorkaroundHelper] &#x5B;&amp;lt;clinit&gt;:42] - Running under a Zone that uses
daylight saving time. To avoid incorrect datetimes being stored during DST transition,
either update to JDK 7 or use a Timezone for the JDK without Daylight Saving Time
</pre></div>


<p>This warning occurs when using this version:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
&lt;dependency&gt;
    &lt;groupId&gt;org.jadira.usertype&lt;/groupId&gt;
    &lt;artifactId&gt;usertype.core&lt;/artifactId&gt;
    &lt;version&gt;3.0.0.GA&lt;/version&gt;
&lt;/dependency&gt;
</pre></div>


<h2 class="wp-block-heading">SOLUTION</h2>



<p>Upgrade Jadira Usertype to the latest version, and the problem goes away:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; title: ; notranslate">
&lt;dependency&gt;
    &lt;groupId&gt;org.jadira.usertype&lt;/groupId&gt;
    &lt;artifactId&gt;usertype.core&lt;/artifactId&gt;
    &lt;version&gt;3.1.0.CR10&lt;/version&gt;
&lt;/dependency&gt;
</pre></div><p>The post <a rel="nofollow" href="https://myshittycode.com/2013/12/26/jadira-usertype-under-jdk-6-it-may-not-be-possible-to-handle-dst-transitions-correctly/">Jadira Usertype: Under JDK 6 it may not be possible to handle DST transitions correctly</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2013/12/26/jadira-usertype-under-jdk-6-it-may-not-be-possible-to-handle-dst-transitions-correctly/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">277</post-id>	</item>
		<item>
		<title>Hibernate + Joda Time: Auto Registering Type</title>
		<link>https://myshittycode.com/2013/12/25/hibernate-joda-time-auto-registering-type/</link>
					<comments>https://myshittycode.com/2013/12/25/hibernate-joda-time-auto-registering-type/#comments</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Thu, 26 Dec 2013 01:30:19 +0000</pubDate>
				<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Jadira]]></category>
		<category><![CDATA[Joda-Time]]></category>
		<guid isPermaLink="false">http://myshittycode.com/?p=274</guid>

					<description><![CDATA[<p>OVERVIEW Jadira Usertype is required when using Joda Time with Hibernate 4. The Joda Time objects are annotated accordingly in the Hibernate entity, and they looks something like this:- PROBLEM This solution works, but it is rather tedious because I can never remember the actual @Type to write, thus I always end up copying and [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2013/12/25/hibernate-joda-time-auto-registering-type/">Hibernate + Joda Time: Auto Registering Type</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">OVERVIEW</h2>



<p><a href="http://jadira.sourceforge.net/usertype-userguide.html" target="_blank" rel="noopener">Jadira Usertype</a> is required when using Joda Time with Hibernate 4. The Joda Time objects are annotated accordingly in the Hibernate entity, and they looks something like this:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: java; highlight: [16,20]; title: ; notranslate">
@Entity
@Table(name = &quot;person&quot;)
public class Person implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = &quot;personId&quot;)
    private Long id;

    @Column
    private String name;

    @Column
    @Type(type = &quot;org.jadira.usertype.dateandtime.joda.PersistentLocalDate&quot;)
    private LocalDate birthDate;

    @Column
    @Type(type = &quot;org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime&quot;)
    private LocalDateTime createdDatetime;

    // getters and setters
}
</pre></div>


<h2 class="wp-block-heading">PROBLEM</h2>



<p>This solution works, but it is rather tedious because I can never remember the actual <code>@Type</code> to write, thus I always end up copying and pasting it from past project code.</p>



<p>Further, that additional annotations clutter up my otherwise beautiful code.</p>



<h2 class="wp-block-heading">SOLUTION</h2>



<p>Jadira Usertype provides a clean way to auto register these Joda Time object types.</p>



<p>In the Hibernate configuration, add the following line:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: xml; highlight: [8]; title: ; notranslate">
&lt;bean id=&quot;sessionFactory&quot; class=&quot;org.springframework.orm.hibernate4.LocalSessionFactoryBean&quot;&gt;
    &lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot;/&gt;

    &lt;property name=&quot;hibernateProperties&quot;&gt;
        &lt;props&gt;
            &lt;prop key=&quot;hibernate.dialect&quot;&gt;org.hibernate.dialect.SQLServerDialect&lt;/prop&gt;
            &lt;prop key=&quot;hibernate.show_sql&quot;&gt;false&lt;/prop&gt;
            &lt;prop key=&quot;jadira.usertype.autoRegisterUserTypes&quot;&gt;true&lt;/prop&gt;
        &lt;/props&gt;
    &lt;/property&gt;
    &lt;property name=&quot;packagesToScan&quot;&gt;
        &lt;list&gt;
            &lt;value&gt;com.choonchernlim.project.entity&lt;/value&gt;
        &lt;/list&gt;
    &lt;/property&gt;
&lt;/bean&gt;
</pre></div>


<p>Now all <code>@Type</code> annotations can be safely removed from the Hibernate entity:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: java; title: ; notranslate">
@Entity
@Table(name = &quot;person&quot;)
public class Person implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = &quot;personId&quot;)
    private Long id;

    @Column
    private String name;

    @Column
    private LocalDate birthDate;

    @Column
    private LocalDateTime createdDatetime;

    // getters and setters
}
</pre></div><p>The post <a rel="nofollow" href="https://myshittycode.com/2013/12/25/hibernate-joda-time-auto-registering-type/">Hibernate + Joda Time: Auto Registering Type</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2013/12/25/hibernate-joda-time-auto-registering-type/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">274</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)
Database Caching 52/67 queries in 0.039 seconds using Disk

Served from: myshittycode.com @ 2026-02-21 10:38:14 by W3 Total Cache
-->