This is a discussion on write-only entity beans with no primary key, OR using ejb and jdbc in 1 transaction - Weblogic ; My app (running on Weblogic 6.1) maintains a database table that serves as a log of all activity in the app. The log entries are written to the database by the app but are never read back from the database. ...
My app (running on Weblogic 6.1) maintains a database table that
serves as a log of all activity in the app. The log entries are
written to the database by the app but are never read back from the
Currently the log object is implemented as a CMP entity bean. We have
an extra column on the log table that is used as the primary key. The
primary key is only there because EJB seems to require it.
Conceptually, the log objects have no meaningful primary key.
The problem is that performance is slow, because each time we create a
new log object in the database, we have to do a read from the database
to get the primary key and then write the log row to the database.
Ideally we would just be doing the write without the read.
I can think of 2 possible approaches, but I'm not sure how to
implement either of them...
Approach #1: Is it possible to have a write-only entity bean? Such an
object would need no primary key, since there would be no
Approach #2: Don't use an entuty bean at all, and jusy se jdbc to
insert rows directly into the log table. The problem here is that I
would want these jdbc calls to be using the same transaction that the
EJBs are using. If I have a sesson bean method that uses both entity
beans and jdbc calls, how do I get the jdbc calls to use the same
transaction that the session bean and entity beans are using?