on 04-18-2007 2:49 AM
Hello experts
I have created entity and session beans to conduct database transactions. My database table has the following fields
room_id -- string
room_name -- String
For the entity bean RoomsBean, the default methods ejbCreate(String a, String b) and ejbfindbyPrimaryKey(String a) are created that I uase to create a record in the database and find a record in the database.
Now, I need a method to delete records from databse. How do I create that method? Is there a default method that I can use to delete a record? Do I have to create a method and use EJB QL to do it?
If I have to create a method, then where do I create it as the options under ejb methods are
1. create methods
2. find methods
3. home methods
4. select methods
please help.
Hi Sabbir,
From your question I assume you are using CMP entity beans. In this case you don't need to do anything in the entity bean coding. In the session bean just call the <b>remove()</b> method on the entity home or component interface -- the container will do all the work for you. (These methods are available for every entity bean - they are defined on the javax.ejb.{EJBLocalObject | EJBObject | EJBLocalHome | EJBHome} interfaces.)
If you are using BMP, all you have to do is to implement the <b>ejbRemove()</b> method in the bean class (this method is inherited from the javax.ejb.EntityBean interface).
Hope it helps!
-Vladimir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Here is an <a href="http://www.javapassion.com/j2ee/EntityBean.pdf">pdf</a> for your all your ejb related issues.
How ever, in short I can say, there are methods in entity bean to create, remove a record from table. check the above pdf for piece of code especially 79 and 103 for creating and removing a record.
<a href="http://www.javapassion.com/j2ee/EntityBean.pdf">Create and Remove</a>
Reward points it it helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.