Hi everybody,
I got a strange problem and don't know, where my mistake could be:
I build up a entity Bean with a Container baased persitence field:
public abstract Map getAttributes();
public abstract void setAttributes(Map attribs);
In the create-routine, I am puting a map inside that field or - if the given argument is null, I put there a new java.util.HashMap();
I am adding Attributes there, so I build up a function inside the bean:
public void setAttribute(String key, String obj) {
Map m = getAttributes();
if (m==null) {
m = new HashMap();
setAttributes(m); // could be left away
}
m.put(key,obj);
setAttributes(m);
}
In ejbStore() and ejbLoad() I am just printing the contents of the stored map.
Now I got this strange behavior:
- initialisation works fine. I can give a Map with Attributes. For Example, I can give him the Attributes "testkey" -> "TestObject"
When I am changing a keys, I get:
Adding Key "a1" -> "a1obj"
ejbLoad:
"testkey" -> "TestObject"
ejbStore:
"testkey" -> "TestObject"
"a1" -> "a1obj"
This seems good, but now I am adding "b1" -> "b1obj"
ejbLoad:
"testkey" -> "TestObject"
ejbStore:
"testkey" -> "TestObject"
"b1" -> "b1obj"
So the stored Key "a1" -> "a1obj" is missing!
When I am changing the Key:
ejbLoad:
"testkey" -> "TestObject"
ejbStore:
"testkey" -> "changed"
But when I am queriing the Attributes I got:
"testkey" -> "TestObject"
instead of
"testkey" -> "changed"
again!
Where can be my mistake? I am using
jboss 3.0.4 with MySQL, I build up the datasource as shown in the jca-Example. Adding new Entities works fine. The initial values are stored as they should be, but I cannot change the Attributes!
Maybe somebody could give me a clue, what I can do to fix this.
With kind regards,
Konrad