Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Struts - A MVC web framework
Tomcat - JSP/Servlet container
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
JSP - A mailing list about Java Server Pages specification and reference
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
Data in join table apart from the foreign keys using EJB2.0

Data in join table apart from the foreign keys using EJB2.0

2004-02-17       - By Vijith

 Back
Reply:     1     2  

Hi All,

I have a scenario like this
-- ---- ---- ---- ---- ------

TableA (col1 PK)

TableB (col2 PK)

TableC (col1 , col2, col3)
-- ---- ---- ---- ---- ------
(Col1 + col2) composite PK
Col1 is FK(TableA)
Col2 is FK(TableB)
Col3 is a normal column

-- ---- ---- ---- ---- ---- ---- ---

Now I have designed the EJB like this

EJB1 (Entity Object for TableA)
EJB2 (Entity Object for TableB)

There is a many - many relationship between EJB1 and EJB2 with TableC as
join table.

I'm following the SessionFacade pattern. In the Session Bean , I create
the entity for EJB1 and create the Entity for EJB2. In the CMR setter of
EJB1, i associate the EJB2,(though after adding it to a collection),
which populates data to TableC.

In this way, the data is inserted into TableA, TableB and TableC like

Table A
-- ----
col1
----
1

TableB
-- ---
col2
----
1

TableC
-- ---
col1 col2 col3
-- ---- ---- ------
1 1 null

My requirement here is to insert data to col3 in the same transaction ie
the data should get populated in the same transaction that inserts data
into col1 and col2 of TableC.If the validation for col3 fails, all
inserts should be rolled back.

I tried this appraoch. I created EJB3 which maps to TableC and performed
the following steps.

Steps
-- --
1) In session bean, create EJB1 and get the reference to
   the EJB1object
2) In session bean, create EJB2 and get the reference to
  the EJB2object
3) create new vector with EJB2object as an element.
4) On EJB1object , call setCMREJB2(vector);
(The above series of steps inserts data in all the table except for col3
in TableC)
5) Try to get the handle for the EJBObject for table3
  using findByPK(new PK(col1, col2))
6) But this fails as the previous transaction is not
  commited and findByPK fails. So Im not able to call
  setter for col3 in EJB3.

Any suggestions :-)

Thanks
Vijith

===========================================================================
To unsubscribe, send email to listserv@(protected) and include in the body
of the message "signoff J2EE-INTEREST".  For general help, send email to
listserv@(protected) and include in the body of the message "help".



©2008 junlu.com - Jax Systems, LLC, U.S.A.