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

ASF subversion and git services commented on OPENJPA-3021:
----------------------------------------------------------

Commit e9c0d5e76d845ca78e03342c1fc234ed9601417f in openjpa's branch 
refs/heads/OPENJPA-3021 from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=e9c0d5e76 ]

[OPENJPA-3021] Keep the value a converter returns instead of replacing it by a 
bean proxy


> A converted attribute value is replaced by a bean proxy that loses state 
> without a setter
> -----------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-3021
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-3021
>             Project: OpenJPA
>          Issue Type: Bug
>            Reporter: Richard Zowalla
>            Assignee: Richard Zowalla
>            Priority: Major
>
> A value of an attribute with an {{AttributeConverter}} is replaced by a 
> generated bean proxy when its declared type is not a collection, map, date or 
> calendar. The proxy is filled by calling the getters of the converted value 
> and the matching setters of the proxy. State without a setter is lost.
> Found by the Apache Syncope tests:
> {code:java}
> @Convert(converter = AuthModuleConfConverter.class)
> @Lob
> private AuthModuleConf jsonConf;   // AuthModuleConf is an interface
> {code}
> {code:java}
> public class StaticAuthModuleConf implements AuthModuleConf {
>     private String credentialCriteria;
>     private final Map<String, String> users = new HashMap<>();   // getter 
> only
>     ...
> }
> {code}
> The converter returns a {{StaticAuthModuleConf}} with the users from the 
> column. The entity returns a {{StaticAuthModuleConf$proxy}} whose {{users}} 
> map is empty.
> Cause: {{SingleFieldManager.proxy()}} calls {{ProxyManager.newCustomProxy()}} 
> for every {{JavaTypes.OBJECT}} field, also when the field has a converter. 
> {{ProxyManagerImpl}} generates a subclass of the value's class and copies the 
> value through its getter and setter pairs (or a copy constructor).
> A converted value is opaque to the provider and should be kept as the 
> converter returned it. Since the proxy is also what marks the field dirty 
> when a setter of the value is called, change detection for such fields has to 
> come from comparing the converted value at flush, as OPENJPA-3019 does for 
> collections and maps converted as a whole.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to