Issue Details (XML | Word | Printable)

Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: hyperjaxb2-issues
Reporter: lexi
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

Use checking property accessors

Created: 12/Jan/06 02:20 AM   Updated: 12/Jan/06 02:20 AM
Component/s: www
Affects Version/s: current
Fix Version/s: milestone 1

Time Tracking:
Not Specified


Operating System: All
Platform: All

Issuezilla Id: 2
Participants: hyperjaxb2-issues and lexi

 Description  « Hide

> I have some optional (minOccurs=0) numeric fields that i'd like stored as
> null when they don't exist. I see the generated POJOs have "has_<name>"
> booleans which are set & used by unmarshall & marshall. Is there a way to
> have hibernate use these? (It currently stores 0 for missing ones.)
> (are those booleans a standard part of JAXB, or jaxbcommons extensions, or
> HJ2?)

They are generated if you generate "isSetXXX" methods, this is standard JAXB

Yes, there is a way to do that and I'm planning to do this. The trick is called
"property accessors". For every property you cant define a class that will be
used to access this property by it's name. I've implemented
org.jvnet.hyperjaxb2.runtime.hibernate.accessor.CheckingPropertyAccessor that
checks isSetXXX methods when returning the values (if isSetXXX returns false,
getter will return null) and setting them (if value to be set is null, unsetXXX
method will be called instead of the setter).
I only have to update the mapping strategies and test it once again, so it will
soon be available.

There are no comments yet on this issue.