
|
If you were logged in you would be able to see more operations.
|
|
|
db4o Core
Created: 01/Aug/07 11:02 AM
Updated: 06/Aug/07 02:25 PM
|
|
| Component/s: |
Build
|
| Affects Version/s: |
None
|
| Fix Version/s: |
None
|
|
|
Time Tracking:
|
|
Original Estimate:
|
Not Specified
|
|
|
Remaining Estimate:
|
0h
|
|
|
Time Spent:
|
1h
|
|
|
|
|
File Attachments:
|
1.
map_issue.zip (3 kb)
|
|
Environment:
|
Windows XP Pro V5.1 SP2
|
|
| Iteration: |
2
|
| Resolution Date: |
06/Aug/07 02:25 PM
|
| First Response Date: |
02/Aug/07 04:49 PM
|
| Labels: |
|
| Participants: |
Lance Buchan and Norberto Goussies
|
| Number of Attachments: |
1
|
| Number of Comments: |
2
|
|
When using a Wrapper type in a HashMap<String, Wrapper>, where Wrapper itself contains a HashMap<String, Bean> as a property, the Bean object is not retrieved properly. Bean itself contains String properties, which are used in hashCode(), toString() etc, so on retrieval the system fails due to NPE.
So the pattern is as follows:
Map<String, Bean> m1 = new HashMap<String, Bean>();
m1.put("BEAN1", new Bean("val1", "val2"));
m1.put("BEAN2", new Bean("val1", "val2"));
Wrapper w = new Wrapper(m1);
Map<String, Wrapper> m2 = new QueryableMap<String, Wrapper>(); // QueryableMap simply extends HashMap and adds an id property
m2.put("WRAPPER1", w);
When I try and retrieve m2, the internal Bean object is simply not fully defined (properties remain null).
Tested with both 6.1 and 6.3.201.
|
|
Description
|
When using a Wrapper type in a HashMap<String, Wrapper>, where Wrapper itself contains a HashMap<String, Bean> as a property, the Bean object is not retrieved properly. Bean itself contains String properties, which are used in hashCode(), toString() etc, so on retrieval the system fails due to NPE.
So the pattern is as follows:
Map<String, Bean> m1 = new HashMap<String, Bean>();
m1.put("BEAN1", new Bean("val1", "val2"));
m1.put("BEAN2", new Bean("val1", "val2"));
Wrapper w = new Wrapper(m1);
Map<String, Wrapper> m2 = new QueryableMap<String, Wrapper>(); // QueryableMap simply extends HashMap and adds an id property
m2.put("WRAPPER1", w);
When I try and retrieve m2, the internal Bean object is simply not fully defined (properties remain null).
Tested with both 6.1 and 6.3.201.
|
Show » |
|
Perform 2 runs, firstly to generate the store.odb file, secondly to actually retrieve data and test the completeness of retrieval.
The console should output the following for the two runs:
Run1:
Test.init; shows Map retrieval issue, Db4o version: db4o 6.3.201
Test.init, no stored data, creating newly...
Test.init, QueryableMap created newly, stored data:
Map value [Wrapper.toString()]: Order_1:Order_2
Test.init, done; re-run Test to retrieve and output data from <store.odb>
Run2:
Test.init; shows Map retrieval issue, Db4o version: db4o 6.3.201
Test.init, retrieved QueryableMap with 1 values from data store, details:
Retrieved Map value: null_null:null_null
TEST FAILS -> null reference!!!
Notice the output in Run2, where essentially the properties of Bean have remained null.
Thanks
Lance Buchan
Tel +27 76 8513 929