Entity inheritence ans duplicate rows

Posts   
 
    
mosachri
User
Posts: 3
Joined: 27-Jul-2006
# Posted on: 27-Jul-2006 15:47:25   

Hello,

I have two entities with hierarchical relation, and also a duplicate row. I mean that the mother table has a common row with his child table (same name, same type, null not allowed).

When trying to add a row to the child table, LLBL generated code does not fill the duplicate row in the mother table, and the result is an SQL exception because this row in the mother table can't have a null value.

I could't find any solution to that problem. If anyone had an idea about that ?

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 27-Jul-2006 17:22:08   

Please post some code which shows how you saved the entity which failed or any other information we might need to repro the problem.

Frans Bouma | Lead developer LLBLGen Pro
silat
User
Posts: 57
Joined: 24-Mar-2006
# Posted on: 27-Jul-2006 19:10:00   

Hello Frans,

This is not really a problem with LLBL I guess. Below our structure:

Contact - CNT_I_ID (PK) - CNT_D_CREATE - CNT_I_TYPE

Person - CNT_I_ID (PK) - CNT_I_TYPE (<-- This is the duplicate fields. In fact, most of the fields from contact are also present in Person) - PER_S_FIRSTNAME

Table Person inherits from table contact. As you can see the Field CNT_I_TYPE is both in the two table and also have the same name.

Now, when we do the following code:


Person person = new Person();
person.CNT_I_TYPE = 2;
person.PER_S_FIRSTNAME = "John";
person.Save() //pseudo code, as we are using adapter

LLBL will generate the following 2 SQL insert: - one for Contact - then one for person

as CNT_I_TYPE is in both table, it will only appears in the second SQL statement, making the first call failed as this is a mandatory field.

By now, we have renamed the fields names in the Person entity, but I hope that you might have a better idea...(btw, this is only an example, as our Contact table has almost 30 fields, which are all replicated in Person - ok, I know, bad design...).

Cheers,

Silat.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 28-Jul-2006 08:43:09   

I think you should modify the SubType class and add base.CNT_I_TYPE = value; In the Setter of the CNT_I_TYPE property.