From: Brad C. <bra...@wo...> - 2002-10-01 21:44:06
|
i often add a toString method (that prints out the values of all = properties) to my persistent objects so that i can get detailed logging = of an object's state when it is loaded, saved, etc. i have just written = a printToString method for the Session interface/SessionImpl class that = does this dynamically, taking into account proxy's, lazy collections and = PersistentEnum types, so i don't have to write & maintain the toString = methods (for this purpose) anymore. i know gavin would rather the = Session interface didn't grow anymore :-), but i think this may be = useful for others to. comments? brad |
From: Anton v. S. <an...@ap...> - 2002-10-01 22:39:53
|
I would find this useful. I rely on toString quite a bit. I assume that printToString could be added somewhere else, but would then require a session object as a parameter? Or would that be very unnatural? Design niceties aside, that would work fine for me. Would adding it to the Hibernate class be any better from a reduced-interface-clutter perspective? Anton -----Original Message----- From: hib...@li... [mailto:hib...@li...]On Behalf Of Brad Clow Sent: Tuesday, October 01, 2002 5:43 PM To: hib...@li... Subject: [Hibernate] writing the properties of a persistent object to a string i often add a toString method (that prints out the values of all properties) to my persistent objects so that i can get detailed logging of an object's state when it is loaded, saved, etc. i have just written a printToString method for the Session interface/SessionImpl class that does this dynamically, taking into account proxy's, lazy collections and PersistentEnum types, so i don't have to write & maintain the toString methods (for this purpose) anymore. i know gavin would rather the Session interface didn't grow anymore :-), but i think this may be useful for others to. comments? brad |
From: Gavin K. <ga...@ap...> - 2002-10-02 03:32:42
|
I prefer Anton's suggestion. There used to be a method like this on the session interface A Long Time Ago but I got rid of it because I didn't think it had anything to do with persistence. On the other hand, sessionFactory.openDatabinder().toXML(foo); does a really nice job of printing an object..... ----- Original Message ----- From: "Anton van Straaten" <an...@ap...> To: "Brad Clow" <bra...@wo...>; <hib...@li...> Sent: Wednesday, October 02, 2002 8:40 AM Subject: RE: [Hibernate] writing the properties of a persistent object to a string > I would find this useful. I rely on toString quite a bit. > > I assume that printToString could be added somewhere else, but would then > require a session object as a parameter? Or would that be very unnatural? > Design niceties aside, that would work fine for me. Would adding it to the > Hibernate class be any better from a reduced-interface-clutter perspective? > > Anton > > > -----Original Message----- > From: hib...@li... > [mailto:hib...@li...]On Behalf Of Brad Clow > Sent: Tuesday, October 01, 2002 5:43 PM > To: hib...@li... > Subject: [Hibernate] writing the properties of a persistent object to a > string > > > i often add a toString method (that prints out the values of all properties) > to my persistent objects so that i can get detailed logging of an object's > state when it is loaded, saved, etc. i have just written a printToString > method for the Session interface/SessionImpl class that does this > dynamically, taking into account proxy's, lazy collections and > PersistentEnum types, so i don't have to write & maintain the toString > methods (for this purpose) anymore. i know gavin would rather the Session > interface didn't grow anymore :-), but i think this may be useful for others > to. > > comments? > > brad > > > > ------------------------------------------------------- > This sf.net email is sponsored by: DEDICATED SERVERS only $89! > Linux or FreeBSD, FREE setup, FAST network. Get your own server > today at http://www.ServePath.com/indexfm.htm > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel |
From: Anton v. S. <an...@ap...> - 2002-10-02 04:45:48
|
> On the other hand, > > sessionFactory.openDatabinder().toXML(foo); > > does a really nice job of printing an object..... I haven't tried that, but I will, thanks. This made me think some more... Ideally, having a single method with fixed behavior for something like this, on a class like Hibernate or Session, may not be such a good idea. It would be better if the behavior were customizable or pluggable, and perhaps that would lead to a different interface style anyway. Perhaps the code to do this could be packaged as a class which a developer could use to implement their own final result, i.e. provide methods that allow the components of an object's string representation to be arranged differently, abbreviated, or whatever. This could have the additional benefit of not needing to extend any existing classes or interfaces, and being more orthogonal to the core Hibernate persistence functionality. Anton |