From: Matt R. <ma...@ra...> - 2002-12-29 12:17:21
|
Is it recommended that all hibernate persistent classes implement equals() and hashcode()? If so, is it possible to implement them in a base class? I'm doing this write now with the following toString() method and it works pretty well: public String toString() { StringBuffer results = new StringBuffer(); Class clazz = getClass(); results.append(getClass().getName() + "\n"); Field[] fields = clazz.getDeclaredFields(); try { AccessibleObject.setAccessible(fields, true); for (int i = 0; i < fields.length; i++) { results.append("\t" + fields[i].getName() + "=" + fields[i].get(this) + "\n"); } } catch (Exception e) { // ignored! } return results.toString(); } Thanks, Matt > -----Original Message----- > From: hib...@li... > [mailto:hib...@li...] On > Behalf Of Gavin King > Sent: Sunday, December 29, 2002 4:09 AM > To: hib...@li... > Subject: [Hibernate] CodeGenerator > > > > Hi everyone, > > I spent some time earlier today playing around with > CodeGenerator (a part of the codebase that I'm only > barely familiar with) and made some improvements. > > * The support for <composite-id> is now working > properly with composite id classes having > correctly generated hashCode() and equals() > methods. > > * All generated classes now implement toString() > > The generated classes now have a dependency upon > commons-lang, which doesn't bother me in the > slightest, but other people may have another > opinion. > > The last thing I noticed, but didn't have time > to fix, is that subclass constructors are unaware > of superclass properties. We need to fix that > as soon as possible. If anyone has a chance to > address this, I would appreciate it. > > 1.2.1 should be released before the weekend. > > peace > > Gavin > > > ********** CAUTION - Disclaimer ********** > This message may contain privileged and confidential > information. If you are not the intended recipient of this > message (or responsible for delivery of the message to such > person) you are hereby notified that any use, dissemination, > distribution or reproduction of this message is prohibited. > If you have received this message in error, you should > destroy it and kindly notify the sender by reply e-mail. > Please advise immediately if you or your employer do not > consent to Internet e-mail for messages of this kind. > Opinions, conclusions and other information in this message > that do not relate to the official business of Expert > Information Services Pty Ltd ("The Company") shall be > understood as neither given nor endorsed by it. > > The Company advises that this e-mail and any attached > files should be scanned to detect viruses. The Company > accepts no liability for loss or damage (whether caused > by negligence or not) resulting from the use of any > attached files. > **EIS******** End of Disclaimer ********** > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > hibernate-devel mailing list hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > |