You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Hugi Thordarson <hu...@karlmenn.is> on 2016/04/15 00:34:04 UTC

For those of us who want getters without the get-prefix (e.g. EOF fugitives)

Hi all,
if you’d like to drop the “get"-prefix from your DataObject accessor methods, here’s a pom-file and a template to help. The pom/template combination generates a BeanInfo class for each entity that java reads to check the names of getter and setter methods. If you use this, Cayenne will function perfectly with getter methods that don’t include the “get”-prefix.
I included the wosuperclass-template which generate EOF style DataObject classes, just to make the example complete.

https://gist.github.com/hugith/377ed698b6966d25bcd65ccd9970aa7c

- hugi

Re: For those of us who want getters without the get-prefix (e.g. EOF fugitives)

Posted by Hugi Thordarson <hu...@karlmenn.is>.
Whoa, yes—that’s true. I haven’t hit the issue, probably because I’m using WO which uses Apple’s KVC rather than beanystuff to access and modify object data. And I believe Cayenne is using the correct methods to access bean data in some cases, since creating BeanInfo classes eliminated errors I was previously encountering (eg. when sorting lists of DataObjects).

But yes, as you point out, PropertyUtils.getProperty() fails for all of my properties since BeanAccessor hardcodes the get-prefix. We should probably fix Cayenne to comply with the JavaBeans spec in this regard.

- hugi



> On 17. apr. 2016, at 17:00, David Feshbach <dj...@gmail.com> wrote:
> 
> I think that will break PropertyUtils/BeanAccessor. BeanAccessor uses
> JavaBeans naming conventions but doesn't look at BeanInfo.
> 
> On Thu, Apr 14, 2016 at 5:34 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
> 
>> Hi all,
>> if you’d like to drop the “get"-prefix from your DataObject accessor
>> methods, here’s a pom-file and a template to help. The pom/template
>> combination generates a BeanInfo class for each entity that java reads to
>> check the names of getter and setter methods. If you use this, Cayenne will
>> function perfectly with getter methods that don’t include the “get”-prefix.
>> I included the wosuperclass-template which generate EOF style DataObject
>> classes, just to make the example complete.
>> 
>> https://gist.github.com/hugith/377ed698b6966d25bcd65ccd9970aa7c
>> 
>> - hugi


Re: For those of us who want getters without the get-prefix (e.g. EOF fugitives)

Posted by David Feshbach <dj...@gmail.com>.
I think that will break PropertyUtils/BeanAccessor. BeanAccessor uses
JavaBeans naming conventions but doesn't look at BeanInfo.

On Thu, Apr 14, 2016 at 5:34 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:

> Hi all,
> if you’d like to drop the “get"-prefix from your DataObject accessor
> methods, here’s a pom-file and a template to help. The pom/template
> combination generates a BeanInfo class for each entity that java reads to
> check the names of getter and setter methods. If you use this, Cayenne will
> function perfectly with getter methods that don’t include the “get”-prefix.
> I included the wosuperclass-template which generate EOF style DataObject
> classes, just to make the example complete.
>
> https://gist.github.com/hugith/377ed698b6966d25bcd65ccd9970aa7c
>
> - hugi