Save() not saving

Posts   
 
    
mjcastillo
User
Posts: 10
Joined: 08-Feb-2007
# Posted on: 18-Aug-2007 18:01:17   

I am calling Save() on a changed entity object and the save completes and returns true, but the value that was changed is not getting updated in the DB. I turned on tracing and there is no update sql getting generated. It's like the save method thinks there are no changes, or doesn't change it for some other reason. In the debugger I can examine the entity object before the save and I can see the isDirty is true and I can go to the field that was changed and see the IsChanged is true and I can see the new value in place, but after the save completes, there is no change made to the DB. The entity is not part of any relationships with other entities so I don't think there is anything going on there. Why would the Save() not carry out an update operation? I have a feeling there is a simple answer to this. Thanks in advance. Mike

stefcl
User
Posts: 210
Joined: 23-Jun-2007
# Posted on: 18-Aug-2007 18:11:17   

When you say a "changed entity", Is it changed by code or via some kind of databound controls?

mjcastillo
User
Posts: 10
Joined: 08-Feb-2007
# Posted on: 18-Aug-2007 18:18:12   

I was making the change in the code. I just tried adding a new uniqueidentifier column to the table that represents the entity and made that a primary key, and now it is working. I'm not sure why adding a primary key fixed this issue. Do you always need a primary key declared for updates to occur on an entity?

stefcl
User
Posts: 210
Joined: 23-Jun-2007
# Posted on: 18-Aug-2007 18:35:48   

As far as I know, a typical UPDATE statement generated by the llblgen framework looks like

UPDATE [table] SET [column] = x WHERE [PrimaryKeyColumn] = something

I would not be surprised at all if the framework was unable to create an update statement because there was no primary key in your table... And I wonder why you're designing database table without primary keys confused

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 18-Aug-2007 18:47:22   

It can't update a row if there's no PK field defined. However, it should throw an ORMQueryConstructionException exception. Do you catch any exceptions and swallow them around the save routine perhaps? Could you paste some code which includes the save() call?

Frans Bouma | Lead developer LLBLGen Pro