GAE 的 JPA Annotation/Metadata 映射
JPA Annotation/Metadata mapping for GAE
我正在尝试完成我计划在 google App Engine 上部署的应用程序的建模。
我有一个baseclass,Account是抽象的,注释如下:
@Entity
@MappedSuperclass
public abstract class Account {
@Id
private Key id;
.....
然后我有 2 个具体的 classes,AdministratorAccount:
@Entity
public class AdministratorAccount extends Account {
和客户帐户:
@Entity
public class CustomerAccount extends Account {
我的 persistence.xml 文件中也声明了所有 3 个。
当我尝试保留 CustomerAccount 时,出现 500 错误:
org.datanucleus.exceptions.NoPersistenceInformationException: The class "com.nucleus.entitymodel.Account" is required to be persistable yet no Meta-Data/Annotations can be found for this class. Please check that the Meta-Data/annotations is defined in a valid file location.
对可能出现的问题有什么想法吗?我尝试按照 GAE 站点上的文档进行 JPA 继承。
注意 Google 关于 JPA 的 warning,考虑迁移到 Objectify 或他们的低级数据存储。
你的警告说你的 JPA 实体 类 没有增强。
Google 的数据存储在 datanucleus 上运行,需要增强 类 的持久性。
这可以使用 Maven 插件完成,例如;
<plugins>
<!-- This plug-in "enhances" your domain model objects (i.e. makes them persistent for datanucleus) -->
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>${datanucleus.version}</version>
<configuration>
<fork>false</fork>
<!-- Make sure this path contains your persistent classes! -->
<mappingIncludes>**/model/*.class</mappingIncludes>
<verbose>true</verbose>
<enhancerName>ASM</enhancerName>
<api>JPA</api>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<dependencies>
<!-- force maven-datanucleus-plugin to use the same version of datanucleus-core -->
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>${datanucleus.version}</version>
</dependency>
</dependencies>
</plugin>
我正在尝试完成我计划在 google App Engine 上部署的应用程序的建模。
我有一个baseclass,Account是抽象的,注释如下:
@Entity
@MappedSuperclass
public abstract class Account {
@Id
private Key id;
.....
然后我有 2 个具体的 classes,AdministratorAccount:
@Entity
public class AdministratorAccount extends Account {
和客户帐户:
@Entity
public class CustomerAccount extends Account {
我的 persistence.xml 文件中也声明了所有 3 个。
当我尝试保留 CustomerAccount 时,出现 500 错误:
org.datanucleus.exceptions.NoPersistenceInformationException: The class "com.nucleus.entitymodel.Account" is required to be persistable yet no Meta-Data/Annotations can be found for this class. Please check that the Meta-Data/annotations is defined in a valid file location.
对可能出现的问题有什么想法吗?我尝试按照 GAE 站点上的文档进行 JPA 继承。
注意 Google 关于 JPA 的 warning,考虑迁移到 Objectify 或他们的低级数据存储。
你的警告说你的 JPA 实体 类 没有增强。 Google 的数据存储在 datanucleus 上运行,需要增强 类 的持久性。 这可以使用 Maven 插件完成,例如;
<plugins>
<!-- This plug-in "enhances" your domain model objects (i.e. makes them persistent for datanucleus) -->
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>${datanucleus.version}</version>
<configuration>
<fork>false</fork>
<!-- Make sure this path contains your persistent classes! -->
<mappingIncludes>**/model/*.class</mappingIncludes>
<verbose>true</verbose>
<enhancerName>ASM</enhancerName>
<api>JPA</api>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<dependencies>
<!-- force maven-datanucleus-plugin to use the same version of datanucleus-core -->
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>${datanucleus.version}</version>
</dependency>
</dependencies>
</plugin>