Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Bugs & Issues> [SOLVED] Compound primary keys and Delete method
 

Pages: 1
Bugs & Issues
[SOLVED] Compound primary keys and Delete method
Page:1/1 

  Print all messages in this thread  
Poster Message
bonder
User



Location:

Joined on:
23-Sep-2003 05:05:17
Posted:
36 posts
# Posted on: 18-Feb-2004 18:19:19.  
This is from one of my developers:

There is the problem in generation entity class for entity that has composite primary key.

There are now constructors that have as parameters all fields of primary key in this case.

But most annoying thing that Delete() method of generated class Delete more than one entity from BD,

more precisely, all entities, that have in its keys field same value, as in deleted entity.

Example:

Table called SubTypeSubscription
ClientID (int PK, not null)
Type
ID (int PK, not null)

Rows in table:

ClientId TypeID

1 2
1 22
1 345

Code:
Code:

int clientId;
SubTypeSubscription subscription = new SubTypeSubscription(clientId);
Subscription.Delete();

Execution of this code delete all rows in table SubTypeSubscription.
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37409 posts
# Posted on: 18-Feb-2004 18:56:55.  
I'm a bit confused, as an entity with say 2 fields in its PK, has a constructor with 2 fields, so you have to specify both. So I wonder how your code snippet can compile as you specify just 1 PK field. Confused

A delete will always construct a filter with ALL PK fields. All those fields are compared to the value they have in teh entity to delete. So in your case, the TypeID field will have the value 0, so the delete statement will look like:

DELETE FROM SubTypeSubscription
WHERE ClientID = paramClientID
AND
Type
ID = paramTypeID

if I'm not mistaken you use Oracle, so I didn't use sqlserver syntaxis.
paramClientID will be set to 0 with your example (default value of int) and TypeID will also be 0.

This will thus delete 0 rows.

Please, correct me where I go wrong Regular Smiley so I can jump into the code and check what should have been there and what is actually there.



Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
bonder
User



Location:

Joined on:
23-Sep-2003 05:05:17
Posted:
36 posts
# Posted on: 19-Feb-2004 16:00:02.  
Frans, I am going to send you a piece of DDL and some generated files to show you the issue a bit more. Hopefully it's just that we're doing something wrong, which would be great news! Regular Smiley

And no, we are using SQL Server, sorry I didn't explain that.

--Bruce
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37409 posts
# Posted on: 19-Feb-2004 16:24:34.  
Ok, send it to support@llblgen.com and I'll look into it. Regular Smiley I'll mail you when I've received it.

Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.