Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to delete database records in cmp?

 
Mike Lin
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ~~~~~~~~~~~
 
Sergiu Truta
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can delete records using remove from the home interface like
entityHome.remove(primaryKey);
or you can lookup for the local/remote interface and call remove:
entityLocal = entityHome.findByPrimaryKey(primaryKey);
entityLocal.remove();
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.
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic