peichhorn / lombok-pg

Collection of lombok extensions
http://peichhorn.github.com/lombok-pg/
Other
326 stars 44 forks source link

Add transient keyword for property and veto support generation locks #121

Open MiguelGL opened 11 years ago

MiguelGL commented 11 years ago

Hi, the lock Object[]'s used to synchronize the generation of property change and veto supports are not transient. This leads to problems when using, for example, JPA + Hibernate + field access: the ORM complains about having multiple mapped $propertyChange... etc. fields.

I made a tests-passing simple patch to add the transient keyword and hence request you honor me pulling it.

Of course, contact me for any issue, and thanks again for your great lombok extensions!!

travisbot commented 11 years ago

This pull request passes (merged 8d7f4f41 into 85f19e60).

peichhorn commented 11 years ago

Hi there Miguel,

First let me say, thank you for your interest in this project. I believe that this is the first pull-request for lombok-pg, so.. yay.

Now the bad news.. ;) The issue with this patch is, that the lock Object[]'s would be null after regular serialization and deserialization, which defeats the purpose of having them in the first place. Of cause one could argue, that the creation of the PropertyChangeSupport and VetoableChangeSupport doesn't have to be tread-safe in all cases, which would render the lock Object[]'s obsolete. I will create a small example to see what can be done in this scenario. Of cause, I you have a small example laying around, you could save me some time. ;)

peichhorn commented 11 years ago

I think it would be possible to look for the presence of the @Entitiy annotation and add @Transient to the lock fields.

MiguelGL commented 11 years ago

Mhhh, yes, I did not check the (de-)serialization issues. I will try to build some test case for that.

Your suggestion on adding the @Transient annotation seems good, too. Though may turn out a little restrictive: similar issues could arise for other annotations, for example JAXB-related: in those cases @XmlTransient annotations are required (when using @XmlAccessorType(XmlAccessType.FIELD), not @XmlTransient. Have not tried this, though.