db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lars Clausen ...@statsbiblioteket.dk>
Subject Re: Derby with beans and null primitives
Date Wed, 30 Nov 2005 08:57:10 GMT
On Wed, 2005-11-30 at 06:28, Michael McCutcheon wrote:
> I'm implementing a utility class that populates 'beans' with data from 
> tables in derby.  Suppose I have the following 'bean':
> 
> public class Person
> {
>   private String firstName;
>   private String lastName;
>   private int weight;
>  
>   public void setWeight(int inWeight)
>   {
>     this.weight = inWeight;
>   }
>   public int getWeight()
>   {
>     return this.weight;
>   }
> }
> 
> I select out of a Person table to get the information to populate this bean.
> 
> But what happens if weight is nullable in the table?
> 
> Since you can't put nulls into primitives in Java, how is this handled? 
> 
> This is a real problem because 0 is definately different than no value.
> 
> Also is there some standard for how JSP's deal with beans with primitive 
> types?
> 
> How should null primitives be handled in beans like this?

In Java 1.5, you could declare weight as an Integer and make use of the
autoboxing feature.  Don't know how that interacts with beans, though.

-Lars


Mime
View raw message