You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@syncope.apache.org by "Francesco Chicchiriccò (JIRA)" <ji...@apache.org> on 2013/07/26 09:07:50 UTC

[jira] [Comment Edited] (SYNCOPE-246) Remove collection setters in transfer objects for JAXB marshalling

    [ https://issues.apache.org/jira/browse/SYNCOPE-246?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13720481#comment-13720481 ] 

Francesco Chicchiriccò edited comment on SYNCOPE-246 at 7/26/13 7:07 AM:
-------------------------------------------------------------------------

I have removed any collection setter: Jackson is fine but I have troubles because often databinders use Spring's BeanUtils.copyProperties() to copy property vales from JPA entities to transfer objects and vice versa.
Since removing collection setters breaks the JavaBean contract, Spring's (but also Commons Collections', as I could find) BeanUtils silently ignores collection properties, with serious consequences.

I will keep investigating for a while, but if I don't find any valuable alternative - e.g. not being forced to replace BeanUtils.copyProperties() with hand copying - I will just revert my local copy and close this issue as invalid.
                
      was (Author: ilgrosso):
    I have removed any collection setter: Jackson is fine but I have troubles because often databinders use Spring's BeanUtils.copyProperties() to copy property vales from JPA entities to transfer objects and vice versa.
Since removing collection setters breaks the JavaBean contract, Spring's (but also Commons Collections', as I could find) BeanUtils silently ignores collection properties, with serious consequences.

I will keep investigating for a while, but if I don't fine any valuable alternative - e.g. not being forced to replace BeanUtils.copyProperties() with hand copying - I will just revert my local copy and close this issue as invalid.
                  
> Remove collection setters in transfer objects for JAXB marshalling
> ------------------------------------------------------------------
>
>                 Key: SYNCOPE-246
>                 URL: https://issues.apache.org/jira/browse/SYNCOPE-246
>             Project: Syncope
>          Issue Type: Sub-task
>          Components: core
>    Affects Versions: 1.1.0
>         Environment: CXF branch
>            Reporter: Andrei Shakirin
>            Assignee: Francesco Chicchiriccò
>             Fix For: 1.2.0
>
>
> XML payload will be marshaled/unmarshaled using JAXB by migration to CXF Rest frontend.
> JAXB works with collections in a little bit different way as Spring Rest marshaling.
> JAXB uses only getter for the list (assumes that list is initialized due object creation) and adds elements into the list obtained by getter by unmarshaling. It doesn't need setter at all.
> The problem is that actual implementation of transfer objects doesn't work with JAXB. 
> If TO provide setter for collection, JAXB gets the list, adds the elements and additionally calls setter for this list. As far as setter logic cleans the TO collection, the result collection is always empty.
> Solution is remove setters for collections in TOs by migration on CXF Rest.
> I find it also better from security and encapsulation aspects.
> Regards,
> Andrei.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira