[nhusers] Re: delete generates lots of queries

2009-04-08 Thread Graham Bunce
I'm a little confused over your mapping of table to class but, assuming you meant TABLE_A relates to class A and TABLE_B relates to class B, your example would therefore be: DELETE FROM TABLE_B WHERE CHILDREN_ID IN (1, 2, 3) - Children_id is the primary key Correct? If so, then If you're

[nhusers] Re: delete generates lots of queries

2009-04-08 Thread graphicsxp
Yes but that would delete all of the children for a given parent ! What if I only want to delete a few of them ? The IN would still be appropriate and would be : DELETE FROM TABLE_B WHERE CHILDREN_ID IN (1, 2, 3) On 8 avr, 12:02, Graham Bunce grahambu...@hotmail.com wrote: I'm a little

[nhusers] Re: delete generates lots of queries

2009-04-08 Thread Graham Bunce
If you only wanted to delete a few then, yes you are correct. However, how many is a few before the IN becomes extremely long?. I don't know if there are any performance hits for a large number of IN statements. If there is, I presume this would be different for each database type. Could

[nhusers] Re: delete generates lots of queries

2009-04-07 Thread graphicsxp
Ok, so it's not possible to do what I want, that's all I wanted to know. I will add the JIRA request. Regarding the batch thing, I was told I can't do it when doing an INSERT because my table has a identity field. Is it true for DELETE as well ? On 6 avr, 22:13, Fabio Maulo

[nhusers] Re: delete generates lots of queries

2009-04-07 Thread graphicsxp
I'll reply to myself I've used NHProfiler (really good tool : ) ) and I can see the DELETE are batched according to the value in property name=adonet.batch_size5/property I've created the JIRA request for the IN thing. Thanks to all ! On 7 avr, 09:40, graphicsxp graphic...@googlemail.com

[nhusers] Re: delete generates lots of queries

2009-04-06 Thread Fabio Maulo
on-delete=cascade (attribute of key tag)and/or check the inverse. 2009/4/6 graphicsxp graphic...@googlemail.com Hi, If I remove all the items in my collection and saves my entity to which the collection belongs, I get one DELETE query per items. How can I have all these items deleted with

[nhusers] Re: delete generates lots of queries

2009-04-06 Thread Fabio Maulo
Let NH generate your DB and then see the difference ;) 2009/4/6 graphicsxp graphic...@googlemail.com Thanks. But it's driving me nuts... I've added on-delete cascade and I also have the inverse=true but I still get as many DELETE as they are items to delete. In my Post mapping file :

[nhusers] Re: delete generates lots of queries

2009-04-06 Thread James Crowley
Fabio doesn't mean throw your old DB out... but if you look at the SQL Schema that NHibernate generates based on your mappings, that can generally be a good indicator of problems with the mapping that you're using (if you start seeing columns you're not expecting, for instance!) 2009/4/6

[nhusers] Re: delete generates lots of queries

2009-04-06 Thread graphicsxp
Ok, I had misunderstood. I've used hbm2ddl and from what I can see, the generated SQL for creating the tables give me the same database structure. It also adds the correct foreign-primary key constrainsts. The primary key is an identity column, same as my existing DB. Fabio No triggers is

[nhusers] Re: delete generates lots of queries

2009-04-06 Thread Fabio Maulo
you are seeing another movie (the on-delete=cascade is tested). 2009/4/6 graphicsxp graphic...@googlemail.com Ok, I had misunderstood. I've used hbm2ddl and from what I can see, the generated SQL for creating the tables give me the same database structure. It also adds the correct

[nhusers] Re: delete generates lots of queries

2009-04-06 Thread graphicsxp
Ok, so what do you think could prevent NH from doing the DELETE *** IN (1, 2, ...) ? On 6 avr, 17:44, Fabio Maulo fabioma...@gmail.com wrote: you are seeing another movie (the on-delete=cascade is tested). 2009/4/6 graphicsxp graphic...@googlemail.com Ok, I had misunderstood.

[nhusers] Re: delete generates lots of queries

2009-04-06 Thread Graham Bunce
I think you have the same problem I had NH will not (as I understand it) generate a single DELETE FROM entity WHERE foreignkey = X. From my tests it will work out the keys of the child table and delete them all one-by-one, i.e. DELETE FROM entity WHERE primarykey = Y, where NH has already got

[nhusers] Re: delete generates lots of queries

2009-04-06 Thread Fabio Maulo
If what you are looking for is only one round trip you can obtain the same result configuringproperty name=adonet.batch_size100/property If you want exactly DELETE FROM TABLE_A WHERE CHILDREN_ID IN (1, 2, 3) you should add a Improvement request in our JIRA. 2009/4/6 graphicsxp