users@jersey.java.net

Re: [Jersey] Can anyone explain what this is supposed to be doing?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 23 Jan 2009 11:05:32 +0100

Hi Eric,

I do not know enough about JPA to help you. I have forwarded the
email to the NetBeans engineer who might have some clues.

Paul.


On Jan 22, 2009, at 10:39 PM, Marsh Eric wrote:

> This code is from an entity bean generated in netbeans. In the last
> for loop the code is broken. Anyone have any idea what it should be
> doing, or better yet how I should approach fixing it?
>
> /**
> * Persist the given entity.
> *
> * @param entity the entity to persist
> */
> protected void createEntity(People entity) {
> EntityManager em = PersistenceService.getInstance
> ().getEntityManager();
> em.persist(entity);
> for (People value : entity.getPeopleCollection()) {
> value.getPeopleCollection().add(entity);
> }
> for (People value : entity.getPeopleCollection1()) {
> value.getPeopleCollection().add(entity);
> }
> for (Mylocation value : entity.getMylocationCollection()) {
> value.getPeopleCollection().add(entity);
> }
> for (Mylocation value : entity.getMylocationCollection1()) {
> People oldEntity = value.getPeopleCollection(); //
> attempts to assign a collection to a single entity
> value.setPeopleCollection(entity); // here it's
> trying to assign a single entity where a collection is expected
> if (oldEntity != null) {
> oldEntity.getMylocationCollection1().remove(entity);
> }
> }
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>