Forum Stats

  • 3,769,982 Users
  • 2,253,043 Discussions


Exception : Persistent class has non-persistent superclass: java.util.HashMap

Neelkamal-Oracle Member Posts: 15
edited Jun 28, 2016 11:19AM in Berkeley DB Java Edition


I am running into this exception : Persistent class has non-persistent superclass: java.util.HashMap

Here is my class declaration :

public class foo extends HashMap<foo1, foo2[]> { }

From the PersistentProxy documentation looks like it is not allowed : " A proxied class may not be used as a superclass for a persistent class or entity class"

@Persistent(proxyFor = HashMap.class)
public class PersistentProxyForHashMap implements PersistentProxy<HashMap<foo1,foo2[]>> {
  foo1 Key;
  foo2[] Value;

  private PersistentProxyForHashMap() {}

  public HashMap<foo1,foo2[]> convertProxy() {
  HashMap<foo1,foo2[]> h1 = new HashMap<foo1,foo2[]>();
  h1.put(Key, Value);
  return h1;

  public void initializeProxy(HashMap<foo1,foo2[]> arg0) {
  Key = (foo1) arg0.keySet();
  Value = arg0.get(Key);

How can I workaround this restriction ?

Also, I have read that built-in proxy class is available for HashMap. How can i use that ?



  • Greybird-Oracle
    Greybird-Oracle Member Posts: 2,690
    edited Jun 28, 2016 11:19AM


    You cannot extend a non-persistent class, even though it has a proxy.

    Instead, create a persistent class that has a HashMap field, for example:


    public class foo  {

      private HashMap<foo1, foo2[]> map;


    The built-in proxy for HashMap will be used automatically.


This discussion has been closed.