Hiding fields on relations and relations

Posts   
 
    
jeffryvu
User
Posts: 14
Joined: 22-Sep-2005
# Posted on: 27-Sep-2005 23:27:01   

Hi,

From the docs: "Hiding fields mapped on relations is sometimes necessary as LLBLGen Pro creates all relations for you it can construct from existing foreign key constraints. Among these relations are a lot of M:N relations you probably never use. All these relations have a field mapped onto them. [b]It can clean up your generated code to hide the fields on these relations, if you want to use the relation but hide the field mapped on the relation[/b]. You can also hide the relation completely (on both sides of the relation, or on one side)"

Some questions from a newbie: 1. How can I use a relation when the field mapped on it is hidden?

  1. Is my understanding correct if I say that the generated relations are for traversing from one entity to related entities? And if I don't have the need to traverse e.g. from entity A to a collection of entity B (1:n), I can safely remove that relation (I'm using Adapter, so I don't need to remove them on both sides)?

Thanks, Jeffry

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 28-Sep-2005 16:02:10   

Hi Jeffry,

A field mapped on a relation is used inside an entity as a container of the related entity/entities. Thus you can fetch an entity with its related entities enclosed.

Answers of your questions: 1. How can I use a relation when the field mapped on it is hidden?

You can use the relation as filter to fetch your main entity/entities As you used to use a JOIN between 2 tables just to filter the rows returned from one table.

  1. Is my understanding correct if I say that the generated relations are for traversing from one entity to related entities? And if I don't have the need to traverse e.g. from entity A to a collection of entity B (1:n), I can safely remove that relation (I'm using Adapter, so I don't need to remove them on both sides)?

Considering the answer of the first question, you still may want the relation for filtering. Although you might not want to traverse from entity A to a collection of Entity B, you may want to retreive a collection of Entities A who having B.somefield = true

jeffryvu
User
Posts: 14
Joined: 22-Sep-2005
# Posted on: 28-Sep-2005 16:41:21   

Thanks, that clears things up for me simple_smile