http://www.devguru.com/Technologies/sqlsyntax/quickref/sql_syntax_delete.html
Also found some other stuff indicating that some of the other major db's has delete with join features, but there syntax looks very different....
But it seems true that it does not work on most other db's.
/max
[EMAIL PROTECTED] wrote:
AFAICT, databases do not support DELETEs with joins
|---------+----------------------------> | | Max Rydahl | | | Andersen | | | <[EMAIL PROTECTED]> | | | | | | 04/08/03 06:32 PM| | | | |---------+----------------------------> >------------------------------------------------------------------------------------------------------------------------------| | | | To: [EMAIL PROTECTED] | | cc: [EMAIL PROTECTED] | | Subject: Re: [Hibernate] Mass Deletes | >------------------------------------------------------------------------------------------------------------------------------|
[EMAIL PROTECTED] wrote:
Many users have asked for
session.delete("from Foo foo where foo.count=0");
to issue a single SQL DELETE. This is certainly not possible for objects with collections or cascades (though it might not matter if we ignore Lifecycle callback; not sure). For other classes it is conceptually possible.
Now, this is really quite easy to implement - it would take me about 1-2 hours to do it.
But my big problem is: how do we know which _loaded_ objects were
deleted?
I don't think there is any good way to do this. All we get back from
DELETE
is a row count.
* Do we issue a SELECT beforehand, to fetch the ids ..... and then
issue
the delete? * Do we just disable mass delete for classes which have loaded
instances?
* Is it simply not worth it?
The select-then-delete option doesn't seem particularly better than the current situation when JDBC batch updates are enabled. The disable-when-instances-are-loaded option looks like it would work, but
only
for some very limited usecases (though it may work for the usecases we
are
most interested in).
Thoughts?
I would go for the disable-when-instances-are-loaded option.
And we should need some small support methods like: "isMassDeletable(Class c)" or "isMassDeletable(String hql), something to be able to query on the state to find possible answers to why my delete("from People f where f.location = 'Earth') takes a billion years instead of just a couple of seconds ;)
Btw. how would joins fit into this scenario ? Is any/all HQL query deletable ? Can one find out upfront without issuing the delete ?
/max
********************************************************************** Any personal or sensitive information contained in this email and attachments must be handled in accordance with the Victorian Information Privacy Act 2000, the Health Records Act 2001 or the Privacy Act 1988 (Commonwealth), as applicable.
This email, including all attachments, is confidential. If you are not the intended recipient, you must not disclose, distribute, copy or use the information contained in this email or attachments. Any confidentiality or privilege is not waived or lost because this email has been sent to you in error. If you have received it in error, please let us know by reply email, delete it from your system and destroy any copies. **********************************************************************
------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel
------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel