persist new m:n relation on a new entity

Posts   
 
    
zaad
User
Posts: 19
Joined: 13-Sep-2005
# Posted on: 13-Sep-2005 15:51:08   

Hello,

I'm not able to do the following: I have a (FireBird) table User, table Right and a crosstable UserRight. I want to create a new user and at the same time give him rights. I want to persist this to the database in one go. The way described below gives me an exception that I need to provide the new PK-value of User. I hoped this was all taken care of in the framework. Or am I doing something wrong?

        UserEntity usr = new UserEntity();
        usr.Name = "test";
        usr.active = 1;

        UserRightEntity usrRight = new UserRightEntity();
        usrRight.User = usr;
        usrRight.Right = new RightEntity(1); //1=PK value for Right

        usr.Save(true);

Greetz,

zaad

Posts: 134
Joined: 04-Mar-2005
# Posted on: 13-Sep-2005 16:13:29   

Does Firebird have the equivalent of Oracle sequences? Have you set up the method by which the entity gets it's next PK in the entity? LLBL handles allocating keys so long as you set it up in the LLBL project.

zaad
User
Posts: 19
Joined: 13-Sep-2005
# Posted on: 13-Sep-2005 16:36:22   

Firebird works with generators for single serial PK-values. When a new record is added, a beforeInsert-trigger gets the new pk-value from the generator and stored that in the new fieldvalue. How do you set up the method then?

zaad
User
Posts: 19
Joined: 13-Sep-2005
# Posted on: 13-Sep-2005 16:50:20   

Sorry for the previous post. I found out how to do that. It was easy.

More importantly, it works... smile

Thanks for this great tool. wink

greetz,

zaad