Brilliant! This is exactly what I was looking for. I suppose the view solution would be the best way to go- since I only need a light entity for loading information and do a 'bulk' select. At first my mind was set on a two-way thingy (select/save-update) and then I've realised it doesn't make much sense, as no bulk updates or saving would/could be done with this... That's another great thing about NH, it has the capacity to keep you in line with what you want to and can do with SQL... :)
Thanks again. On Dec 25, 5:10 pm, "Davy Brion" <[email protected]> wrote: > or you could create a view in your database and map to that with > mutable="false" > > > > On Thu, Dec 25, 2008 at 5:00 PM, Fabio Maulo <[email protected]> wrote: > > Well... IMO the better way to do it is using HQL and transformer for the > > specific use-case. > >http://nhforge.org/doc/nh/en/index.html#querycriteria-associations > >http://nhforge.org/doc/nh/en/index.html#d0e9672 > > > You can even map "light" entities using mutable=false and > > polymorphing=explicit but it is better when you are using "light" version of > > your entity for all relationships and without cascade actions. > > > In some special case you can even use SP > > >http://nhforge.org/blogs/nhibernate/archive/2008/11/24/populating-ent... > > > 2008/12/25 Nieve <[email protected]> > > >> No, no- I'm sorry, I didn't explain myself clearly enough. > >> What I'm trying to do is to map a 'lighter' class. Suppose My Item, > >> Publisher and Language entities are rather big. I map them each > >> separately according the NH norms. Now I wish to map my 'lighter' > >> Item, one that'll have only the Item title, the publisher name and the > >> language name, so that when loading all Items from the DB, I won't > >> need to load all corresponding Publishers and Languages, nor will I > >> need to lazy load their requested columns afterwards... Is this > >> possible in NH? Or is the only way to do that would be to use my > >> normal mappings whilst using an HQL join on those, declaring the > >> specific columns I need? > > >> On Dec 25, 4:15 pm, "Fabio Maulo" <[email protected]> wrote: > >> > Do you really think that somebody can create a mapping reading an SQL > >> > without know nothing about the domain ? > > >> > 2008/12/25 Nieve <[email protected]> > > >> > > Hello Fabio, > >> > > Many thanks for the response! > >> > > So, it looks like I've misunderstood the join attribute. > >> > > What I wish to know, in other words, is whether there's a way to map > >> > > an entity in a way that'll correspond to the following SQL: > >> > > SELECT Item.Title, Language.Name AS Language, Publisher.Name AS > >> > > Publisher > >> > > FROM Item INNER JOIN > >> > > Language ON Item.LanguageID = Language.ID INNER > >> > > JOIN > >> > > Publisher ON Item.PublisherID = Publisher.ID > > >> > > This would allow me to load certain information faster than using the > >> > > classic table-per-class mapping, esp. when doing bulk loading > >> > > (GetAll<Item>()). > > >> > > On Dec 25, 3:45 pm, "Fabio Maulo" <[email protected]> wrote: > >> > > > Probably I don't understand exactly what you are looking > >> for...<join> is > >> > > > used to represent the same class in more than one table. > >> > > > Two records, one in the "main" table and the other in the "slave" > >> table, > >> > > are > >> > > > representing the same entity instance and for that both have the > >> same > >> > > POID > >> > > > (the POID of the "master"). > >> > > > The <join> feature was introduced to support some legacy DB and its > >> > > target > >> > > > is more oriented to improve the inheritance mapping strategies > >> (mixing > >> > > > table-per-class with table-per-class-hierency). > > >> > > > Do you can explain exactly why you want use <join> ? > > >> > > > 2008/12/25 Nieve <[email protected]> > > >> > > > > Hello there, > >> > > > > I'm trying to create a light entity consisting of several > >> properties > >> > > > > of multiple table, as described in the following discussion: > > >>http://groups.google.com/group/nhusers/browse_thread/thread/38e7ebc04. > >> > > .. > > >> > > > > Now, the thing is that I wish to use a join on the two tables, so > >> that > >> > > > > when doing massive reading from the database, the less data > >> that'll be > >> > > > > read, the faster will the query will go, which is why I prefer not > >> to > >> > > > > use the solution suggested in the aforementioned discussion. > >> > > > > I would like to know whether a <Join Table="MyTable"> could be > >> used > >> > > > > with specifying the join column on the primary entity/table. From > >> what > >> > > > > I've seen, the join takes the ID column. The only way I found to > >> do > >> > > > > this was to declare the foreign key column as the ID of the > >> primary > >> > > > > table (if to use the example given in that discussion it'll be: > >> > > > > <class name="Car"> > >> > > > > <id name ="EngineID"> <--obviously not good--> > >> > > > > ... > >> > > > > <join table="Engines"> > >> > > > > <key column="ID"/> > >> > > > > <property name="NumberOfCylinders" column="NumCylinders"/> > >> > > > > </join> > >> > > > > This, obviously, is not the way to go, but it pretty well > >> illustrates > >> > > > > what I wish to do.) > > >> > > > > Any ideas and comments would be highly appreciated! > > >> > > > -- > >> > > > Fabio Maulo > > >> > -- > >> > Fabio Maulo > > > -- > > Fabio Maulo > > -- > Davy Brionhttp://davybrion.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
