In my database, i have column like
"ISDEFAULTPAYMENTFORCURRENCY" CHAR(1 BYTE) NOT NULL ENABLE,
CHECK (ISDEFAULTPAYMENTFORCURRENCY IN ('N','Y')) ENABLE,
In my bean, i have
private Boolean isDefaultPaymentForCurrency;
my question, how can i map this isDefaultPaymentForCurrency
in hibernate hbm file?
<property name="isDefaultPaymentForCurrency" type="???" column="ISDEFAULTPAYMENTFORCURRENCY" not-null="true"/>
Use
<property name="isDefaultPaymentForCurrency" type="yes_no" column="ISDEFAULTPAYMENTFORCURRENCY" not-null="true"/>
And to use hql you can set this property in hibernate.cfg
<property name="hibernate.query.substitutions">true 'Y', false 'N'</property>
Type mappings from Java primitives or wrapper classes to appropriate (vendor-specific) SQL
column types. boolean
, yes_no
, and true_false
are all alternative encodings for a Java boolean or java.lang.Boolean
.
http://docs.jboss.org/hibernate/stable/core.old/reference/en/html/mapping-types.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With