Can't see how to create sub type for abstract entity

Posts   
 
    
csb1965
User
Posts: 12
Joined: 20-Sep-2011
# Posted on: 28-Sep-2011 08:53:07   

I have an existing entity hierarchy with an abstract entity ShoppingCart and existing subtypes.

I need to add another subtype. In version 2.6 I would right click the ShoppingCart entity and choose "Add sub type" (or something like that) ... define my discriminator value and then choose which unmapped fields (in the super type) should be mapped in the new sub type.

I can't see how to do this in version 3.1.

I tried creating a new entity and then choosing "make sub type of" on this entity to add it to the existing hierarchy. This seemed to work but I then had to manually modify the discriminator value and create the target mapping in this new type.

I then needed to add one of the "unmapped" fields to this subtype entity. I clicked Reverse-engineer unmapped target fields in the field mappings tab. All the fields from the target table were listed there (not just the fields left as unmapped in the parent entity).

I chose the field in wished to map and clicked Reverse Engineer Selected. The selected field now shows up in the list of fields for the new subtype but the Is FK attribute is not set as it was in the unmapped target fields list and I can't see any way to correct this. The corresponding relationship is also missing from this entity.

I figure I am doing something completely wrong but I can't find the right way. I also tried the ol' RTFM but still can't see anything listed about creating subtypes in the entity hierarchy.

I'm sure it can't be this hard (it was soooo simple in 2.6) so forgive me for totally missing the path.

In case it matters ... this project was converted from version 2.6 to 3.1 but I hadn't noticed any issues until now.

Please help ... this is really holding me up!!

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 28-Sep-2011 11:05:27   

In v.2.6 there was no "Model-First" approach.

So if you'd pick an entity and select "Create Sub-Type...", which insinuates that there is no existing entity mapped from the database to be the sub-Type, which means the Sub-Type must be a "TargetPerEntityHierarchy" (mapped to the same table).

And you could not have created an entity in the model which is not there in the database.

In v.3.x "Model-First" was there, and hence you can create a model entity, and then you can select it's Super-Type, and in the process you can define whether it's a TargetPerEntity, or a TargetPerEntityHierarchy.

csb1965
User
Posts: 12
Joined: 20-Sep-2011
# Posted on: 28-Sep-2011 19:29:23   

okay ... I understand that we can now do "model first" design (and that's great!) but it seems like we are having to do a lot of manual wiring that was done by the designer in 2.6.

When I am adding a new subtype to an hierarchy I choose the inheritance type (can these be mixed for a single hierarchy?). So far so good ...

But then if I am using entity per hierarchy I have to realise or remember that the discriminator value is not set and go and do that.

That's not too hard but after I have added the new subtype to the entity hierarchy the list of unmapped fields doesn't take into account the fields that are already mapped onto the super type (ie. they are available to choose in the subtype as well which doesn't make sense to me). There's no indication as to which fields are already inherited so I need to remember that and the only place I can see that is in the inheritance info tab.

So, to work out which fields are NOT already inherited I have to look at the field name, jump to the inheritance info, look at the super type and see if that field is already there. then jump back and select this field for my subtype. This info is already known in the designer but is not shown in the place where I really need that information ... when choosing fields for my subtype.

If you DO choose a field that's already inherited and then validate your model you get an error ... so why not prevent that in the first place by removing these items from the list (as it was in 2.6)?

Lastly, when I map an unmapped field onto my subtype it doesn't automatically add the relationship - I had to do that manually as well. If I don't notice that the field has a FK I can easily forget that there is a relationship to add. Is there a preference somewhere that I haven't set that would create this relationship automatically based on the FK?

LLBLGen is the most sophisticated tool of its kind I have used so please understand I am not complaining. It just feels like I've taken a step backwards from the hierarchy creation tools in 2.6 where it was much harder for me to make a mistake!!!

Since I am more inclined to question my use of your tool than the design of the tool itself it leaves me to wonder whether I am doing this right. Is there a better process for creating a hierarchy using target per entity that eliminates all these manual checks?

What am I missing?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 29-Sep-2011 07:00:02   

You are right. TPEH work this way:

  1. Add a new Entity (model-first)
  2. Set the SuperType
  3. Right-click the group root node and click "Auto-map unmapped entities"
  4. Go to InheritanceInfo subtab and set the Discriminator value.
  5. Go to "Field mappings" subtab and click the "Reverse-engineer unmapped target fields"
  6. Select the field you want to reverse-engineer.

And that works ok. But I see you have good points in your post from an usability point of view. Maybe those can be resumed in:

a. When creating a subentity, it should be automapped. b. When "Reverse-engineer unmapped target fields" in a subentity it should show just those fields that are not mapped in the parent entity. c. When Reverse-engineer an unmapped FK field in a subentity, LLBLGen should create its relationship, thus the associated navigator.

I will pass those suggestions to the dev team to see if they can be included as formal feature requests. Thanks for the feedback simple_smile

David Elizondo | LLBLGen Support Team
csb1965
User
Posts: 12
Joined: 20-Sep-2011
# Posted on: 29-Sep-2011 07:26:07   

Thanks daelmo,

At least I know I'm going about this the right way :-)

LLBLGen just keeps getting better and the support is fantastic. We can't imagine using anything else!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 29-Sep-2011 11:52:56   

Thanks for the feedback. It should indeed not be a struggle, but as simple as possible. You should look at quick model btw to quickly add entities to your model. For example in quickmodel you can add a subtype and define it in 1 statement, and if the supertype is in a TPEH hierarchy, the new subtype will be as well. But, indeed we could add a new menu option to make this easier, e.g. 1 dialog which allows you to add a new entity, mark its supertype and if that supertype is in a TPEH, allow you to specify the discriminator value. There will be situations where things still need multiple actions (e.g. the supertype is not in an inheritance hierarchy yet)

We'll look into making this smoother in v3.5.

Frans Bouma | Lead developer LLBLGen Pro