Hi I have problem with Conteiner Managed Relation.
Environment: JBoss 4.0.4.GA, JDK 1.5.0_07 on WindowsXP + SP2, SQL SERVER 2000
I have two EJBs A and B with container managed bidirectional relation (one ? many). I am using direct SQL to delete the records for B related with one of A?s instances.
Later when I call a.getBs(), returned collection is not empty, even if the entities are removed.
If I get B?s home interface and make b.findByA(PK) the returned collection is empty.
It seems that the relation is not updated.
Here is a simple snippet.
//This is in Entity A. public boolean hasInstances() { Collection coll = null; try { BHomeLocal processHome = ? //perform lookup here coll = processHome.findByAid(getId()); } catch (NamingException e) { e.printStackTrace(); } catch (FinderException e) { e.printStackTrace(); } //Note coll is empty. No B entities found Collection bCollection = getBs(); //CMR of A return (!bCollection.isEmpty()); //Note that it returns false, and bCollection contains the ids of the //removed B instancess }