org.datanucleus.sco.backed.ArrayList cannot be cast to java.util.Set

时光怂恿深爱的人放手 提交于 2019-12-23 23:32:56

问题


Since 4 days ago, in random short periods of time, my deployed application is throwing this error:

org.datanucleus.sco.backed.ArrayList cannot be cast to java.util.Set

We are using GWT 2.4 / Java 1.7 (We recently migrate from 1.6 to 1.7)

It happens when retrieving or persisting an entity with a String set:

import java.util.HashSet;
import java.util.Set;
...
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class DbAccount {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;
...
    @Persistent
    private Set<String> accounts;
...
    public DbAccount(SerAccount account) throws Exception {
        ...
        this.accounts= new HashSet<String>();
        ...
        key = KeyFactory.createKey(DbCuentas.class.getSimpleName(), this.id);
    }
}

I have checked my entire project for a reference to org.datanucleus.sco.backed.ArrayList and it does not exist.

Any idea?


回答1:


It may sound stupid, but have you tried to use List instead of Set ?

After checking out the docs again, I can't find any example from Google with a Collection other than List.

Reading your issue, it looks like the JPA datanucleus impl is indeed using their own ArrayList implementation whatever you do. I don't know why the problem happens randomly though...



来源:https://stackoverflow.com/questions/22307734/org-datanucleus-sco-backed-arraylist-cannot-be-cast-to-java-util-set

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!