This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Deleting Record in a Web Application.

 
Devi Ramadass
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to delete the paricular record in hibernate web application. Can anyone knows please tell me.

Regards
Devi Ramadass
 
Devi Ramadass
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Any one knows please help me.

Regards
Devi Ramadass
 
Scott Selikoff
author
Saloon Keeper
Posts: 4015
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Devi Ramadass
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any inputs...........

Regards
Devi Ramadass
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Devi Ramadass
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any Suggestion.........
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Devi Ramadass
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any Inputs Please....

Regards
Devi Ramadass
 
Vijay Gadde
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hope this helps.
Thanks,VIJAY
 
Ramesh Srinivasan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Devi Ramadass
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rather asking same question repeatedly... please google and try to understnad some basic concepts arround Hibernate...javascript:%20x()
javascript:%20x()javascript:%20x()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic