I could switch to field access, but I guess that I was looking at it
wrong. I have the annotations on the getters because I thought that
was the way to get jpa to use the getters/setters. I will read up on
field vs. property access.

Thanks for the pointers guys!

-Wes

On Fri, Apr 30, 2010 at 1:12 PM, Craig L Russell
<[email protected]> wrote:
> Hi,
>
> If you're going to play with the values in the get/set methods, then I
> strongly encourage you to use persistent fields, and not persistent
> properties.
>
> Guaranteed to work. Money back if not satisfied.
>
> Craig
>
> On Apr 30, 2010, at 8:06 AM, Wes Wannemacher wrote:
>
>> Guys,
>>
>> I have an entity that I decided to munge up a little bit... So,
>> normally, a setter would be coded like this -
>>
>> public void setFoo(String foo) {
>>   this.foo = foo;
>> }
>>
>> But, we decided to try to uppercase everything before it goes into the
>> database. Now the relevant section of code looks like this -
>>
>> [code]
>> private String foo;
>>
>> @Column(length=32)
>> public String getFoo() {
>>   return foo;
>> }
>>
>> public void setFoo(String foo) {
>>   this.foo = (foo == null ? null : foo.toUppsercase()) ;
>> }
>> [/code]
>>
>> Our build process enhances the entities (using the ant task which
>> maven calls during the process-classes phase). Then, it unit tests
>> them, and right away, every entity that we tried to do this with
>> bombed out. There was an NPE in pcsetEntityName. The relevant portion
>> of the stack trace is below -
>>
>> Caused by: java.lang.NullPointerException
>> at
>> com.cdotech.amarg.entities.CDO_CageCode.pcsetCageCode(CDO_CageCode.java:55)
>> at
>> com.cdotech.amarg.entities.CDO_CageCode.pcClearFields(CDO_CageCode.java)
>> at
>> com.cdotech.amarg.entities.CDO_CageCode.pcNewInstance(CDO_CageCode.java)
>> at
>> org.apache.openjpa.kernel.SaveFieldManager.saveField(SaveFieldManager.java:132)
>> at org.apache.openjpa.kernel.StateManag
>>
>> I tried to look through the PCEnhancer, but I'm not familiar enough to
>> be effective figuring out the problem. At the same time, since the NPE
>> happens in the generated byte-code, it's *really* hard to figure out
>> what's going on. I'd like to provide more information, but this is as
>> much as I can see.
>>
>> For right now, we moved the capitalizing logic out of the entity, but
>> was wondering if there is a way to move it back to the entity...
>>
>> -Wes
>>
>> --
>> Wes Wannemacher
>>
>> Head Engineer, WanTii, Inc.
>> Need Training? Struts, Spring, Maven, Tomcat...
>> Ask me for a quote!
>
> Craig L Russell
> Architect, Oracle
> http://db.apache.org/jdo
> 408 276-5638 mailto:[email protected]
> P.S. A good JDO? O, Gasp!
>
>



-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

Reply via email to