Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Object Relational Mapping
Search Coderanch
Advance search
Google search
Register / Login
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
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Object Relational Mapping
example of where exists
Franck McGeough
Greenhorn
Posts: 26
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Can somebody give me a Hibernate example of delete "where exists" usage? The reference manual
doc
is pretty bad. I want to delete all the rows from a child table based on a criteria in the parent. Something like this:
DELETE FROM Child WHERE EXISTS (SELECT 1 FROM Parent WHERE Parent.field1 = 642 AND Parent.field2 = 1 AND Parent.pkid = Child.fkeyid)
Franck McGeough
Greenhorn
Posts: 26
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Never mind. I figured it out. You can do it in HQL. (I'm using Hibernate 3.1 rc3). It looks something like this :
String hqlDelete = "delete from Child c where exists (from c.parent p where p.field1 = 642 AND p.field2 = 1)";
Hibernate generates sql that resembles the following :
delete from Child where exists (select Parent.id from Parent where Parent.pkid = Child.fkeyid and field1 = 642 and field2 = 1)
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Example of Reflexive composition relation.
retrieving object hierarchy - many-to-one?
SQL puzzle about removing duplicate rows
Conditionalize popup menu for each node in JTree
Association problem in delete
More...