In PMs class I've a property that referr to Department entity (many-to- one). The point is, because of Project and Department are not linked by foreign key, I would like to include this in the previuos join mapping. So I can retrieve directly from my Project Entity also the Department. What do you do in this specific case?
Thanks! On 25 Feb, 11:28, Fabio Maulo <[email protected]> wrote: > In the class you have not a property IdDepartment of type Int32, instead you > have a property of type Department and the relation is a many-to-one (for > example... it can be even a one-to-one depending on your business). > > Switch your mind!! > become a OOP developer and not a squared data designer ;-) > > > > > > On Fri, Feb 25, 2011 at 10:04 AM, turibbio <[email protected]> wrote: > > Ok, I understand what do you mean. I've this entity named "Project" > > with these fields: > > > (ProjectName, ProjectDate, IsFinished, ProjectOwner, > > ProjectDepartment). > > > That's the way I've mapped it > > >> <id name="IdProject" column="Id" type="integer" /> > > >> <property name="ProjectDate" column="ProjectDate" /> > > >> <property name="IsFinished" column="IsFinished" /> > > >> <join table="PMs"> > > >> <key column="Id"/> > > >> <property name="Name" column="Name" /> > > >> <property name="LastName" column="LastName" /> > > >> <property name="???" column="???" /> <-- Here I would like > > to retrieve the name of the dep > Departments.Description > > >> </join> > > > The thing is that information is stored in 3 different tables on DB. > > So I came up with the join in the mapping. > > > >> Projects > > >> ------------ > > >> Id > > >> ProjectDate > > >> IsFinished > > > >> PMs > > >> ----------- > > >> Id > > >> Name > > >> LastName > > >> IdDepartment > > > >> Departments > > >> ---------- > > >> Id > > >> Description > > > I hope to get your message, and to be more clear than before. > > Thanks in advance Fabio! > > > On 25 Feb, 12:07, Fabio Maulo <[email protected]> wrote: > > > To try to be more clear... > > > The problem that an ORM tries to solves is the representation in table of > > > class graph and is not the class representation of table/column/relation. > > > > You are starting from the wrong point. > > > > Switch your mind and think only and exclusively in your domain, your > > > business; only then, when the problem is solved in RAM, we can talk about > > > how persist it. > > > > On Fri, Feb 25, 2011 at 7:59 AM, Fabio Maulo <[email protected]> > > wrote: > > > > To have tables is an accident; in general we prefer to talk about > > classes. > > > > > On Fri, Feb 25, 2011 at 6:27 AM, turibbio <[email protected]> wrote: > > > > >> Hi all, I'm facing this problem. > > > >> I have 3 table on my db > > > > >> TableA > > > >> ------------ > > > >> Id_TableA > > > >> TableA_Field1 > > > >> TableA_Field2 > > > > >> TableB > > > >> ----------- > > > >> Id_TableB > > > >> TableB_Field1 > > > >> TableB_Field2 > > > >> ForeignKey_ToTableC > > > > >> TableC > > > >> ---------- > > > >> Id_TableC > > > >> TableC_Field1 > > > > >> I have joined table B in xml mapping of table A. I'd like also to > > > >> retrieve TableC_Field in the same join. > > > > >> This is the mapping of TableA: > > > > >> <join table="TableB"> > > > >> <key column="Id_TableB"/> > > > >> <property name="Field1_B" column="TableB_Field1" /> > > > >> <property name="Field2_B" column="TableB_Field2" /> > > > >> <property name="???" column="???" /> > > > >> </join> > > > > >> I would like to map one of the follow: > > > > >> 1)The entity returned in the mapping of TableB (something like that > > > >> <property name="EntityPropertyNameInTableB_ToTableC" />) > > > > >> 2)The TableC_Field1 directly from mapping of table A. > > > > >> There's any way to do that? > > > > >> Thanks in advance! > > > > >> -- > > > >> You received this message because you are subscribed to the Google > > Groups > > > >> "nhusers" group. > > > >> To post to this group, send email to [email protected]. > > > >> To unsubscribe from this group, send email to > > > >> [email protected]. > > > >> For more options, visit this group at > > > >>http://groups.google.com/group/nhusers?hl=en. > > > > > -- > > > > Fabio Maulo > > > > -- > > > Fabio Maulo- Nascondi testo citato > > > > - Mostra testo citato - > > > -- > > You received this message because you are subscribed to the Google Groups > > "nhusers" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group at > >http://groups.google.com/group/nhusers?hl=en. > > -- > Fabio Maulo- Nascondi testo citato > > - Mostra testo citato - -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
