openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Prashant Bhat <>
Subject Re: OpenJPA Date Proxy serialization problem when using entities with GWT
Date Thu, 10 Mar 2011 17:01:32 GMT
Hi Mike,

Thanks for the reply.

Yes, on serialization all the proxies are removed, as it works with our
Swing app which has no dependency on OpenJpa jars. But GWT serialization
seems to work in a different way.

And I've tried detachCopy() and it works. But I'd like to keep existing DAOs
as they're, because entities are loaded from an abstract class which is
common to all services, so then for all queries detachCopy() would be
called. And I tried to call detachCopy()  after loading entities(only in GWT
services), but once the EM is closed, this doesn't work. Btw, I found that
EM.detachAll() throws a NPE, it seems to be a bug.

For copying the properties to DTO, I used a simple approach like this in my
GWT service implementation:
 // Load entities from DAO, using Spring Transactional(readOnly=true)
// starts an EM and is closed on return here
List<SalesOrder> salesOrderList = salesOrderDao.findSalesOrders(customer);
// convert entity to dto
List<SalesOrderDto> salesOrderDtoList = new ArrayList<SalesOrderDto>();
for(SalesOrder salesOrder : salesOrderList) {
    SalesOrderDto salesOrderDto = new SalesOrderDto();
return salesOrderDtoList;


On Thu, Mar 10, 2011 at 11:26 PM, Michael Dick <>wrote:

> Hi Prashant,
> I've been looking into the Date proxies recently. What I've found is that
> the proxies are removed if you serialize the entity or use detachCopy() (in
> this case the original entity retains the proxies and the new copy does not
> have them). I'm looking into a better solution for this use case, but the
> detachment code is pretty tangled, and it might take a little while to work
> out a safe option.
> I'm not sure why using a DTO didn't work for you. How did you copy the date
> field from your entity?
> -mike
> On Wed, Mar 9, 2011 at 9:13 PM, Prashant Bhat <>
> wrote:
> > Hi All,
> >
> > We're developing an application using OpenJpa 2.1, Spring-3.0.5 and
> > GWT-2.2.0. This integration works for all other types in the entity, but
> > fails for fields of type Date with the following exception:
> > --
> > Type
> > '$util$Date$proxy' was not included in the
> set
> > of types which can be serialized by this SerializationPolicy or its Class
> > object could not be loaded. For security purposes, this type will not be
> > serialized.: instance = Sat Dec 31 00:00:00 SGT 2011
> > --
> > I tried using DTO instead of using an entity directly, but when date
> > property is copied from Entity object to DTO, the same proxy will be set.
> > So
> > it doesn't work either.
> >
> > When searched, I found lot of references to detaching the entity to
> remove
> > all proxies needed by Jpa. It works, but this needs to be explicitly
> > called,
> > while the same works without calling this, in our Swing app which gets
> the
> > serialized objects through Spring Remoting. And also, as there're a lot
> of
> > DAOs already written, this is going to be major change.
> >
> > So, is there a openjpa configuration setting to use, so that all proxies
> > are
> > removed on em.close() ? I really appreciate any help to solve this.
> >
> > Thanks,
> > Prashant
> >

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message