'non mandatory Fk' means the relationship does not exist when there is no value in the Fk column. It is the first time I've heard someone using -1 to represent a null!!! I take it you're integrating with a existing DB that has been used like that? Otherwise I cannot imagine someone using -1 provided the Fk is null-able.
You can either map the Fk as CMP field and do a manual get method which would be very ugly, but might just work. Or use null to represent what really is a null.
you are right, I'm integrating with an existing database where "null" relationships are represented with an id set to -1 (valid id values are >= 0).
I was just wondering why JBoss was rollbacking the current transaction when it couldn't find the related object ! It doesn't give you any chance to recover from that kind of problem...
Anyway, converting the database to set the field 'nullable' and set a 'null' value where -1 is found would solve the problem...
Thanks taking time answering...
It does depend on your transaction boundaries and code implementation. If you're catching the NoSuchEntity exception and make it carry on in your code, sure, JBoss won't roll back. Or you'll have to decide where to put your set transaction in the descriptors depending on
a) where the transaction was started (session bean?)
b) should that method support transaction at all?
c) or simply try catch finderExp, instanceof NoSuchEntity and say you're ok to carry on without finding something in your code.