-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: how to map java boolean field to sql char(1) .
PostPosted: Fri Mar 16, 2007 2:23 am 
Newbie

Joined: Tue Feb 27, 2007 9:18 am
Posts: 7
hi,
i have written like this

<property name="baseCurrency" type="yes_no" column="BASE_CURRENCY" not-null="false" />

in java public boolean baseCurrency;

in sql
BASE_CURRENCY char(1) .

here BASE_CURRENCY value is 'Y' or 'N'. but the field is not having null constarint. so there might be chance of having null value.

how can i solve the problem if there is null value.

hiberante set the property of either yes or no value.
if null value is there in table. it raised setter property field exception..

thanks
naveen.m


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 16, 2007 2:31 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi naveen

use Boolean instead of boolean. and change your code accordingly

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject: thanq
PostPosted: Fri Mar 16, 2007 2:40 am 
Newbie

Joined: Tue Feb 27, 2007 9:18 am
Posts: 7
ya it's working fine. thanq very much


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 17, 2007 10:51 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
hi naveen
Plz.. give credits for that

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject: How Boolean object can insert in sql
PostPosted: Fri Mar 30, 2007 7:51 am 
Newbie

Joined: Tue Feb 27, 2007 9:18 am
Posts: 7
Hi
i have written like this in hbm.xml file

<property name="baseCurrency" type="yes_no" column="BASE_CURRENCY" not-null="true" />

in java class thre is setter and getter properties

java code:

private Boolean baseCurrency = null;

public void setBaseCurrency(Boolean baseCurrency){
this.baseCurrency = baseCurrency;
}


public Boolean getBaseCurrency(){
return baseCurrency
}

when i have insert an object into sql. the baseCurrency value is blank.

could you please suggest sutable solution


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.