You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Scott Wells (JIRA)" <ji...@apache.org> on 2008/10/22 17:23:46 UTC
[jira] Created: (CONFIGURATION-342) DatabaseConfiguration.copy()
loses list/array values
DatabaseConfiguration.copy() loses list/array values
----------------------------------------------------
Key: CONFIGURATION-342
URL: https://issues.apache.org/jira/browse/CONFIGURATION-342
Project: Commons Configuration
Issue Type: Bug
Components: Type conversion
Affects Versions: 1.5
Reporter: Scott Wells
I've found a bug where adding a list property to a BaseConfiguration, then copying that full BaseConfiguration to a DatabaseConfiguration, the list is lost and only the first element is copied to the destination DatabaseConfiguration. For example:
BaseConfiguration bc = new BaseConfiguration();
bc.addProperty("myList", Arrays.asList("1", "2", "3", "4");
DatabaseConfiguration dc = new DatabaseConfiguration(...);
dc.copy(bc);
List list = dc.getList("myList");
// At this point, you'll get a single element list containing only "1"
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CONFIGURATION-342) DatabaseConfiguration.copy()
loses list/array values
Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12642786#action_12642786 ]
Oliver Heger commented on CONFIGURATION-342:
--------------------------------------------
Yes, I am interested in this stuff and am happy to review and apply patches.
I think, adding support for multi-valued properties should not be too complicated. But making DatabaseConfiguration truly hierarchical will be challenging; we would have to implement all the enhanced query facilities.
To your question about traversing hierarchical node structures: There is indeed a visitor-like approach implemented in the nodes of a hierarchical configuration. You can for instance check out the HierarchicalConfiguration.getKeys() method, which uses a visitor to gather a list of the existing keys. This should be similar to what is needed for DatabaseConfiguration.
> DatabaseConfiguration.copy() loses list/array values
> ----------------------------------------------------
>
> Key: CONFIGURATION-342
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-342
> Project: Commons Configuration
> Issue Type: Bug
> Components: Type conversion
> Affects Versions: 1.5
> Reporter: Scott Wells
> Attachments: ConfigurationUtil.java
>
>
> I've found a bug where adding a list property to a BaseConfiguration, then copying that full BaseConfiguration to a DatabaseConfiguration, the list is lost and only the first element is copied to the destination DatabaseConfiguration. For example:
> BaseConfiguration bc = new BaseConfiguration();
> bc.addProperty("myList", Arrays.asList("1", "2", "3", "4");
> DatabaseConfiguration dc = new DatabaseConfiguration(...);
> dc.copy(bc);
> List list = dc.getList("myList");
> // At this point, you'll get a single element list containing only "1"
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CONFIGURATION-342) DatabaseConfiguration.copy()
loses list/array values
Posted by "Scott Wells (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12643311#action_12643311 ]
Scott Wells commented on CONFIGURATION-342:
-------------------------------------------
Okay. I'm pretty slammed with major release planning at work right now after presenting several successful proof-of-concept projects. I'm 99.999% sure that we'll be using Commons Config, and in particular DatabaseConfiguration for shared persistent storage and XMLConfiguration for externalized format (for import/export, revisioning through SCM, etc.). As we get into the productization of that, I'll likely ping you again to chat about how DatabaseConfiguration might evolve to have the same level of expressiveness as HierarchicalConfiguration and what we might do to aid in getting it there.
> DatabaseConfiguration.copy() loses list/array values
> ----------------------------------------------------
>
> Key: CONFIGURATION-342
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-342
> Project: Commons Configuration
> Issue Type: Bug
> Components: Type conversion
> Affects Versions: 1.5
> Reporter: Scott Wells
> Attachments: ConfigurationUtil.java
>
>
> I've found a bug where adding a list property to a BaseConfiguration, then copying that full BaseConfiguration to a DatabaseConfiguration, the list is lost and only the first element is copied to the destination DatabaseConfiguration. For example:
> BaseConfiguration bc = new BaseConfiguration();
> bc.addProperty("myList", Arrays.asList("1", "2", "3", "4");
> DatabaseConfiguration dc = new DatabaseConfiguration(...);
> dc.copy(bc);
> List list = dc.getList("myList");
> // At this point, you'll get a single element list containing only "1"
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (CONFIGURATION-342) DatabaseConfiguration.copy()
loses list/array values
Posted by "Scott Wells (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-342?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Scott Wells updated CONFIGURATION-342:
--------------------------------------
Attachment: ConfigurationUtil.java
Demonstrates simple version of flattening/unflattening multi-valued property values for flat key/value storage, e.g., to properties files, current database configuration tables, etc.
> DatabaseConfiguration.copy() loses list/array values
> ----------------------------------------------------
>
> Key: CONFIGURATION-342
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-342
> Project: Commons Configuration
> Issue Type: Bug
> Components: Type conversion
> Affects Versions: 1.5
> Reporter: Scott Wells
> Attachments: ConfigurationUtil.java
>
>
> I've found a bug where adding a list property to a BaseConfiguration, then copying that full BaseConfiguration to a DatabaseConfiguration, the list is lost and only the first element is copied to the destination DatabaseConfiguration. For example:
> BaseConfiguration bc = new BaseConfiguration();
> bc.addProperty("myList", Arrays.asList("1", "2", "3", "4");
> DatabaseConfiguration dc = new DatabaseConfiguration(...);
> dc.copy(bc);
> List list = dc.getList("myList");
> // At this point, you'll get a single element list containing only "1"
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CONFIGURATION-342) DatabaseConfiguration.copy()
loses list/array values
Posted by "Scott Wells (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12641890#action_12641890 ]
Scott Wells commented on CONFIGURATION-342:
-------------------------------------------
After a little more debugging, it looks like it may be worse than just copy. I just tried to add the list directly and it still only picked up the first element. So basically the following:
DatabaseConfiguration dc = new DatabaseConfiguration(...);
dc.addProperty("myList", Arrays.asList("1", "2", "3", "4");
List list = dc.getList("myList");
// At this point, you'll get a single element list containing only "1"
Scanning the bug DB, it looks like there was a problem earlier with this. Perhaps a regression? Or (hopefully!) I'm doing something wrong? I haven't changed the delimiter or whether it should be evaluated from the defaults for a new DBConfig.
> DatabaseConfiguration.copy() loses list/array values
> ----------------------------------------------------
>
> Key: CONFIGURATION-342
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-342
> Project: Commons Configuration
> Issue Type: Bug
> Components: Type conversion
> Affects Versions: 1.5
> Reporter: Scott Wells
>
> I've found a bug where adding a list property to a BaseConfiguration, then copying that full BaseConfiguration to a DatabaseConfiguration, the list is lost and only the first element is copied to the destination DatabaseConfiguration. For example:
> BaseConfiguration bc = new BaseConfiguration();
> bc.addProperty("myList", Arrays.asList("1", "2", "3", "4");
> DatabaseConfiguration dc = new DatabaseConfiguration(...);
> dc.copy(bc);
> List list = dc.getList("myList");
> // At this point, you'll get a single element list containing only "1"
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CONFIGURATION-342) DatabaseConfiguration.copy()
loses list/array values
Posted by "Scott Wells (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12641975#action_12641975 ]
Scott Wells commented on CONFIGURATION-342:
-------------------------------------------
I've actually written a simple flatten()/unflatten() pair that flattens multi-valued properties when during save and unflattens then during load. You end up with multiple rows in the DB of the form:
<key>.mventry00 value1
<key>.mventry01 value2
<key>.mventry02 value3
but to the API user, things work as expected because those values are aggregated back into an actual list before being passed back. It's not perfect, and it doesn't get to the point where I could marshal/unmarshal a full hierarchical configuration to/from the DB without using a CLOB, but it's a start. I can send you what I have if you're interested...
> DatabaseConfiguration.copy() loses list/array values
> ----------------------------------------------------
>
> Key: CONFIGURATION-342
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-342
> Project: Commons Configuration
> Issue Type: Bug
> Components: Type conversion
> Affects Versions: 1.5
> Reporter: Scott Wells
>
> I've found a bug where adding a list property to a BaseConfiguration, then copying that full BaseConfiguration to a DatabaseConfiguration, the list is lost and only the first element is copied to the destination DatabaseConfiguration. For example:
> BaseConfiguration bc = new BaseConfiguration();
> bc.addProperty("myList", Arrays.asList("1", "2", "3", "4");
> DatabaseConfiguration dc = new DatabaseConfiguration(...);
> dc.copy(bc);
> List list = dc.getList("myList");
> // At this point, you'll get a single element list containing only "1"
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CONFIGURATION-342) DatabaseConfiguration.copy()
loses list/array values
Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12642071#action_12642071 ]
Oliver Heger commented on CONFIGURATION-342:
--------------------------------------------
It would be nice if you could attach your code (or a patch) to this ticket.
However, I am not sure whether the flatten/unflatten approach is the way to go because it violates all rules of good database design and normalization. It would be cool if the table layout used by DatabaseConfiguration could be made customizable, but this is certainly really complex.
> DatabaseConfiguration.copy() loses list/array values
> ----------------------------------------------------
>
> Key: CONFIGURATION-342
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-342
> Project: Commons Configuration
> Issue Type: Bug
> Components: Type conversion
> Affects Versions: 1.5
> Reporter: Scott Wells
>
> I've found a bug where adding a list property to a BaseConfiguration, then copying that full BaseConfiguration to a DatabaseConfiguration, the list is lost and only the first element is copied to the destination DatabaseConfiguration. For example:
> BaseConfiguration bc = new BaseConfiguration();
> bc.addProperty("myList", Arrays.asList("1", "2", "3", "4");
> DatabaseConfiguration dc = new DatabaseConfiguration(...);
> dc.copy(bc);
> List list = dc.getList("myList");
> // At this point, you'll get a single element list containing only "1"
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CONFIGURATION-342) DatabaseConfiguration.copy()
loses list/array values
Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12642624#action_12642624 ]
Oliver Heger commented on CONFIGURATION-342:
--------------------------------------------
This looks interesting. For DatabaseConfiguration to be useful on its own such a feature has to be integrated into this class. E.g. when adding a new property the flattening has to be performed executing multiple inserts if necessary. (BTW I am not sure whether flatten()/unflatten() is the right naming because it can be confused with transforming a hierarchical configuration into a flat one and vice versa.)
Making DatabaseConfiguration a true hierarchical configuration will even be more complex. I assume this was not intended when the class was created, and I would already be happy if we get support for multiple properties right.
> DatabaseConfiguration.copy() loses list/array values
> ----------------------------------------------------
>
> Key: CONFIGURATION-342
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-342
> Project: Commons Configuration
> Issue Type: Bug
> Components: Type conversion
> Affects Versions: 1.5
> Reporter: Scott Wells
> Attachments: ConfigurationUtil.java
>
>
> I've found a bug where adding a list property to a BaseConfiguration, then copying that full BaseConfiguration to a DatabaseConfiguration, the list is lost and only the first element is copied to the destination DatabaseConfiguration. For example:
> BaseConfiguration bc = new BaseConfiguration();
> bc.addProperty("myList", Arrays.asList("1", "2", "3", "4");
> DatabaseConfiguration dc = new DatabaseConfiguration(...);
> dc.copy(bc);
> List list = dc.getList("myList");
> // At this point, you'll get a single element list containing only "1"
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CONFIGURATION-342) DatabaseConfiguration.copy()
loses list/array values
Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12641950#action_12641950 ]
Oliver Heger commented on CONFIGURATION-342:
--------------------------------------------
It seems to me that the support for properties with multiple values in DatabaseConfiguration is broken. I don't know whether it ever worked, but I doubt it. I guess the problem is that when inserting the 2nd value of the property the database throws an exception similar to the following one:
{{java.sql.SQLException: Violation of unique constraint $$: duplicate value(s) for column(s) $$: SYS_PK_47 in statement [INSERT INTO configuration (key, value) VALUES (?, ?)]}}
(This is at least what I get in the unit tests.) This exception is not re-thrown by the configuration, but an error event is fired. If you register an error listener, you will probably see such an event.
I am not sure how to handle this problem. IMO the only solution would be to require an additional database column with a unique ID, so that no unique constraint can be violated. However, then we have to deal with stuff like ID generation, which can be highly specific depending on the use case.
> DatabaseConfiguration.copy() loses list/array values
> ----------------------------------------------------
>
> Key: CONFIGURATION-342
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-342
> Project: Commons Configuration
> Issue Type: Bug
> Components: Type conversion
> Affects Versions: 1.5
> Reporter: Scott Wells
>
> I've found a bug where adding a list property to a BaseConfiguration, then copying that full BaseConfiguration to a DatabaseConfiguration, the list is lost and only the first element is copied to the destination DatabaseConfiguration. For example:
> BaseConfiguration bc = new BaseConfiguration();
> bc.addProperty("myList", Arrays.asList("1", "2", "3", "4");
> DatabaseConfiguration dc = new DatabaseConfiguration(...);
> dc.copy(bc);
> List list = dc.getList("myList");
> // At this point, you'll get a single element list containing only "1"
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Issue Comment Edited: (CONFIGURATION-342)
DatabaseConfiguration.copy() loses list/array values
Posted by "Scott Wells (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12642171#action_12642171 ]
scwells72 edited comment on CONFIGURATION-342 at 10/23/08 7:42 AM:
---------------------------------------------------------------------
Yeah, it's definitely a totally denormalized form of an otherwise normalized structure, especially if you follow it to its logical end of storing entire HierarchicalConfiguration objects. On the other hand, if there were a good mechanism to externalize arbitrarily complex Configuration instances in the simplest of storage formats, e.g., PropertiesConfiguration, I can only imagine it would be incredibly useful.
I could see adding one more column to your current storage table for a parent key such that you'd get proper hierarchical storage in a quite simple table, though. Well, I guess technically if order were important, as it is in lists, then you'd want key, parent key, and index in parent, so a total of two extra columns.
Anyway, I've attached the rough version of flatten()/unflatten(). This is for a proof-of-concept, so don't take this as final code, but it does allow me to successfully marshal/unmarshal multi-value properties.
was (Author: scwells72):
Yeah, it's definitely a totally denormalized form of an otherwise normalized structure, especially if you follow it to its logical end of storing entire HierarchicalConfiguration objects. On the other hand, if there were a good mechanism to externalize arbitrarily complex Configuration instances in the simplest of storage formats, e.g., PropertiesConfiguration, I can only imagine it would be incredibly useful.
I could see adding one more column to your current storage table for a parent key such that you'd get proper hierarchical storage in a quite simple table, though. Well, I guess technically if order were important, as it is in lists, then you'd want key, parent key, and index in parent, so a total of two extra columns.
Anyway, here's the rough version of flatten()/unflatten(). This is for a proof-of-concept, so don't take this as final code, but it does allow me to successfully marshal/unmarshal multi-value properties.
protected static final String FLATTENED_LIST_ITEM_SUFFIX = ".flattenedListItem";
public static Configuration flatten(Configuration configuration)
{
BaseConfiguration flattenedConfiguration = new BaseConfiguration();
for (Iterator it = configuration.getKeys(); it.hasNext();)
{
String key = (String) it.next();
Object value = configuration.getProperty(key);
if (value instanceof Collection)
{
Collection collection = (Collection) value;
// Create a formatting string to ensure that numbers are zero-padded properly
int numPlaces = (int) Math.log10(collection.size()) + 1;
String formatString = "%0" + numPlaces + "d";
// Add each item in the collection distinctly
int i = 0;
for (Object item : collection)
{
String index = String.format(formatString, i);
String flattendedListItemKey = key + FLATTENED_LIST_ITEM_SUFFIX + index;
flattenedConfiguration.setProperty(flattendedListItemKey, item);
i++;
}
}
else
{
flattenedConfiguration.setProperty(key, value);
}
}
return flattenedConfiguration;
}
public static Configuration unflatten(Configuration configuration)
{
BaseConfiguration unflattenedConfiguration = new BaseConfiguration();
// Add to a list that can be sorted by keys first
Map<String, Object> sortedByKeys = new TreeMap<String, Object>();
for (Iterator it = configuration.getKeys(); it.hasNext();)
{
String key = (String) it.next();
Object value = configuration.getProperty(key);
sortedByKeys.put(key, value);
}
for (Map.Entry<String, Object> entry : sortedByKeys.entrySet())
{
String key = entry.getKey();
Object value = entry.getValue();
if (key.contains(FLATTENED_LIST_ITEM_SUFFIX))
{
int chopHere = key.indexOf(FLATTENED_LIST_ITEM_SUFFIX);
String originalKey = key.substring(0, chopHere);
unflattenedConfiguration.addProperty(originalKey, value);
}
else
{
unflattenedConfiguration.setProperty(key, value);
}
> DatabaseConfiguration.copy() loses list/array values
> ----------------------------------------------------
>
> Key: CONFIGURATION-342
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-342
> Project: Commons Configuration
> Issue Type: Bug
> Components: Type conversion
> Affects Versions: 1.5
> Reporter: Scott Wells
>
> I've found a bug where adding a list property to a BaseConfiguration, then copying that full BaseConfiguration to a DatabaseConfiguration, the list is lost and only the first element is copied to the destination DatabaseConfiguration. For example:
> BaseConfiguration bc = new BaseConfiguration();
> bc.addProperty("myList", Arrays.asList("1", "2", "3", "4");
> DatabaseConfiguration dc = new DatabaseConfiguration(...);
> dc.copy(bc);
> List list = dc.getList("myList");
> // At this point, you'll get a single element list containing only "1"
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CONFIGURATION-342) DatabaseConfiguration.copy()
loses list/array values
Posted by "Scott Wells (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12642171#action_12642171 ]
Scott Wells commented on CONFIGURATION-342:
-------------------------------------------
Yeah, it's definitely a totally denormalized form of an otherwise normalized structure, especially if you follow it to its logical end of storing entire HierarchicalConfiguration objects. On the other hand, if there were a good mechanism to externalize arbitrarily complex Configuration instances in the simplest of storage formats, e.g., PropertiesConfiguration, I can only imagine it would be incredibly useful.
I could see adding one more column to your current storage table for a parent key such that you'd get proper hierarchical storage in a quite simple table, though. Well, I guess technically if order were important, as it is in lists, then you'd want key, parent key, and index in parent, so a total of two extra columns.
Anyway, here's the rough version of flatten()/unflatten(). This is for a proof-of-concept, so don't take this as final code, but it does allow me to successfully marshal/unmarshal multi-value properties.
protected static final String FLATTENED_LIST_ITEM_SUFFIX = ".flattenedListItem";
public static Configuration flatten(Configuration configuration)
{
BaseConfiguration flattenedConfiguration = new BaseConfiguration();
for (Iterator it = configuration.getKeys(); it.hasNext();)
{
String key = (String) it.next();
Object value = configuration.getProperty(key);
if (value instanceof Collection)
{
Collection collection = (Collection) value;
// Create a formatting string to ensure that numbers are zero-padded properly
int numPlaces = (int) Math.log10(collection.size()) + 1;
String formatString = "%0" + numPlaces + "d";
// Add each item in the collection distinctly
int i = 0;
for (Object item : collection)
{
String index = String.format(formatString, i);
String flattendedListItemKey = key + FLATTENED_LIST_ITEM_SUFFIX + index;
flattenedConfiguration.setProperty(flattendedListItemKey, item);
i++;
}
}
else
{
flattenedConfiguration.setProperty(key, value);
}
}
return flattenedConfiguration;
}
public static Configuration unflatten(Configuration configuration)
{
BaseConfiguration unflattenedConfiguration = new BaseConfiguration();
// Add to a list that can be sorted by keys first
Map<String, Object> sortedByKeys = new TreeMap<String, Object>();
for (Iterator it = configuration.getKeys(); it.hasNext();)
{
String key = (String) it.next();
Object value = configuration.getProperty(key);
sortedByKeys.put(key, value);
}
for (Map.Entry<String, Object> entry : sortedByKeys.entrySet())
{
String key = entry.getKey();
Object value = entry.getValue();
if (key.contains(FLATTENED_LIST_ITEM_SUFFIX))
{
int chopHere = key.indexOf(FLATTENED_LIST_ITEM_SUFFIX);
String originalKey = key.substring(0, chopHere);
unflattenedConfiguration.addProperty(originalKey, value);
}
else
{
unflattenedConfiguration.setProperty(key, value);
}
> DatabaseConfiguration.copy() loses list/array values
> ----------------------------------------------------
>
> Key: CONFIGURATION-342
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-342
> Project: Commons Configuration
> Issue Type: Bug
> Components: Type conversion
> Affects Versions: 1.5
> Reporter: Scott Wells
>
> I've found a bug where adding a list property to a BaseConfiguration, then copying that full BaseConfiguration to a DatabaseConfiguration, the list is lost and only the first element is copied to the destination DatabaseConfiguration. For example:
> BaseConfiguration bc = new BaseConfiguration();
> bc.addProperty("myList", Arrays.asList("1", "2", "3", "4");
> DatabaseConfiguration dc = new DatabaseConfiguration(...);
> dc.copy(bc);
> List list = dc.getList("myList");
> // At this point, you'll get a single element list containing only "1"
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CONFIGURATION-342) DatabaseConfiguration.copy()
loses list/array values
Posted by "Scott Wells (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12642629#action_12642629 ]
Scott Wells commented on CONFIGURATION-342:
-------------------------------------------
Yeah, for my proof-of-concept against commons config, I decided to do the work outside of the library, but yes, it should be encapsulated within the DatabaseConfiguration class, not external to it. And yes, this is only intended to help with multi-valued properties, not yet with true hierarchical structures. It wouldn't be hard to imagine a similar flattening for full hierarchies that uses the XPath format for storing keys, though.
If this is something that interests you, I'd be happy to work with you on an implementation that addresses both issues. I looked briefly at what it would take to perform a traversal of a HierarchicalConfiguration and didn't quite "get it" at first glance. It'd be nice if there were a simple way to perform depth- and/or breadth-first traversals via a Visitor pattern or something.
What are your thoughts? It looks at this point as if we're going to proceed with commons config for our next phase of the product, and my goals are the ability to store rich config data (including components with sub-components) in the DB but, with a line or two of code, enable import/export via XML. I can do that now, but the richness of the data is limited because of the way that DatabaseConfiguration "loses" multi-valued properties and hierarchies. I can imagine this same mechanism would be broadly useful.
> DatabaseConfiguration.copy() loses list/array values
> ----------------------------------------------------
>
> Key: CONFIGURATION-342
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-342
> Project: Commons Configuration
> Issue Type: Bug
> Components: Type conversion
> Affects Versions: 1.5
> Reporter: Scott Wells
> Attachments: ConfigurationUtil.java
>
>
> I've found a bug where adding a list property to a BaseConfiguration, then copying that full BaseConfiguration to a DatabaseConfiguration, the list is lost and only the first element is copied to the destination DatabaseConfiguration. For example:
> BaseConfiguration bc = new BaseConfiguration();
> bc.addProperty("myList", Arrays.asList("1", "2", "3", "4");
> DatabaseConfiguration dc = new DatabaseConfiguration(...);
> dc.copy(bc);
> List list = dc.getList("myList");
> // At this point, you'll get a single element list containing only "1"
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (CONFIGURATION-342) DatabaseConfiguration.copy()
loses list/array values
Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CONFIGURATION-342?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Oliver Heger updated CONFIGURATION-342:
---------------------------------------
Fix Version/s: 1.7
> DatabaseConfiguration.copy() loses list/array values
> ----------------------------------------------------
>
> Key: CONFIGURATION-342
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-342
> Project: Commons Configuration
> Issue Type: Bug
> Components: Type conversion
> Affects Versions: 1.5
> Reporter: Scott Wells
> Fix For: 1.7
>
> Attachments: ConfigurationUtil.java
>
>
> I've found a bug where adding a list property to a BaseConfiguration, then copying that full BaseConfiguration to a DatabaseConfiguration, the list is lost and only the first element is copied to the destination DatabaseConfiguration. For example:
> BaseConfiguration bc = new BaseConfiguration();
> bc.addProperty("myList", Arrays.asList("1", "2", "3", "4");
> DatabaseConfiguration dc = new DatabaseConfiguration(...);
> dc.copy(bc);
> List list = dc.getList("myList");
> // At this point, you'll get a single element list containing only "1"
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.