How can I insert and update in 2 tables using EJB?? For example, after inserting a row in table of employee (a new employee) , I want to update a table of company (the field "number of employees" will be added 1). I am using session bean and entity bean but it seens that each entity bean is related with only one table. Is there some pattern for this case???
Ken, Although I saw no mention of it in your post, I assume you are using CMP entity beans. Usually, you can only create CMP entity beans for a single table -- as you seem to have discovered. In my opinion, you have two choices:
BMP entity beans
I believe the second option is only possible when there is a foreign-key relationship between the tables -- in your case I presume the relevant tables are the EMPLOYEE and COMPANY tables. Also the second option -- CMRs (Container Managed Relationships) -- was introduced in version 2.0 of the EJB specification. Again, I saw no mention in your post regarding which EJB container you are using -- nor which EJB version it supports -- so I'll just suggest that you do some research on the two topics I've listed above. By the way, do people give you a hard time because your name is Kenny Rogers (like the singer) ? Good Luck, Avi.