Fornax-Platform
Forum

valueobject collection private

View: New views
3 Messages — Rating Filter:   Alert me  

valueobject collection private

by saadkhawaja :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi
I have a ValueObject and a collection on it like so.
ValueObject MyValueObject {
   !immutable
   List<Person> persons changeable
}

The code generated makes the setter for this collection private. I would like it to be public, why, because of bean copying utilities.
Do I need to do something else to make that setter public.
Thanks
Saad

Re: valueobject collection private

by Patrik Nordwall :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The collection is managed by hibernate and you are not allowed to change the collection instance.

I would add a setter in the hand written subclass like this:
    public void setPersons(List<Person> persons) {
        getPersons().clear();
        getPersons().addAll(persons);
    }

/Patrik


saadkhawaja wrote:
Hi
I have a ValueObject and a collection on it like so.
ValueObject MyValueObject {
   !immutable
   List<Person> persons changeable
}

The code generated makes the setter for this collection private. I would like it to be public, why, because of bean copying utilities.
Do I need to do something else to make that setter public.
Thanks
Saad

Re: valueobject collection private

by Patrik Nordwall :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

... or if you would like to generate that for all, then you add this snippet to your src/main/resources/templates/SpecialCases.xpt

«AROUND templates::DomainObject::manyReferenceSetter FOR Reference»
    public void set«name.toFirstUpper()»(«getCollectionInterfaceType()»<«getTypeName()»> «name») {
        this.«name».clear();
        this.«name».addAll(«name»);
    }
«ENDAROUND»