Jump to content
Changes to the Jaspersoft community edition download ×

cant display null Boolean values from db


samzilverberg

Recommended Posts

Hi all

Some background info:

My report gets its data from a mysql server using a simple sql query embedded in the jrxml.
One of the fields is a Boolean field (field class = Boolean).
In the mysql db the field is defined as bit(1) and null values are allowed (and used!).

The problem:

In my report I want to display the value for this field and I want to use custom values for true/false/null.

So I created a textfield with expression class String and a simple expression:

($F{b}!=null):($F{b}.booleanValue()?"yes":"no"):"n/a"

I never see N/A printed although I triple checked and the value in the db is null.

I tried all kinds of work arounds using different expressions with no luck.
Finally I decided to neglect costum values.
I changed the textfield expression class to Boolean and use the most simple expression $F{b}
and still no null are displayed even though there are some null values.

Blank when null is not checked for this textfield.

What can I do?
Why is jasper reports populating my Boolean field with false when it should be null?

 

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I solved this by changing the field type to string and using textfield expression:

($F{b}!=null)?($F{b}.equals("1")?"Yes":"No"):"N/A"

 

The conversion of the db value to string preserves the null value as string, unlike the conversion to Boolean that converts it to Boolean.FALSE.



Post Edited by samzilverberg at 09/16/2010 11:46
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...