Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

how to delete database records in cmp?

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ~~~~~~~~~~~
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic