aspose file tools*
The moose likes Struts and the fly likes Struts & Hibernate Integration unable to delete values from MYSQL database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts & Hibernate Integration unable to delete values from MYSQL database" Watch "Struts & Hibernate Integration unable to delete values from MYSQL database" New topic
Author

Struts & Hibernate Integration unable to delete values from MYSQL database

Melvin Reynold
Greenhorn

Joined: Jun 12, 2009
Posts: 15
After i click search, the result with the values are shown. Im unable to delete the values whenever i click the delete button and it shows an exception. Please help. Thanks.

Hibernate: select product0_.sno as sno5_0_, product0_.name as name5_0_, product0_.price as price5_0_, product0_.quantity as quantity5_0_, product0_.total as total5_0_, product0_.distributorid as distribu6_5_0_ from product product0_ where product0_.sno=?
Exceptionorg.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.test.hibernate.pojo.product#0]

JSP




ITEM FORM


STRUTS-CONFIG


DELETE ACTION CLASS


DELETE DAO CLASS


HIBERNATE MAPPING


POJO


SEARCH DAO



SEARCH ACTION


David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I find the code nearly as illegible as without code tags: could you edit so the code is indented like in real life?
Melvin Reynold
Greenhorn

Joined: Jun 12, 2009
Posts: 15
Edited and hope this helps.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Not really; that's worse. Are you unable to see your own posts?
Melvin Reynold
Greenhorn

Joined: Jun 12, 2009
Posts: 15
how about now?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Much better. That's nearly 500 lines of code to wade through... :/It looks like you instantiate a new product (really, following Java naming conventions makes things much clearer), get its ID (which is... what by default?), then attempt to delete it--completely ignoring any parameters.

Note that deleting items via an HTML link can be a very bad idea, and tales abound of people losing their entire databases this way.
Melvin Reynold
Greenhorn

Joined: Jun 12, 2009
Posts: 15
Thanks. Got it to work. I have a another question. Can i use this way to pass values to another page for editing? Im returning a resultset from the search page to edit page. What is the best way to do this and how to update?

EDIT DAO



EDIT ACTION



EDIT PAGE

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

That's another ~200 lines of code. It'd be better if you posted only the most relevant bits; I don't need to see things like your imports, your presentation of error messages, non-relevant table columns, etc. You're getting free help here--it's polite to make it as easy as possible for the people trying to help you. While normally I say it's better to provide too much than too little, there's a point of diminishing returns.

All that said, I'm not really sure what you're actually asking.
Melvin Reynold
Greenhorn

Joined: Jun 12, 2009
Posts: 15
When i click search, the result is shown under the search field. There is an edit button beside the result. When i click edit, it will forward to an edit page and display each values in a html:text field using logic:iterate. Im returning a resultset. What is the best way to do this? I dont speak or write in English very well. I hope you understand.
sudha senthil
Greenhorn

Joined: Aug 01, 2008
Posts: 26
is this is a real time project?
 
Don't get me started about those stupid light bulbs.
 
subject: Struts & Hibernate Integration unable to delete values from MYSQL database