[ http://jira.nhibernate.org/browse/NH-662?page=comments#action_14972 ]
john john commented on NH-662:
------------------------------
http://clipurl.com/?GCJ260
http://clipurl.com/?CID636
http://clipurl.com/?QJA842
http://clipurl.com/?QDK555
http://clipurl.com/?OJN754
http://clipurl.com/?LFA480
http://clipurl.com/?GQI323
http://clipurl.com/?GBI585
http://clipurl.com/?LFA314
http://clipurl.com/?VPF671
http://clipurl.com/?NRW144
http://clipurl.com/?VEP345
http://clipurl.com/?BXE976
http://clipurl.com/?FLG109
http://clipurl.com/?ADY800
http://clipurl.com/?FTQ923
http://clipurl.com/?WCE140
http://clipurl.com/?EMH991
http://clipurl.com/?TUB211
http://clipurl.com/?BGX661
http://clipurl.com/?OSX593
http://clipurl.com/?TES273
http://clipurl.com/?KEX928
http://clipurl.com/?XLK359
http://clipurl.com/?CAD504
http://clipurl.com/?QCD334
http://clipurl.com/?DUK562
http://clipurl.com/?VCV890
http://clipurl.com/?LPD559
http://clipurl.com/?ESS525
http://clipurl.com/?POG768
http://clipurl.com/?NQR107
http://clipurl.com/?ESD909
http://clipurl.com/?YXX462
http://clipurl.com/?ICA940
http://clipurl.com/?QJJ118
http://clipurl.com/?SCE452
http://clipurl.com/?LLP216
http://clipurl.com/?SGH401
http://clipurl.com/?DAS656
http://clipurl.com/?SJL646
http://clipurl.com/?SXU272
http://clipurl.com/?AVN392
http://clipurl.com/?UQD703
http://clipurl.com/?IGG924
http://clipurl.com/?XMB630
http://clipurl.com/?GPV901
http://clipurl.com/?KBK449
http://clipurl.com/?JRL153
http://clipurl.com/?KJD664
http://shurl.net/2R8
http://shurl.net/2R9
http://shurl.net/2Ra
http://shurl.net/2Rb
http://shurl.net/2Rc
http://shurl.net/2Rd
http://shurl.net/2Re
http://shurl.net/2Rf
http://shurl.net/2Rg
http://shurl.net/2Rh
http://shurl.net/2Ri
http://shurl.net/2Rj
http://shurl.net/2Rk
http://shurl.net/2Rl
http://shurl.net/2Rm
http://shurl.net/2Rn
http://shurl.net/2Ro
http://shurl.net/2Rp
http://shurl.net/2Rq
http://shurl.net/2Rr
http://shurl.net/2Rs
http://shurl.net/2Rt
http://shurl.net/2Ru
http://shurl.net/2Rv
http://shurl.net/2Rw
http://shurl.net/2Rx
http://shurl.net/2Ry
http://shurl.net/2Rz
http://shurl.net/2RA
http://shurl.net/2RB
http://shurl.net/2RC
http://shurl.net/2RD
http://shurl.net/2RE
http://shurl.net/2RF
http://shurl.net/2RG
http://shurl.net/2RH
http://shurl.net/2RI
http://shurl.net/2RJ
http://shurl.net/2RK
http://shurl.net/2RL
http://shurl.net/2RM
http://shurl.net/2RN
http://shurl.net/2RO
http://shurl.net/2RP
http://shurl.net/2RQ
http://shurl.net/2RR
http://shurl.net/2RS
http://shurl.net/2RT
http://shurl.net/2RU
http://shurl.net/2RV
http://linkook.com/115
http://linkook.com/116
http://linkook.com/117
http://linkook.com/118
http://linkook.com/119
http://linkook.com/11a
http://linkook.com/11b
http://linkook.com/11c
http://linkook.com/11d
http://linkook.com/11e
http://linkook.com/11f
http://linkook.com/11g
http://linkook.com/11h
http://linkook.com/11i
http://linkook.com/11j
http://linkook.com/11k
http://linkook.com/11l
http://linkook.com/11m
http://linkook.com/11n
http://linkook.com/11o
http://linkook.com/11p
http://linkook.com/11q
http://linkook.com/11r
http://linkook.com/11s
http://linkook.com/11t
http://linkook.com/11u
http://linkook.com/11v
http://linkook.com/11w
http://linkook.com/11x
http://linkook.com/11y
http://linkook.com/11z
http://linkook.com/11A
http://linkook.com/11B
http://linkook.com/11C
http://linkook.com/11D
http://linkook.com/11E
http://linkook.com/11F
http://linkook.com/11G
http://linkook.com/11H
http://linkook.com/11I
http://linkook.com/11J
http://linkook.com/11K
http://linkook.com/11L
http://linkook.com/11M
http://linkook.com/11N
http://linkook.com/11O
http://linkook.com/11P
http://linkook.com/11Q
http://linkook.com/11R
http://linkook.com/11S
http://win-win.main.jp/kb
http://win-win.main.jp/kc
http://win-win.main.jp/kd
http://win-win.main.jp/ke
http://win-win.main.jp/kf
http://win-win.main.jp/kg
http://win-win.main.jp/kh
http://win-win.main.jp/ki
http://win-win.main.jp/kj
http://win-win.main.jp/kk
http://win-win.main.jp/kl
http://win-win.main.jp/km
http://win-win.main.jp/kn
http://win-win.main.jp/ko
http://win-win.main.jp/kp
http://win-win.main.jp/kq
http://win-win.main.jp/kr
> 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
|