exception.cpp wrote:
Hi !
I have one logical problem:
TABLES:
REALTY
REALTY_FLAT
REALTY_FLAT_NEW
REALTY_HOUSE
all tables has REALTY_ID and connect by 1:1
in LLBLGEN mapper we create syb-types:
REALTY
REALTY_FLAT (syb-type of REALTY)
REALTY_FLAT_NEW (syb-type of REALTY_FLAT)
REALTY_HOUSE (syb-type of REALTY)
In inheritance, you've to look at what makes an entity type an entity type and not a state of an entity. If I look at your type hierarchy, I see 'REALTY_FLAT_NEW'. Being 'new' is a state: after a while the flat isn't new anymore and therefore should change type. But that's not possible: instances can't change type: you can't do:
Object o = new Object();
and then change o into a string, even though string is a subtype of o: o isn't a string, so it can never become a string. Data inside a table are entity instances. A row in REALTY is an entity instance of type REALTY. You can't change that to a subtype. Sure, physically you can by adding data to a table, but that's not correct, semantically, therefore we don't support it. it's tempting to do, but it has consequences in edge cases and it's also not correct semantically, which in the end will lead to bugs which are hard to track down.
So drop the REALTY_FLAT_NEW as a subtype of REALTY_FLAT, and instead make it a related entity with information about REALTY_FLAT entities which are new. Once they're not new anymore, you can delete their REALTY_FLAT_NEW entity and you're ok.
We can create entities of any types and fetch they - all work fine.
Problem: We can't convert between this types.
example:
RealtyEntity realtyEntity1;
adapter.Fetch(realtyEntity1);
how I can convert realtyEntity1 to RealtyFlatEntity type ? If I insert record into REALTY_FLAT table with same REALTY_ID and refetch realtyEntity1 - they will be RealtyFlatEntity, but how I can do this without direct insert into database - from code ?
P.S. Sory for my bad English.
You can't do this, and also shouldn't do this. Something which is a FLAT should be created as such.