You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nick Broadhurst <ho...@gmail.com> on 2011/03/22 00:16:24 UTC

JPA Collection Update on Post

Hi Guys,

JPA background:

I have a Demographics entity that has as one of its properties a Collection
of MedicalRecordsReceived entities. Each MedicalRecordsRecieved entity has
as one of its properties a Demographic object.

OK, When I pull the Demo entity and display in page using s:iterator to
display all MedicalRecordsReceived entities, everything displays fine. My
problem is that on post back to my Action for update, the
MedicalRecordsReceived collection in the Demographics object is now null.

I have lots of situations similar to this where an entity contains an entity
(one-to-one) and don't have any problems with the child posting back also
and updating fine. So do I need to do something different on this
one-to-many situation? If this is a JPA thing then pardon my faux pas. I
don't think it is though, my model is not exhibiting any issues. I think I
am not doing something right in my page with all the entity properties.

Any thoughts? Thanks.

Nick

Re: JPA Collection Update on Post

Posted by Maurizio Cucchiara <ma...@gmail.com>.
Have you noticed any errors? You should see something like
LazyInitializationException.

Maurizio Cucchiara

Il giorno 22/mar/2011 00.16, "Nick Broadhurst" <ho...@gmail.com> ha
scritto:
Hi Guys,

JPA background:

I have a Demographics entity that has as one of its properties a Collection
of MedicalRecordsReceived entities. Each MedicalRecordsRecieved entity has
as one of its properties a Demographic object.

OK, When I pull the Demo entity and display in page using s:iterator to
display all MedicalRecordsReceived entities, everything displays fine. My
problem is that on post back to my Action for update, the
MedicalRecordsReceived collection in the Demographics object is now null.

I have lots of situations similar to this where an entity contains an entity
(one-to-one) and don't have any problems with the child posting back also
and updating fine. So do I need to do something different on this
one-to-many situation? If this is a JPA thing then pardon my faux pas. I
don't think it is though, my model is not exhibiting any issues. I think I
am not doing something right in my page with all the entity properties.

Any thoughts? Thanks.

Nick