我正在试图弄清楚为什么一个由250个对象组成的集合的Jackson JSON序列化需要40秒的时间,我认为我已经将其缩小到SDN延迟加载。我正在使用@Fetch,但它似乎仍然要求数据库提供集合中每个节点的每个属性的委托。请忽略任何打字,因为我必须手动输入,因为复制粘贴不是一个选项。请放心,类将按预期进行编译。被序列化的(简化的)类:
@NodeEntity
public class NodeWithDelegate {
@RelatedTo(type="REL_NAME", direction=Direction.OUTGOING)
@Fetch private DelegateNode delegate;
private DelegateNode getInitializedDelegate() {
if (delegate == null) {
delegate = new DelegateNode();
}
return delegate;
}
public String getDelegateAttribute1() {
return delegate == null ? null : delegate.getAttribute1();
}
public void setDelegateAttribute1(String attribute1) {
getInitializedDelegate().setAttribute1(attribute1);
}
....
public String getDelegateAttribute15() {
return delegate == null ? null : delegate.getAttribute15();
}
public void setDelegateAttribute15(String attribute15) {
getInitializedDelegate().setAttribute15(attribute15);
}
}
DelegateNode
类正是您所期望的,只是包含15个字符串或整数或布尔属性的简单@NodeEntity
POJO。
所以有两个问题:
我想我应该提到我正在为neo4j使用rest。
事先非常感谢!
发布于 2015-04-29 07:44:48
我假设您使用的是3.x版本的Spring Neo4j。
这个版本对于REST并不是很优化。如果您启用了密码查询的日志记录,您将看到很多。Log4j示例:
log4j.category.org.springframework.data.neo4j.support.query=DEBUG
您可以使用自定义密码查询和使用@QueryResult注释映射结果来解决这一限制。
https://stackoverflow.com/questions/29826177
复制相似问题