Hi all!
Can't you modify a N-1 CMP relation by assigning the 1-end
to the single value field on the N-end? At least it
seems to create some problems, namely the N-side object
is found two times in the 1-side Collection if accessed
inside the same transaction that the relation was set up in.
Suppose we have two CMP entity beans: First and Second, having
a 1-N relation so that we have:
Collection FirstLocal.get/setSeconds()
FirstLocal SecondLocal.get/setFirst()
Now, I'm doing this:
transaction.begin();
first = firstLocalHome.create();
second = secondLocalHome.create();
second.setFirst(first);
hits = first.getSeconds();
i = hits.iterator();
while(i.hasNext()) {
SecondLocal temp = (SecondLocal)i.next();
debugOutput(temp.getId());
}
transaction.commit();
...and I get the "second" object listed twice.
This works:
transaction.begin();
first = firstLocalHome.create();
second = secondLocalHome.create();
second.setFirst(first);
// starting a new transaction
transaction.commit();
transaction.begin();
hits = first.getSeconds();
i = hits.iterator();
while(i.hasNext()) {
SecondLocal temp = (SecondLocal)i.next();
debugOutput(temp.getId());
}
transaction.commit();
And so does this:
transaction.begin();
first = firstLocalHome.create();
second = secondLocalHome.create();
// setting up relation on 1-side
first.getSeconds().add(second);
hits = first.getSeconds();
i = hits.iterator();
while(i.hasNext()) {
SecondLocal temp = (SecondLocal)i.next();
debugOutput(temp.getId());
}
transaction.commit();
The strange thing is, that EJB 2.0 specification
doesn't seem to say anything about this N-side
setting issue that I'm doing. Or is it just that
I didn't find it?
Panu
--
Panu H�llfors, [EMAIL PROTECTED]|CS Student, Helsinki University of Technology
http://panu.hallfors.com | Chief Software Architect, Viloke Oy
-------------------------------------------------------
This SF.NET email is sponsored by: FREE SSL Guide from Thawte
are you planning your Web Server Security? Click here to get a FREE
Thawte SSL guide and find the answers to all your SSL security issues.
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user