문제

I have Class CustomDate and that is referred in other class called Test.

public   class CustomDate{
    public String toString(){
       return "20100829"
    }
}
public class Test{
    CustomDate date;
}

In Mapping file of Test

<property name="date" COLUMN="DATE">

I want to save only long value and type should be long type and i should not save date object and string value.long value will be this like:"20100829" actual date:29-08-2010. Because in feature if want compare dates in sql it may create problem, if it is long value, sql compare queries will fine. Do we have any way do it in Hibernate?

도움이 되었습니까?

해결책

You'll have to implement the UserType interface, and define the behavior of your new type.

<property name="twoStrings" type="com.company.CustomDate" />

Resources :

Related posts :

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top