File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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: 1066
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?
jQuery in Action, 3rd edition