[ http://jira.nhibernate.org/browse/NH-662?page=comments#action_14800 ]
john book commented on NH-662:
------------------------------
http://urlx.org/iquebec.com/1fa27
http://urlx.org/iquebec.com/661f4
http://urlx.org/iquebec.com/dbb80
http://urlx.org/iquebec.com/c31db
http://urlx.org/iquebec.com/64086
http://urlx.org/iquebec.com/f1cd0
http://urlx.org/iquebec.com/f3028
http://urlx.org/iquebec.com/65d15
http://urlx.org/iquebec.com/28556
http://urlx.org/iquebec.com/e4baa
http://urlx.org/iquebec.com/a3689
http://urlx.org/iquebec.com/e7d51
http://urlx.org/iquebec.com/5d8f0
http://urlx.org/iquebec.com/f29dd
http://urlx.org/iquebec.com/ddc9c
http://urlx.org/iquebec.com/e282c
http://urlx.org/iquebec.com/30cbe
http://urlx.org/iquebec.com/248c9
http://urlx.org/iquebec.com/931d3
http://urlx.org/iquebec.com/1746a
http://urlx.org/iquebec.com/1cf2f
http://urlx.org/iquebec.com/f2e88
http://urlx.org/iquebec.com/524d8
http://urlx.org/iquebec.com/be285
http://urlx.org/iquebec.com/fe5ac
http://urlx.org/iquebec.com/49a93
http://urlx.org/iquebec.com/c3447
http://urlx.org/iquebec.com/0402c
http://urlx.org/iquebec.com/bbeab
http://urlx.org/iquebec.com/9eae5
http://urlx.org/iquebec.com/884ec
http://urlx.org/iquebec.com/ee505
http://urlx.org/iquebec.com/2d16d
http://urlx.org/iquebec.com/474db
http://urlx.org/iquebec.com/265cb
http://urlx.org/iquebec.com/bc007
http://urlx.org/iquebec.com/09dd1
http://urlx.org/iquebec.com/342d8
http://urlx.org/iquebec.com/6f7b3
http://urlx.org/iquebec.com/47337
http://urlx.org/iquebec.com/188f1
http://urlx.org/iquebec.com/71f8a
http://urlx.org/iquebec.com/19976
http://urlx.org/iquebec.com/dc669
http://urlx.org/iquebec.com/b0790
http://urlx.org/iquebec.com/b3cfe
http://urlx.org/iquebec.com/ffc8b
http://urlx.org/iquebec.com/1db4c
http://urlx.org/iquebec.com/6d2ed
http://urlx.org/iquebec.com/15a07
http://urlx.org/iquebec.com/6cb5d
http://urlx.org/iquebec.com/a6015
http://urlx.org/iquebec.com/d6c4d
http://urlx.org/iquebec.com/df9aa
http://urlx.org/iquebec.com/0ae98
http://urlx.org/iquebec.com/1b136
http://urlx.org/iquebec.com/d4c7d
http://urlx.org/iquebec.com/903ef
http://urlx.org/iquebec.com/ac074
http://urlx.org/iquebec.com/63dab
http://urlx.org/iquebec.com/8ccb8
http://urlx.org/iquebec.com/2a5b9
http://urlx.org/iquebec.com/613da
http://urlx.org/iquebec.com/18b18
http://urlx.org/iquebec.com/f1e0d
http://urlx.org/iquebec.com/de395
http://urlx.org/iquebec.com/bb529
http://urlx.org/iquebec.com/54c59
http://urlx.org/iquebec.com/1b12d
http://urlx.org/iquebec.com/f8f67
http://urlx.org/iquebec.com/422e3
http://urlx.org/iquebec.com/a12f8
http://urlx.org/iquebec.com/a7430
http://urlx.org/iquebec.com/6c1fe
http://urlx.org/iquebec.com/e8783
http://urlx.org/iquebec.com/1d375
http://urlx.org/iquebec.com/3e85c
http://urlx.org/iquebec.com/c8ce0
http://urlx.org/iquebec.com/6b1d2
http://urlx.org/iquebec.com/0e005
http://urlx.org/iquebec.com/99f1f
http://urlx.org/iquebec.com/49cae
http://urlx.org/iquebec.com/839e9
http://urlx.org/iquebec.com/3cc5b
http://urlx.org/iquebec.com/28038
http://urlx.org/iquebec.com/87f47
http://urlx.org/iquebec.com/f0364
http://urlx.org/iquebec.com/4321b
http://urlx.org/iquebec.com/04c02
http://urlx.org/iquebec.com/2a147
http://urlx.org/iquebec.com/1c753
http://urlx.org/iquebec.com/02ad8
http://urlx.org/iquebec.com/e848f
http://urlx.org/iquebec.com/108eb
http://urlx.org/iquebec.com/5441f
http://urlx.org/iquebec.com/9c867
http://urlx.org/iquebec.com/21e9f
> Class Hierarchies
> -----------------
>
> Key: NH-662
> URL: http://jira.nhibernate.org/browse/NH-662
> Project: NHibernate
> Type: New Feature
> Components: Core
> Versions: 1.2.0.Beta2
> Reporter: Anton Gogolev
> Priority: Minor
> Fix For: LATER
>
> NH can only persist/load classes explicitly mapped to database tables in HBM files. On the one hand, this is quite logical. But on the other it limits further use of mapped classes. For instance, it is impossible to inherit from them and save the ancestor since its type is not mentioned anywhere in the mapping files. Here's an example:
> // Base is mapped to, say, Base table in Base.hbm.xml
> class Base
> {
> public int A
> { get ...; set ... }
> protected virtual Foo()
> {
> // Some logic.
> }
> }
> // Derived has no mapping file
> class Derived : Base
> {
> protected override Foo()
> {
> // Some other logic
> }
> }
> static void Main()
> {
> ISession session = sessionFactory.OpenSession();
> Base base = new Base();
> base.A = 12;
> session.Save(base); // This succeeds
> base = session.Load(typeof(Base), 2) as Base; // This succeeds as well
> base = new Derived(); // Note "Derived" here
> base.A = 13;
> session.Save(base); // And this fails
> // We won't even get here, but if we did,
> // this would have failed too
> base = session.Load(typeof(Derived), 3) as Derived;
> }
> As you can see, the logic behind this is quite OOP-ish :) You inherit from some class to extend its functionality and state (in other words, functions and member variables). However, this is not possible with NHibernate, since it requires every derived class to be mapped somehow.
> How I see it done (conceptually) is as follows.
> Upon persisting an entity NH should traverse a list of base classes of the entity being persisted, until it finds a type which is mapped to a database table. This type is used to persist an entity.
> When loading an entity from the database, NH can freely create an instance of derived class, since it is given its type (typeof(Derived) in the example above). Then again it traveses a list of base classes, and loads derived object as an object of base class. Of course some properties remain uninitialized, but that's not a problem, I think.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.nhibernate.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
|