java - Empty/Null values from post request are getting assigned to 0 -


<student> <id>1</id> <badge></badge> <name>matt</name> </student> 

this xml post when observe during post.

public class student implements serializable{  long id; integer badge; string name; } 

my web service :

    @path("add")     @post     @consumes({mediatype.xml,mediatype.json})     @produces({mediatype.xml,mediatype.json})     public response add(student student)     {     } 

when debug on add method on service layer , variable badge gets assigned value "0", though not provided gui.database field badge integer(postgres).

is related integer variable, assigns default value 0 if not present ?

the type integer reference type. when create instance of class variable of reference type, it's default value null. behavior seeing not java's.

jersey uses jaxb marshall , unmarshall entities. when sees have badge field has empty text element must make decision proper value set is. doesn't make sense give null since there element there. decides initialize 0.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -