You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ddlutils-dev@db.apache.org by "Sean Xiong (Commented) (JIRA)" <ji...@apache.org> on 2011/10/27 01:39:32 UTC
[jira] [Commented] (DDLUTILS-270) Bug on PlatformImplBase.java of
/src/org/apache/ddlutils/platform
[ https://issues.apache.org/jira/browse/DDLUTILS-270?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13136595#comment-13136595 ]
Sean Xiong commented on DDLUTILS-270:
-------------------------------------
One possible solution I found it that just using LinkedHashmap rather than Hashmap.
The updated implementation shown below:
/**
* Derives the column values for the given dyna properties from the dyna bean.
*
* @param properties The properties
* @param bean The bean
* @return The values indexed by the column names
*/
protected HashMap toColumnValues(SqlDynaProperty[] properties, DynaBean bean)
{
HashMap result = new LinkedHashMap();
for (int idx = 0; idx < properties.length; idx++)
{
result.put(properties[idx].getName(),
bean == null ? null : bean.get(properties[idx].getName()));
}
return result;
}
> Bug on PlatformImplBase.java of /src/org/apache/ddlutils/platform
> -----------------------------------------------------------------
>
> Key: DDLUTILS-270
> URL: https://issues.apache.org/jira/browse/DDLUTILS-270
> Project: DdlUtils
> Issue Type: Bug
> Components: Core (No specific database)
> Affects Versions: 1.0
> Reporter: Sean Xiong
> Assignee: Thomas Dudziak
>
> Bug found in Method protected HashMap toColumnValues(SqlDynaProperty[] properties, DynaBean bean).
> Description: exception will thrown in the case of tables with composite primary keys and the pk columns are in different types.
> Use case throw exception: Table 'Employee' has a composite primary key with the combination of two columns: {int: emplyeeid, string LastName}.
> Exception may thrown because of the keyset and values stored in Hashmap may disordered and give the value of "LastName" to the key of "emplyid";
> Reason: Hashmap is used at here for storage and the items stored in Hashmap are not sorted properly.
> /**
> * Derives the column values for the given dyna properties from the dyna bean.
> *
> * @param properties The properties
> * @param bean The bean
> * @return The values indexed by the column names
> */
> protected HashMap toColumnValues(SqlDynaProperty[] properties, DynaBean bean)
> {
> HashMap result = new HashMap();
> for (int idx = 0; idx < properties.length; idx++)
> {
> result.put(properties[idx].getName(),
> bean == null ? null : bean.get(properties[idx].getName()));
> }
> return result;
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira