我有一个内部类:

@Entity
public class InnerTypes implements Serializable {

    private static final long serialVersionUID = 3839105307661662120L;

    @Id
    public int id;

    public PrimitiveInnerTypes primitiveInnerTypes;

    public PrimitiveInnerTypes getPrimitiveInnerTypes() {
        return primitiveInnerTypes;
    }

    public void setPrimitiveInnerTypes(PrimitiveInnerTypes primitiveInnerTypes) {
        this.primitiveInnerTypes = primitiveInnerTypes;
    }

    @Entity
    public static class PrimitiveInnerTypes implements Serializable {
         //some code ...
    }
}


我在persistence.xml上也有它

<class>pt.ptinovacao.persistencetester.model.InnerTypes$PrimitiveInnerTypes</class>


通过使用$符号(我认为),我得到以下异常:

[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.4.2.v20130514-5956486): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: unexpected token: INNERTYPES$PRIMITIVEINNERTYPES


如果将$符号更改为,我不知道如何解决。我无法访问内部类,因为。仅适用于不同的软件包。我能做什么?

谢谢

最佳答案

JPA规范的第2.1段:


  实体类必须是顶级类。


因此,您不能将嵌套类用于实体。使其成为顶级课程。

09-25 23:10