| Author |
Deleting Record in a Web Application.
|
Devi Ramadass
Greenhorn
Joined: Sep 20, 2008
Posts: 17
|
|
Hi, I want to delete the paricular record in hibernate web application. Can anyone knows please tell me. Regards Devi Ramadass
|
 |
Devi Ramadass
Greenhorn
Joined: Sep 20, 2008
Posts: 17
|
|
Hi, Any one knows please help me. Regards Devi Ramadass
|
 |
Scott Selikoff
Saloon Keeper
Joined: Oct 23, 2005
Posts: 3652
|
|
|
Have you tried the Hibernate APIs? For pre-Hibernate3, you can use Session.delete(), and for current versions its recommended you should use HQL's createQuery() with delete in the query.
|
My Blog: Down Home Country Coding with Scott Selikoff
|
 |
Devi Ramadass
Greenhorn
Joined: Sep 20, 2008
Posts: 17
|
|
Hi, In my code i am not getting idea to delete the particular record from the list. 1.How i get the id in the DAO Class for deleting? 2.I sent the through param tag. In my table structure is Employee.class EmployeeDBConn.java EmployeeList.java Jsp Code is Please suggest me. Regards Devi Ramadass [ Edited to use code tags - Paul Sturrock ] [ September 29, 2008: Message edited by: Paul Sturrock ]
|
 |
Devi Ramadass
Greenhorn
Joined: Sep 20, 2008
Posts: 17
|
|
Any inputs........... Regards Devi Ramadass
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
1.How i get the id in the DAO Class for deleting?
The id is a property of Employee. The objects returned from your query will have this value populated.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Devi Ramadass
Greenhorn
Joined: Sep 20, 2008
Posts: 17
|
|
Hi, This is the query i am using From this query how can i get the id and set it to Employee object for delete. Regards Devi Ramadass
|
 |
Devi Ramadass
Greenhorn
Joined: Sep 20, 2008
Posts: 17
|
|
Any Suggestion.........
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
From this query how can i get the id and set it to Employee object for delete.
You don't need to set it in the Employee object, Hibernate does that for you. The result of your query is a List of Employee objects. Their ID property will be populated already.
|
 |
Vijay Gadde
Ranch Hand
Joined: Sep 30, 2008
Posts: 54
|
|
Hi, I was successfully implimented this Delete in my Hibernate application. Here is the code YOU need to try, don't worry about ID setting and all..! Hope this helps wish YOU good luck VIJAY
|
Vijay Gadde
Coming together is a beginning. Keeping together is progress.. Working together is success........
|
 |
Devi Ramadass
Greenhorn
Joined: Sep 20, 2008
Posts: 17
|
|
Hi, Thank you for your reply It's working fine.But Could you suggest how to get the id of the particular record which is selected from the list instead of assigning it statically (int id=123 . Regards Devi Ramadass. [ October 09, 2008: Message edited by: Devi Ramadass ]
|
 |
Devi Ramadass
Greenhorn
Joined: Sep 20, 2008
Posts: 17
|
|
Any Inputs Please.... Regards Devi Ramadass
|
 |
Vijay Gadde
Ranch Hand
Joined: Sep 30, 2008
Posts: 54
|
|
Hope this helps. Thanks,VIJAY
|
 |
Ramesh Srinivasan
Ranch Hand
Joined: Aug 17, 2008
Posts: 35
|
|
Originally posted by Devi Ramadass: Any Inputs Please.... Regards Devi Ramadass
Hi, If you ask Hibernate to employee.getId() it will give you the ObjectId which was assigned. I have seen your code there was long id has mentioned your EMPLOYEE class it will return Id of your object. ~Ramesh.
|
SCJP 5.0 93%<br /> <br />"We are what we repeatedly do , then excellence is not an action it is an Habit" Aristotle
|
 |
Devi Ramadass
Greenhorn
Joined: Sep 20, 2008
Posts: 17
|
|
Hai,
If you ask Hibernate to employee.getId() it will give you the ObjectId which was assigned. I have seen your code there was long id has mentioned your EMPLOYEE class it will return Id of your object. ~Ramesh..
------------------ If i print the return id through this statement System.out.println("Employee Id="+employee.getId()) i am getting the value zero. Instead of that i want to get the selected employee id.Please suggest. Thank you for all Inputs. Regards Devi Ramadass
|
 |
Devi Ramadass
Greenhorn
Joined: Sep 20, 2008
Posts: 17
|
|
Hi,
//user Id - you will pass this value to this query at run time.String query String query = "from User as user where user.userID=:userId"
I passing the employee id but i am getting the value zero. Instead of that i want to get the selected employee id.Please suggest. Regards Devi Ramadass. [ October 11, 2008: Message edited by: Devi Ramadass ]
|
 |
Vijay Gadde
Ranch Hand
Joined: Sep 30, 2008
Posts: 54
|
|
Rather asking same question repeatedly... please google and try to understnad some basic concepts arround Hibernate...javascript:%20x() javascript:%20x()javascript:%20x()
|
 |
 |
|
|
subject: Deleting Record in a Web Application.
|
|
|