From: <leg...@at...> - 2003-08-22 20:28:53
|
Message: The following issue has been closed. Resolver: Max Rydahl Andersen Date: Fri, 22 Aug 2003 4:59 AM is fixed in CVS --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-275 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-275 Summary: hbm2java generates broken property change code Type: Patch Status: Closed Priority: Minor Resolution: FIXED Project: Hibernate2 Components: toolset Fix Fors: 2.1 Versions: 2.0 final Assignee: Max Rydahl Andersen Reporter: Shane Day Created: Wed, 20 Aug 2003 4:07 AM Updated: Fri, 22 Aug 2003 4:59 AM Environment: OS X, Hibernate 2.0.2, extensions 2.0 Description: The generated setter methods call changeSupport.firePropertyChange with the old value being the same as the new. The first thing firePropertyChange does is return if there is no change in the value. The getFieldAsObject method of BasicRenderer fails to prepend "this." for non-primitive types. The following patch fixes getFieldAsObject and adds generated code that backs up the old value before setting it, and parses this old value to firePropertyChange. It may be ok to call firePropertyChange before updating the member, thus avoiding the oldValue variable, but it feels better to send the event after making the change. Sorry about the tab/space conversion in the patch. My editor auto-converts to spaces. Cheers Shane Day *** /Users/shane/opt/hibernate-extensions-2.0.bak/tools/src/net/sf/hibernate/tool/hbm2java/BasicRenderer.java Sat Jun 14 00:15:31 2003 --- BasicRenderer.java Wed Aug 20 19:58:04 2003 *************** *** 393,402 **** writer.println(" "+getFieldAsObject(true, field)+","); writer.println(" "+getFieldAsObject(false, field)+");"); } writer.println(" this." + field.getName() + " = " + field.getName() + ";"); if((fieldType&BOUND)==BOUND) { writer.println(" "+changeSupport+".firePropertyChange(\""+field.getName()+"\","); ! writer.println(" "+getFieldAsObject(true, field)+","); writer.println(" "+getFieldAsObject(false, field)+");"); } writer.println(" }"); --- 393,406 ---- writer.println(" "+getFieldAsObject(true, field)+","); writer.println(" "+getFieldAsObject(false, field)+");"); } + + if((fieldType&BOUND)==BOUND) { + writer.println(" Object oldValue = "+getFieldAsObject(true, field)); + } writer.println(" this." + field.getName() + " = " + field.getName() + ";"); if((fieldType&BOUND)==BOUND) { writer.println(" "+changeSupport+".firePropertyChange(\""+field.getName()+"\","); ! writer.println(" oldValue,"); writer.println(" "+getFieldAsObject(false, field)+");"); } writer.println(" }"); *************** *** 477,483 **** typeName += prependThis ? "this." : ""; return typeName+field.getName()+" )"; } ! return field.getName(); } } --- 481,487 ---- typeName += prependThis ? "this." : ""; return typeName+field.getName()+" )"; } ! return (prependThis?"this.":"")+field.getName(); } } --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |