Single entity not saving, not throwing exception, not returning false

Posts   
 
    
apb
User
Posts: 41
Joined: 21-Oct-2008
# Posted on: 17-Mar-2009 23:32:10   

Hi,

Using self-service, 2.6.

As an experiment, I tried to save an entity with most of its non-nullable fields unpopulated. I was expecting either an exception or a row with a bunch of empty defaults.

PortletsEntity p = new PortletsEntity(Guid.NewGuid());
bool ok = p.Save();

Nothing happens. No row in the DB. No exception. But it returns true.

When I examine the entity "p" in the visualizer following the "new" statement, it has valid enough data that it should insert (empty guids in guid fields, empty strings in string fields, zeros in ints, etc).

To say that this is a serious problem would be an understatement. If I can't trust it to either save my data or tell me there was a problem, I can't use it.

Any ideas on what might be happening?

-Al

apb
User
Posts: 41
Joined: 21-Oct-2008
# Posted on: 17-Mar-2009 23:40:45   

Update:

Tried setting one additional field:

PortletsEntity p = new PortletsEntity(Guid.NewGuid());
p.Title = "foo";
bool ok = p.Save();

Now an exception occurs (null values).

Very strange.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-Mar-2009 01:55:34   

Does the entity get persisted in DB when you saved it without seting any field value?

The save routing (SaveEntity) returns true if ther are not validation errors or authorization errors. But indeed it could returns true and the entity wouldn't get persisted.

You could check whether or not the entity was persisted with the .IsNew property (true = not persisted, false = persisted).

What happens is that in your first example there are nothing to save. In the later example, there are things to save, but the save fails because the non-null fields.

David Elizondo | LLBLGen Support Team
happyfirst
User
Posts: 215
Joined: 28-Nov-2008
# Posted on: 28-Apr-2009 21:05:09   

I just ran into this very same issue.

I have an entity with a three column primary key. All other fields are nullable.

I created a new entity using the constructor that took the three primary keys and then immediately called Save after that. Returned true, no exceptions, but no record was created and there was no insert sql statement in the log file.

So I switched to the parameterless constructor and then manually set all three primary keys and then finally I got an exception that one of them was null (which I debugged and fixed).

So it seems like maybe some logic isn't getting called when creating an object via a parameterized constructor?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 28-Apr-2009 22:15:34   

happyfirst wrote:

I just ran into this very same issue.

I have an entity with a three column primary key. All other fields are nullable.

I created a new entity using the constructor that took the three primary keys and then immediately called Save after that. Returned true, no exceptions, but no record was created and there was no insert sql statement in the log file.

So I switched to the parameterless constructor and then manually set all three primary keys and then finally I got an exception that one of them was null (which I debugged and fixed).

So it seems like maybe some logic isn't getting called when creating an object via a parameterized constructor?

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7725

We don't have these for nothing, happyfirst. Please, start a new thread, provide the information described in that thread I linked to above. simple_smile

Frans Bouma | Lead developer LLBLGen Pro