2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

テーブルのvarchar型をHibernateでLocalDate型としてマッピングする

Last updated at Posted at 2014-04-06

org.jadira.usertypeでhibernateのusertypeのサポートしてるのでこれを使うと楽です

@Column
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentLocalDateAsString")
private LocalDate myDate; 

中身はhibernateのEnhancedUserTypeを実装してるAbstractSingleColumnUserTypeを継承してvarcharとLocalDateをマッピングしてくれてます



package org.jadira.usertype.dateandtime.joda;

import org.jadira.usertype.dateandtime.joda.columnmapper.StringColumnLocalDateMapper;
import org.jadira.usertype.spi.shared.AbstractSingleColumnUserType;
import org.joda.time.LocalDate;

public class PersistentLocalDateAsString extends AbstractSingleColumnUserType<LocalDate, String, StringColumnLocalDateMapper> {

    private static final long serialVersionUID = -1039569606757252201L;
}
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?