If needed we can "improve" inspection of Persisters, Tuplizers and so on... btw, the "inspection" and usage of those classes is the main work done by NH ;)
2010/1/13 Ayende Rahien <[email protected]> > Oh, I don't want to modify them, I just want to be able to inspect them. > > On Wed, Jan 13, 2010 at 4:23 PM, Fabio Maulo <[email protected]> wrote: > >> The session-factory is using Metadata classes to generate Persisters and >> so on... >> You know... the session-factory is immutable (about mappings)... to change >> a mapping would mean change a lot of things created at session-factory-build >> (all queries for example). >> >> 2010/1/13 Ayende Rahien <[email protected]> >> >> As long as we are doing things this way, can we keep those classes around >>> in the session factory? >>> It would be very useful to be able to access them at some later point in >>> life. >>> >>> >>> On Wed, Jan 13, 2010 at 4:14 PM, Fabio Maulo <[email protected]>wrote: >>> >>>> For sure we can serialize Hbm* to have the XML. >>>> In the code you can see the example in >>>> : MapDslTests.CreateXmlDemo.ShowXml() >>>> >>>> And this is the result of that mapping (readable as written by hand >>>> using NH's conventions): >>>> <?xml version="1.0" encoding="utf-8"?> >>>> <hibernate-mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance >>>> " xmlns:xsd="http://www.w3.org/2001/XMLSchema >>>> " namespace="MapDsl" assembly="MapDsl" xmlns="urn:nhibernate-mapping-2.2"> >>>> <class name="Animal"> >>>> <id name="Id"> >>>> <generator class="native" /> >>>> </id> >>>> <property name="Description" /> >>>> <property name="BodyWeight" /> >>>> <many-to-one name="Mother" /> >>>> <many-to-one name="Father" /> >>>> <many-to-one name="Zoo" /> >>>> <property name="SerialNumber" /> >>>> <set name="Offspring" order-by="Father"> >>>> <key column="animal_key" /> >>>> <one-to-many class="Animal" /> >>>> </set> >>>> </class> >>>> <joined-subclass name="Reptile" extends="Animal"> >>>> <key column="animal_key" /> >>>> <property name="BodyTemperature" /> >>>> </joined-subclass> >>>> <joined-subclass name="Lizard" extends="Reptile"> >>>> <key column="reptile_key" /> >>>> </joined-subclass> >>>> <joined-subclass name="Mammal" extends="Animal"> >>>> <key column="animal_key" /> >>>> <property name="Pregnant" /> >>>> <property name="Birthdate" /> >>>> </joined-subclass> >>>> <joined-subclass name="DomesticAnimal" extends="Mammal"> >>>> <key column="mammal_key" /> >>>> <many-to-one name="Owner" /> >>>> </joined-subclass> >>>> <joined-subclass name="Cat" extends="DomesticAnimal"> >>>> <key column="domesticanimal_key" /> >>>> </joined-subclass> >>>> <joined-subclass name="Dog" extends="DomesticAnimal"> >>>> <key column="domesticanimal_key" /> >>>> </joined-subclass> >>>> <joined-subclass name="Human" extends="Mammal"> >>>> <key column="mammal_key" /> >>>> <component class="Name" name="Name"> >>>> <property name="First" /> >>>> <property name="Initial" /> >>>> <property name="Last" /> >>>> </component> >>>> <property name="NickName" /> >>>> <property name="Height" /> >>>> <property name="IntValue" /> >>>> <property name="FloatValue" /> >>>> <property name="BigDecimalValue" /> >>>> <property name="BigIntegerValue" /> >>>> <bag name="Friends"> >>>> <key column="human_key" /> >>>> <many-to-many class="Human" /> >>>> </bag> >>>> <map name="Family"> >>>> <key column="human_key" /> >>>> <map-key type="String" /> >>>> <many-to-many class="Human" /> >>>> </map> >>>> <bag name="Pets" inverse="true"> >>>> <key column="human_key" /> >>>> <one-to-many class="DomesticAnimal" /> >>>> </bag> >>>> <set name="NickNames" lazy="false" sort="natural"> >>>> <key column="human_key" /> >>>> <element type="String" /> >>>> </set> >>>> <map name="Addresses"> >>>> <key column="human_key" /> >>>> <map-key type="String" /> >>>> <composite-element class="Address"> >>>> <property name="Street" /> >>>> <property name="City" /> >>>> <property name="PostalCode" /> >>>> <property name="Country" /> >>>> <many-to-one name="StateProvince" /> >>>> </composite-element> >>>> </map> >>>> </joined-subclass> >>>> <class name="User"> >>>> <id name="Id"> >>>> <generator class="foreign"> >>>> <param name="property">Human</param> >>>> </generator> >>>> </id> >>>> <property name="UserName" /> >>>> <one-to-one name="Human" constrained="true" /> >>>> <list name="Permissions"> >>>> <key column="user_key" /> >>>> <list-index /> >>>> <element type="String" /> >>>> </list> >>>> </class> >>>> <class name="Zoo"> >>>> <id name="Id"> >>>> <generator class="native" /> >>>> </id> >>>> <discriminator /> >>>> <property name="Name" /> >>>> <property name="Classification" /> >>>> <map name="Mammals"> >>>> <key column="zoo_key" /> >>>> <map-key type="String" /> >>>> <one-to-many class="Mammal" /> >>>> </map> >>>> <map name="Animals" inverse="true"> >>>> <key column="zoo_key" /> >>>> <map-key type="String" /> >>>> <one-to-many class="Animal" /> >>>> </map> >>>> <component class="Address" name="Address"> >>>> <property name="Street" /> >>>> <property name="City" /> >>>> <property name="PostalCode" /> >>>> <property name="Country" /> >>>> <many-to-one name="StateProvince" /> >>>> </component> >>>> </class> >>>> <subclass name="PettingZoo" extends="Zoo" /> >>>> <class name="StateProvince"> >>>> <id name="Id"> >>>> <generator class="native" /> >>>> </id> >>>> <property name="Name" /> >>>> <property name="IsoCode" /> >>>> </class> >>>> </hibernate-mapping> >>>> >>>> >>>> 2010/1/13 Richard Brown (gmail) <[email protected]> >>>> >>>>> > The usage of Hbm* is more like a joke and will give us >>>>> the ability to see the XML. >>>>> >>>>> Can we re-serialise the Hbm* classes back into XML? (If so, then >>>>> definitely keep using them). >>>>> >>>> >>>>> >>>>> > In both cases what we should talk about is the API: >>>>> >what I have used in the post is a "hbm-xml-mimic" style and, IMO, it >>>>> is the best way for various reasons... >>>>> >>>>> I'm happy with the example shown ... I suspect I'd need to use it in >>>>> anger for a while to have anything more concrete to say. >>>>> >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> Fabio Maulo >>>> >>>> >>> >> >> >> -- >> Fabio Maulo >> >> > -- Fabio Maulo
