Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entityunit tries to use field names as property names #4

Open
seanf opened this issue Jan 21, 2017 · 1 comment
Open

Entityunit tries to use field names as property names #4

seanf opened this issue Jan 21, 2017 · 1 comment

Comments

@seanf
Copy link
Contributor

seanf commented Jan 21, 2017

The method BeanMaker.trySetValue() calls BeanUtils.setProperty if the JPA AccessType is PROPERTY, but it uses a field name instead of a property name. To make things worse, it seems that org.apache.commons.beanutils.BeanUtils.setProperty() fails silently if the requested property doesn't exist. This leaves the entity property with its default value, instead of setting the requested value.

This interacts badly with Kotlin's approach to interop for boolean properties - a Boolean Kotlin property named isActive will be exposed with the getter isActive() and the setter setActive() (thus the JavaBean property name is active), but the backing field is named isActive, not active. This is perfectly valid for JavaBeans, and would not be a problem, except that entityunit tries to access the JavaBean property (active) using the field name (isActive).

@seanf
Copy link
Contributor Author

seanf commented Jan 21, 2017

I noticed that entityunit also had trouble finding the specified values for constructor parameters when first building the entity. Since every JPA entity or JavaBean should have a zero-param constructor, it's probably safer to use it and then fill in all the fields/properties (since they have names; constructor parameters generally haven't, unless you use @java.beans.ConstructorProperties).

seanf added a commit to zanata/zanata-platform that referenced this issue Jan 21, 2017
seanf added a commit to zanata/zanata-platform that referenced this issue Jan 21, 2017
seanf added a commit to zanata/zanata-platform that referenced this issue Feb 14, 2017
seanf added a commit to zanata/zanata-platform that referenced this issue Feb 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant