Enhanced versions of classes lose annotations in original classes
-----------------------------------------------------------------

                 Key: OPENJPA-1428
                 URL: https://issues.apache.org/jira/browse/OPENJPA-1428
             Project: OpenJPA
          Issue Type: Bug
          Components: jpa
    Affects Versions: 1.2.1
            Reporter: David M. Karr
            Priority: Minor


I am attempting to construct an application using OpenJPA and CXF such that the 
domain classes that OpenJPA maps the database to are the same beans that CXF is 
using to serialize XML/JSON results through JAXB/Jackson.  I'm using the 
logical JPA annotations along with physical settings in the orm.xml.  I'm also 
using JAXB annotations to specify how the class will be serialized.

In order for that serialization to work, the objects being created by OpenJPA 
have to have the JAXB annotations that I've put on the class. If I just 
manually create an instance of that class and serialize it, it works fine. 
However, I've discovered that if I use the object instance that I got from JPA, 
it doesn't serialize. CXF complains that it can't find a "message body writer" 
for the class of the instance. When I looked deeper, I discovered that the 
class annotations that I put on the class to control its serialization are not 
present on the class of the instance I got back from OpenJPA.

I implemented a straightforward workaround that simply creates an instance of 
my class and uses "BeanUtils.copyProperties()" to copy from the OpenJPA-created 
instance to my manually created instance. I then serialize that. It works fine. 
I'd prefer not to have this workaround, as I was trying to avoid the step of 
copying the properties of the OpenJPA instance to a serializable instance.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to