[jboss-user] [EJB/JBoss] - CMR fileds available after raw SQL delete of related records

jivkoto do-not-reply at jboss.com
Tue Oct 10 10:29:37 EDT 2006


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
  | }

If anyone can help to tell is it bug or I am doing wrong that I am using direct SQL to delete records. 10x



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3977257#3977257

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3977257



More information about the jboss-user mailing list