CMP EJBs and JDBC
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Litsa_Kir
Posted On:   Monday, August 18, 2003 02:21 PM

OK I don't mean to be a pest, but either I'm stupid, or I should have chosen an easier project In the case of cmp ejbs the code of the servlet is as follows: SessionManagerHome sessionMgrs; SessionManager sessionCounter; try { sessionCounter = sessionMgrs.findByPrimaryKey(sessionId); } catch (FinderException fE) { sessionCounter = sessionMgrs.create(sessionId); } In the case of plain JDBC try { sessionCount = db.read(requestedSessionId) + 1L; db.update(requestedSessionId, sessionCount); } catch (Exception e) { sessionCount = 1L; db.create(requestedSessio   More>>

OK I don't mean to be a pest, but either I'm stupid, or I should have chosen an easier project

In the case of cmp ejbs the code of the servlet is as follows:



SessionManagerHome sessionMgrs;

SessionManager sessionCounter;


try {

sessionCounter = sessionMgrs.findByPrimaryKey(sessionId);

} catch (FinderException fE) {

sessionCounter = sessionMgrs.create(sessionId);

}


In the case of plain JDBC



try {
sessionCount = db.read(requestedSessionId) + 1L;

db.update(requestedSessionId, sessionCount);

} catch (Exception e) {
sessionCount = 1L;

db.create(requestedSessionId, sessionCount);

}



In the first case, there should be 2 database accesses, one for the finder method of the home object and one for the entity bean returned by the query.

In the second case there is just one database access.

Is this right, or should I kill myself and get it over with?

   <<Less

Re: CMP EJBs and JDBC

Posted By:   Christopher_Koenigsberg  
Posted On:   Monday, August 18, 2003 02:50 PM

See the interesting answers and links to further reading (re the "N+1" problem etc.) you got, in your other duplicated posting thread -- (http://www.jguru.com/forums/view.jsp?EID=1108995).

About | Sitemap | Contact