1

我有这个对象:

@Entity
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class Channel implements Serializable, Cacheable {



@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
@Id
public Long id;

// NOTE THE PERSISTENT TAGS
@Persistent
private String name;

@Persistent
private boolean hotblocked = false;

........

当我运行 pm.makePersistent(c) (pm 是 PersistenceManager)时,我得到了这个:

An object of class "com.iuculano.tvitaliane.server.types.Channel" uses SingleFieldIdentity using the field "id" yet this field has not had its value set! Either set the field manually, or set a value-strategy for that field.
org.datanucleus.exceptions.NucleusUserException: An object of class "com.iuculano.tvitaliane.server.types.Channel" uses SingleFieldIdentity using the field "id" yet this field has not had its value set! Either set the field manually, or set a value-strategy for that field.
    at org.datanucleus.state.JDOStateManager.setIdentity(JDOStateManager.java:820)
    at org.datanucleus.state.JDOStateManager.internalMakePersistent(JDOStateManager.java:2374)
    at org.datanucleus.state.JDOStateManager.makePersistent(JDOStateManager.java:2357)
    at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1896)
    at org.datanucleus.ObjectManagerImpl.persistObjectWork(ObjectManagerImpl.java:1745)
    at org.datanucleus.ObjectManagerImpl.persistObject(ObjectManagerImpl.java:1602)
    at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:731)
    at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:756)
    at com.iuculano.tvitaliane.server.db.ChannelJDOWrapper.insertChannel(ChannelJDOWrapper.java:45)
    at com.iuculano.tvitaliane.server.scrapers.Import.caricaListaTvita(Import.java:101)
    at com.iuculano.tvitaliane.server.requests.InitialImport.doPost(InitialImport.java:23)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:123)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:61)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:94)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:409)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
18-feb-2013 16.07.53 com.google.appengine.api.taskqueue.dev.UrlFetchJob execute

我不明白这是什么意思,我有 valueStrategy = IdGeneratorStrategy.IDENTITY,我错在哪里?

4

2 回答 2

1

根据此文档,您应该忘记 @id 注释。

于 2013-02-18T16:24:28.733 回答
0

Ok found the solution:

I've two problems:

1) Remove the @id annotation. 2) Remove @Entity

于 2013-02-18T17:00:41.650 回答