-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: one-to-many and rmi creates net.sf.hibernate.PropertyValueEx
PostPosted: Wed Jun 23, 2004 4:14 pm 
Newbie

Joined: Fri May 07, 2004 2:18 am
Posts: 19
Hello

I have been trying to figure this out for a while

I have 2 objects
here are relevant snippets

Party implements Externalizable
private List phones = null;

/**
* @hibernate.bag name="phones" cascade="all-delete-orphan"
*
*@hibernate.collection-key column="id"
* @hibernate.collection-one-to-many class="org.marcus.Phone"
*/
public java.util.List getPhones() {
return phones;
}


public void setPhones(java.util.List phones) {
this.phones = phones;
}

Phone implements Externalizable
private Party party;

/**
* @hibernate.many-to-one column="id" cascade="none"
*
*/
public org.marcus.Party getParty() {
return party;
}

Everything works fine if the objects are not sent to another tier through rmi
I can do this
Phone phone = new Phone();
party.getPhones.add(phone);

try{
Session session = HibernateUtil.currentSession();
Transaction tx= session.beginTransaction();
session.saveOrUpdate(party);
// System.out.println("Saving or updating " + entity);
session.flush();
tx.commit();
HibernateUtil.closeSession();
}catch(Exception ee){
System.out.println(ee);
}

everything works fine
if I go through rmi (assume the the objects are sent out through rmi and then fiddled with and returned to the server)
the first time I tru to save party I get this error
net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: org.marcus.Name.party
the second time I get this error
net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: org.marcus.Name.party
net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: 1069, of class: org.marcus.Party

The errors occur regardless of whether I alter the objects or not.
I have also tried this right before trying to save party thinking maybe hibernate got confused and assumed party and phone.getParty referred to different things
if(entity instanceof Party){
System.out.println("doing party");
Party party = (Party)entity;
Party newparty = (Party)getEntity(entity, null);
Iterator i = party.getPhones().iterator();
while(i.hasNext()){
Phone phone = (Phone)i.next();
phone.setParty(newparty);
}
}

getEntity is basically a function that retrieves stuff from the database

Marcus


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.