From: <leg...@at...> - 2003-11-21 19:55:24
|
The following issue has been updated: Updater: Bertrand Renuart (mailto:ber...@mo...) Date: Fri, 21 Nov 2003 1:53 PM Comment: This patch contains the proposed modifications. Changes: Attachment changed to hibernate-HB487-patch.txt --------------------------------------------------------------------- For a full history of the issue, see: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-487&page=history --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-487 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-487 Summary: Unecessary object creation in CharBooleanType Type: Patch Status: Unassigned Priority: Trivial Project: Hibernate2 Components: core Versions: 2.1 beta 6 Assignee: Reporter: Bertrand Renuart Created: Fri, 21 Nov 2003 1:51 PM Updated: Fri, 21 Nov 2003 1:53 PM Description: Unecessary objects are created when converting the data retrieved from the resultset to a Boolean. Original code: -------------- return new Boolean( code.toUpperCase().equals( getTrueString() ) ); Explanation: ------------ - code.toUpperCase() creates a new String - code.equalsIgnoreCase() should be used instead - new Boolean() creates a new Boolean instance where Boolean.TRUE | FALSE could be used This would lead to the following code: if ( code.equalsIgnoreCase(getTrueString())) { return Boolean.TRUE; } else { return Boolean.FALSE; } A bit more efficient ;-) Note: what should we do if code != getFalseString()? Should we throw an SQLException ? --------------------------------------------------------------------- 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 |
From: <leg...@at...> - 2003-11-21 20:30:24
|
The following issue has been updated: Updater: Bertrand Renuart (mailto:ber...@mo...) Date: Fri, 21 Nov 2003 2:29 PM Comment: Hmmm... fair enough, but the 'stringToObject' method already complains if it receives something that doesn't map to true or false. Anyway, I believe Hibernate should complain when getting something unexpected from the database - don't you think so ? When walking the class hierarchy, I notice the NullableType (ancestor) declares to throw SQLException AND HibernateException. The HibernateException has been dropped below in the hierarchy. I propose to reintroduce it so CharBooleanType can throw an HibernateException when it receives invalid data. The attachment (hibernate-HB487-patch-v2.txt) is a new version of the patch containing this change. Moreover, I made the same optimization as described above to BooleanType. Feel free to comment and/or reject my changes ;-) Changes: Attachment changed to hibernate-HB487-patch-v2.txt --------------------------------------------------------------------- For a full history of the issue, see: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-487&page=history --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-487 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-487 Summary: Unecessary object creation in CharBooleanType Type: Patch Status: Unassigned Priority: Trivial Project: Hibernate2 Components: core Versions: 2.1 beta 6 Assignee: Reporter: Bertrand Renuart Created: Fri, 21 Nov 2003 1:51 PM Updated: Fri, 21 Nov 2003 2:29 PM Description: Unecessary objects are created when converting the data retrieved from the resultset to a Boolean. Original code: -------------- return new Boolean( code.toUpperCase().equals( getTrueString() ) ); Explanation: ------------ - code.toUpperCase() creates a new String - code.equalsIgnoreCase() should be used instead - new Boolean() creates a new Boolean instance where Boolean.TRUE | FALSE could be used This would lead to the following code: if ( code.equalsIgnoreCase(getTrueString())) { return Boolean.TRUE; } else { return Boolean.FALSE; } A bit more efficient ;-) Note: what should we do if code != getFalseString()? Should we throw an SQLException ? --------------------------------------------------------------------- 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 |