如何将 属性 添加到包含条目 (DataNucleus) 的 Neo4j 数据库 Table?
How to add property to Neo4j database Table that contains entry (DataNucleus)?
我使用 DataNucleus 和 JDO。为了在持久化过程中为 "tables" 创建模式,我使用 datanucleus.schema.autoCreateAll=true
告诉 DataNucleus 自动创建模式。一旦我对 Table 进行了任何尝试,将字段添加到模型结果到 org.neo4j.graphdb.NotFoundException: NODE[68] has no property with propertyKey="newFieldName"
。
更改或添加属性到已包含条目的 Table 的最佳方法是什么?
这是堆栈跟踪。
2017-12-27 13:46:08.509 [qtp1955990522-68] Query - JDOQL Query : Executing "SELECT FROM com.hope.tub.neo4j.jdo.model.Product WHERE name.equals(value) PARAMETERS String value" ...
2017-12-27 13:46:08.509 [qtp1955990522-68] Native - Retrieving objects of type com.hope.tub.neo4j.jdo.model.Product using Cypher query : START this=node:DN_TYPES(class="com.hope.tub.neo4j.jdo.model.Product") RETURN this
[INFO ] 2017-12-27 13:46:08.537 [qtp1955990522-68] Query - Reading in results for query "SELECT FROM com.hope.tub.neo4j.jdo.model.Product WHERE name.equals(value) PARAMETERS String value" since the connection used is closing/committing
2017-12-27 13:46:08.539 [qtp1955990522-68] Cache - Object with id "com.hope.tub.neo4j.jdo.model.Product:11" not found in Level 1 cache
2017-12-27 13:46:08.540 [qtp1955990522-68] Cache - Object "com.hope.tub.neo4j.jdo.model.Product@74e1d24" (id="com.hope.tub.neo4j.jdo.model.Product:11") added to Level 1 cache (loadedFlags="[NNNYNNNNNNN]")
2017-12-27 13:46:08.567 [qtp1955990522-68] Connection - Managed connection org.datanucleus.store.neo4j.ConnectionFactoryImpl$ManagedConnectionImpl@7e678a93 [conn=org.neo4j.kernel.impl.factory.GraphDatabaseFacade@18f961ba, commitOnRelease=true, closeOnRelease=true, closeOnTxnEnd=false] is committing
2017-12-27 13:46:08.567 [qtp1955990522-68] Connection - Managed connection org.datanucleus.store.neo4j.ConnectionFactoryImpl$ManagedConnectionImpl@7e678a93 [conn=org.neo4j.kernel.impl.factory.GraphDatabaseFacade@18f961ba, commitOnRelease=true, closeOnRelease=true, closeOnTxnEnd=false] committed connection
2017-12-27 13:46:08.568 [qtp1955990522-68] Persistence - Disconnecting com.hope.tub.neo4j.jdo.model.Product@74e1d24 from StateManager[pc=com.hope.tub.neo4j.jdo.model.Product@74e1d24, lifecycle=HOLLOW]
2017-12-27 13:46:08.568 [qtp1955990522-68] Cache - Level 1 Cache cleared
2017-12-27 13:46:08.568 [qtp1955990522-68] Persistence - ExecutionContext CLOSED "org.datanucleus.ExecutionContextImpl@7464295a"
2017-12-27 13:46:08.568 [qtp1955990522-68] Transaction - Transaction rolling back for ExecutionContext org.datanucleus.ExecutionContextImpl@59f25f8e
2017-12-27 13:46:08.568 [qtp1955990522-68] Transaction - Rolling back [DataNucleus Transaction, ID=1608044257-5, enlisted resources=[]]
2017-12-27 13:46:08.568 [qtp1955990522-68] Transaction - Transaction rolled back in 0 ms
2017-12-27 13:46:08.569 [qtp1955990522-68] Persistence - ExecutionContext CLOSED "org.datanucleus.ExecutionContextImpl@59f25f8e"
Dec 27, 2017 1:46:08 PM com.hope.tub.servlets.TuCreateServlet doPost
SEVERE: null
org.neo4j.graphdb.NotFoundException: NODE[11] has no property with propertyKey="creatorID".
at org.neo4j.kernel.impl.core.NodeProxy.getProperty(NodeProxy.java:479)
at org.datanucleus.store.neo4j.fieldmanager.FetchFieldManager.fetchLongField(FetchFieldManager.java:157)
at org.datanucleus.state.StateManagerImpl.replacingLongField(StateManagerImpl.java:1912)
at com.hope.tub.neo4j.jdo.model.Product.dnReplaceField(Product.java)
at com.hope.tub.neo4j.jdo.model.Product.dnReplaceFields(Product.java)
at org.datanucleus.state.StateManagerImpl.replaceFields(StateManagerImpl.java:4286)
at org.datanucleus.state.StateManagerImpl.replaceFields(StateManagerImpl.java:4311)
at org.datanucleus.store.neo4j.Neo4jUtils.fetchFields(Neo4jUtils.java:605)
at org.datanucleus.state.StateManagerImpl.loadFieldValues(StateManagerImpl.java:3719)
at org.datanucleus.store.neo4j.Neo4jUtils.getObjectUsingApplicationIdForDBObject(Neo4jUtils.java:601)
at org.datanucleus.store.neo4j.Neo4jUtils.getObjectForPropertyContainer(Neo4jUtils.java:565)
at org.datanucleus.store.neo4j.query.LazyLoadQueryResult.getResultFromMapRow(LazyLoadQueryResult.java:153)
at org.datanucleus.store.neo4j.query.LazyLoadQueryResult.closingConnection(LazyLoadQueryResult.java:136)
at org.datanucleus.store.query.AbstractQueryResult.disconnect(AbstractQueryResult.java:105)
at org.datanucleus.store.neo4j.query.JDOQLQuery.performExecute(JDOQLQuery.java:291)
at org.datanucleus.store.query.Query.executeQuery(Query.java:1966)
at org.datanucleus.store.query.Query.executeWithArray(Query.java:1855)
at org.datanucleus.api.jdo.JDOQuery.executeInternal(JDOQuery.java:433)
at org.datanucleus.api.jdo.JDOQuery.execute(JDOQuery.java:276)
at com.hope.tub.neo4j.jdo.services.impl.ProductNeo4jServiceImpl.findByName(ProductNeo4jServiceImpl.java:76)
at com.hope.tub.neo4j.jdo.services.impl.ProductNeo4jServiceImpl.save(ProductNeo4jServiceImpl.java:90)
at com.hope.tub.neo4j.jdo.services.impl.ProductNeo4jServiceImpl.save(ProductNeo4jServiceImpl.java:24)
at com.hope.tub.access.beans.ProductBean.createProduct(ProductBean.java:135)
at com.hope.tub.servlets.TuCreateServlet.createProduct(TuCreateServlet.java:107)
at com.hope.tub.servlets.TuCreateServlet.doPost(TuCreateServlet.java:57)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:848)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1772)
at com.hope.tub.filters.ValidateJsonAntiForgeryTokenFilter.doFilter(ValidateJsonAntiForgeryTokenFilter.java:254)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1751)
at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:205)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFil[INFO ] 2017-12-27 13:46:08.571 [qtp1955990522-68] / - ValidateJsonAntiForgeryTokenFilter:DoAfterProcessing
ter(ServletHandler.java:1759)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:582)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
at org.eclipse.jetty.server.handler.ContextHandler.__doHandle(ContextHandler.java:1180)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
at org.eclipse.jetty.server.Server.handle(Server.java:534)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)
at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:267)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
at org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:589)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.neo4j.kernel.api.exceptions.PropertyNotFoundException: NODE[11] has no property with propertyKeyId=29.
at org.neo4j.kernel.impl.core.NodeProxy.getProperty(NodeProxy.java:471)
... 50 more
初始模型:
@PersistenceCapable(identityType = IdentityType.APPLICATION, cacheable = "false", detachable = "true")
public class Product implements Serializable {
private static final long serialVersionUID = 8269335445554701873L;
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
long id;
@Persistent
private String name = null;
...
任何像下面这样添加新的 属性 的尝试都会重现上面的堆栈跟踪。
...
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
long id;
@Persistent
private String name = null;
@Persistent
private long creatorID;
...
目前不满足缺失的(非字符串)列。也就是说,它假定存储在 Neo4j 数据库中的对象与用于检索它们的模型一致。
已在 GitHub 中修复。 https://github.com/datanucleus/datanucleus-neo4j/issues/32
我使用 DataNucleus 和 JDO。为了在持久化过程中为 "tables" 创建模式,我使用 datanucleus.schema.autoCreateAll=true
告诉 DataNucleus 自动创建模式。一旦我对 Table 进行了任何尝试,将字段添加到模型结果到 org.neo4j.graphdb.NotFoundException: NODE[68] has no property with propertyKey="newFieldName"
。
更改或添加属性到已包含条目的 Table 的最佳方法是什么?
这是堆栈跟踪。
2017-12-27 13:46:08.509 [qtp1955990522-68] Query - JDOQL Query : Executing "SELECT FROM com.hope.tub.neo4j.jdo.model.Product WHERE name.equals(value) PARAMETERS String value" ...
2017-12-27 13:46:08.509 [qtp1955990522-68] Native - Retrieving objects of type com.hope.tub.neo4j.jdo.model.Product using Cypher query : START this=node:DN_TYPES(class="com.hope.tub.neo4j.jdo.model.Product") RETURN this
[INFO ] 2017-12-27 13:46:08.537 [qtp1955990522-68] Query - Reading in results for query "SELECT FROM com.hope.tub.neo4j.jdo.model.Product WHERE name.equals(value) PARAMETERS String value" since the connection used is closing/committing
2017-12-27 13:46:08.539 [qtp1955990522-68] Cache - Object with id "com.hope.tub.neo4j.jdo.model.Product:11" not found in Level 1 cache
2017-12-27 13:46:08.540 [qtp1955990522-68] Cache - Object "com.hope.tub.neo4j.jdo.model.Product@74e1d24" (id="com.hope.tub.neo4j.jdo.model.Product:11") added to Level 1 cache (loadedFlags="[NNNYNNNNNNN]")
2017-12-27 13:46:08.567 [qtp1955990522-68] Connection - Managed connection org.datanucleus.store.neo4j.ConnectionFactoryImpl$ManagedConnectionImpl@7e678a93 [conn=org.neo4j.kernel.impl.factory.GraphDatabaseFacade@18f961ba, commitOnRelease=true, closeOnRelease=true, closeOnTxnEnd=false] is committing
2017-12-27 13:46:08.567 [qtp1955990522-68] Connection - Managed connection org.datanucleus.store.neo4j.ConnectionFactoryImpl$ManagedConnectionImpl@7e678a93 [conn=org.neo4j.kernel.impl.factory.GraphDatabaseFacade@18f961ba, commitOnRelease=true, closeOnRelease=true, closeOnTxnEnd=false] committed connection
2017-12-27 13:46:08.568 [qtp1955990522-68] Persistence - Disconnecting com.hope.tub.neo4j.jdo.model.Product@74e1d24 from StateManager[pc=com.hope.tub.neo4j.jdo.model.Product@74e1d24, lifecycle=HOLLOW]
2017-12-27 13:46:08.568 [qtp1955990522-68] Cache - Level 1 Cache cleared
2017-12-27 13:46:08.568 [qtp1955990522-68] Persistence - ExecutionContext CLOSED "org.datanucleus.ExecutionContextImpl@7464295a"
2017-12-27 13:46:08.568 [qtp1955990522-68] Transaction - Transaction rolling back for ExecutionContext org.datanucleus.ExecutionContextImpl@59f25f8e
2017-12-27 13:46:08.568 [qtp1955990522-68] Transaction - Rolling back [DataNucleus Transaction, ID=1608044257-5, enlisted resources=[]]
2017-12-27 13:46:08.568 [qtp1955990522-68] Transaction - Transaction rolled back in 0 ms
2017-12-27 13:46:08.569 [qtp1955990522-68] Persistence - ExecutionContext CLOSED "org.datanucleus.ExecutionContextImpl@59f25f8e"
Dec 27, 2017 1:46:08 PM com.hope.tub.servlets.TuCreateServlet doPost
SEVERE: null
org.neo4j.graphdb.NotFoundException: NODE[11] has no property with propertyKey="creatorID".
at org.neo4j.kernel.impl.core.NodeProxy.getProperty(NodeProxy.java:479)
at org.datanucleus.store.neo4j.fieldmanager.FetchFieldManager.fetchLongField(FetchFieldManager.java:157)
at org.datanucleus.state.StateManagerImpl.replacingLongField(StateManagerImpl.java:1912)
at com.hope.tub.neo4j.jdo.model.Product.dnReplaceField(Product.java)
at com.hope.tub.neo4j.jdo.model.Product.dnReplaceFields(Product.java)
at org.datanucleus.state.StateManagerImpl.replaceFields(StateManagerImpl.java:4286)
at org.datanucleus.state.StateManagerImpl.replaceFields(StateManagerImpl.java:4311)
at org.datanucleus.store.neo4j.Neo4jUtils.fetchFields(Neo4jUtils.java:605)
at org.datanucleus.state.StateManagerImpl.loadFieldValues(StateManagerImpl.java:3719)
at org.datanucleus.store.neo4j.Neo4jUtils.getObjectUsingApplicationIdForDBObject(Neo4jUtils.java:601)
at org.datanucleus.store.neo4j.Neo4jUtils.getObjectForPropertyContainer(Neo4jUtils.java:565)
at org.datanucleus.store.neo4j.query.LazyLoadQueryResult.getResultFromMapRow(LazyLoadQueryResult.java:153)
at org.datanucleus.store.neo4j.query.LazyLoadQueryResult.closingConnection(LazyLoadQueryResult.java:136)
at org.datanucleus.store.query.AbstractQueryResult.disconnect(AbstractQueryResult.java:105)
at org.datanucleus.store.neo4j.query.JDOQLQuery.performExecute(JDOQLQuery.java:291)
at org.datanucleus.store.query.Query.executeQuery(Query.java:1966)
at org.datanucleus.store.query.Query.executeWithArray(Query.java:1855)
at org.datanucleus.api.jdo.JDOQuery.executeInternal(JDOQuery.java:433)
at org.datanucleus.api.jdo.JDOQuery.execute(JDOQuery.java:276)
at com.hope.tub.neo4j.jdo.services.impl.ProductNeo4jServiceImpl.findByName(ProductNeo4jServiceImpl.java:76)
at com.hope.tub.neo4j.jdo.services.impl.ProductNeo4jServiceImpl.save(ProductNeo4jServiceImpl.java:90)
at com.hope.tub.neo4j.jdo.services.impl.ProductNeo4jServiceImpl.save(ProductNeo4jServiceImpl.java:24)
at com.hope.tub.access.beans.ProductBean.createProduct(ProductBean.java:135)
at com.hope.tub.servlets.TuCreateServlet.createProduct(TuCreateServlet.java:107)
at com.hope.tub.servlets.TuCreateServlet.doPost(TuCreateServlet.java:57)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:848)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1772)
at com.hope.tub.filters.ValidateJsonAntiForgeryTokenFilter.doFilter(ValidateJsonAntiForgeryTokenFilter.java:254)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1751)
at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:205)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFil[INFO ] 2017-12-27 13:46:08.571 [qtp1955990522-68] / - ValidateJsonAntiForgeryTokenFilter:DoAfterProcessing
ter(ServletHandler.java:1759)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:582)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
at org.eclipse.jetty.server.handler.ContextHandler.__doHandle(ContextHandler.java:1180)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
at org.eclipse.jetty.server.Server.handle(Server.java:534)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)
at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:267)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
at org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:589)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.neo4j.kernel.api.exceptions.PropertyNotFoundException: NODE[11] has no property with propertyKeyId=29.
at org.neo4j.kernel.impl.core.NodeProxy.getProperty(NodeProxy.java:471)
... 50 more
初始模型:
@PersistenceCapable(identityType = IdentityType.APPLICATION, cacheable = "false", detachable = "true")
public class Product implements Serializable {
private static final long serialVersionUID = 8269335445554701873L;
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
long id;
@Persistent
private String name = null;
...
任何像下面这样添加新的 属性 的尝试都会重现上面的堆栈跟踪。
...
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
long id;
@Persistent
private String name = null;
@Persistent
private long creatorID;
...
目前不满足缺失的(非字符串)列。也就是说,它假定存储在 Neo4j 数据库中的对象与用于检索它们的模型一致。
已在 GitHub 中修复。 https://github.com/datanucleus/datanucleus-neo4j/issues/32