This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes how to delete database records in cmp? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "how to delete database records in cmp? " Watch "how to delete database records in cmp? " New topic

how to delete database records in cmp?

Mike Lin
Ranch Hand

Joined: Oct 29, 2002
Posts: 48
How can I delete or update records in CMP .
EJB-QL just able to 'SELECT' OBJECT .Will EJB-QL be update to able to UPDATE or DELETE OBJECT?

If I write some SQL in EJBRemove(),Will CMP lose its advantage of Container Managed?
thank u ~~~~~~~~~~~

SCJP1.4 <br />Best wishes!<br />中国人!
Sergiu Truta
Ranch Hand

Joined: Dec 16, 2003
Posts: 121
You can delete records using remove from the home interface like
or you can lookup for the local/remote interface and call remove:
entityLocal = entityHome.findByPrimaryKey(primaryKey);
Updating records in CMP is done by updating the CMP fields using the set methods.
That's the idea behind the CMP (RAD - Rapid Application Development).
If you wanna write your own UPDADE/DELETE SQL statements, you can use BMP or Session Beans with JDBC.
Sergiu. I'm walking the path...
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
EJB-QL is EJB-Query language.....
Only for querying data. No insert/delete/update stmts.
It would be a bad design to mix CMP and BMP code in an entity bean.
In a CMP, the container is responsible to delete your data from the database.We do not have to write any delete stmts in the ejbRemove() method.
I agree. Here's the link:
subject: how to delete database records in cmp?