SaveEntity returns false??

Posts   
 
    
chiro
User
Posts: 6
Joined: 15-Apr-2010
# Posted on: 15-Apr-2010 12:09:49   

Hi, i am using adapter and have 2 insertions per transaction (tables User and UserDetails, UserDetails has FK on table User). I have (simplified):

Adapter.StartTransaction(); UserEntity.InsertUser(user); UserDetailEntity.InsertUserDetail(user.UserDetail[0]); Adapter.Commit();

Insert just calls Adapter.SaveEntity(entity, true, false); UserEntity is saved and SaveEntity returns true, which is ok. But, SaveEntity on UserDetailEntity returns false! Why is that? If i remove check for result, i can see UserDetailEntity is saved to database, although it returns false. Am I doing something wrong?

chiro
User
Posts: 6
Joined: 15-Apr-2010
# Posted on: 15-Apr-2010 13:00:57   

I found out that if I dont refetch item after save then it returns true. Why does error happen in refetching just saved item?

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 15-Apr-2010 21:45:01   

How do the static save methods get a reference to the Adapter used for the save...?

Matt

chiro
User
Posts: 6
Joined: 15-Apr-2010
# Posted on: 16-Apr-2010 09:06:53   

It is singleton, but it is not important for my issue. I solved it like UserEntity.InsertUser(user, true, true) which saves recursively, and it works fine. I think this is the right way.