嗨,我有一个用 @Entity 注释的实体类,因此它可以在谷歌应用引擎上使用 JPA 持久化。
我的课看起来像这样:
@Entity
public class DataUrls {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key key;
private String postalCode;
private List<String> urls;
public Key getKey() {
return key;
}
public void setKey(Key key) {
this.key = key;
}
public String getPostalCode() {
return postalCode;
}
public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}
public List<String> getUrls() {
return urls;
}
public void setUrls(List<String> urls) {
this.urls = urls;
}
}
我正在使用 maven 构建我的项目并在编译阶段增强类,在我的日志记录中我看到以下内容:
[INFO] --- maven-datanucleus-plugin:3.1.1:enhance (default) @ grabby-backend ---
[INFO] DataNucleus Enhancer (version 3.1.1) : Enhancement of classes
DataNucleus Enhancer completed with success for 1 classes. Timings : input=181 ms, enhance=60 ms, total=241 ms. Consult the log for full details
[ERROR] --------------------
[ERROR] Standard error from the DataNucleus tool + org.datanucleus.enhancer.DataNucleusEnhancer :
[ERROR] --------------------
[ERROR] Nov 14, 2013 5:00:01 PM org.datanucleus.enhancer.DataNucleusEnhancer <init>
INFO: DataNucleus Enhancer for API "JPA"
Nov 14, 2013 5:00:02 PM org.datanucleus.enhancer.DataNucleusEnhancer main
INFO: DataNucleus Enhancer (version 3.1.1) : Enhancement of classes
Nov 14, 2013 5:00:02 PM org.datanucleus.metadata.MetaDataManager loadFiles
WARNING: Metadata file -enhancerName not found in CLASSPATH
Nov 14, 2013 5:00:02 PM org.datanucleus.metadata.MetaDataManager loadFiles
WARNING: Metadata file ASM not found in CLASSPATH
Nov 14, 2013 5:00:02 PM org.datanucleus.enhancer.AbstractClassEnhancer save
INFO: Writing class file "/Development/datagrabber-backend/grabby- backend/target/classes/com/appspot/datagrabby/model/entities/DataUrls.class" with enhanced definition
Nov 14, 2013 5:00:02 PM org.datanucleus.enhancer.DataNucleusEnhancer addMessage
INFO: DataNucleus Enhancer completed with success for 1 classes. Timings : input=181 ms, enhance=60 ms, total=241 ms. Consult the log for full details
maven 中的配置如下所示:
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>${datanucleus.jpa.version}</version>
<configuration>
<api>JPA</api>
<metadataIncludes>com/appspot/blabla/model/entities/*.class</metadataIncludes>
<verbose>true</verbose>
<enhancerName>ASM</enhancerName>
</configuration>
<dependencies>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>${datanucleus.jpa.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
持久性代码:
public void persistDataURLs(DataUrls dataUrls){
EntityManager em = EMF.getFactory().createEntityManager();
em.persist(dataUrls);
em.close();
}
但是,当我尝试写入数据库时,我收到以下消息:
Type ("XXX") is not that of an entity but needs to be for this operation
我理解应用程序为什么这么说,但是由于增强器插件的日志记录通知该类已增强,我想知道为什么会发生这种情况。