SpringDataGraph findByProperty 不适用于 Neo4J
当我运行下面的代码时,将创建一个具有预期属性的新用户。 (运行测试后我与 Neoclipse 确认)。但是,findByPropertyValue
无法检索用户。它只是返回 null。当我调试时,我发现 usrFromDb1
似乎只包含空值,甚至我后来确认的那些值实际上已保存在数据库中! 有人有解决办法吗?
@Test(enabled = true, groups = {"functest"})
public void shouldGetUserDetails() throws Exception {
User user = new User("admin", "secretpw").persist();
User usrFromDb1 = userRepository.findOne(user.getId());
assertNotNull(usr1); //succeeds
User usrFromDb2 = userRepository.findByPropertyValue("username", "admin");
assertNotNull(usr2); //fails
}
When I run the code below, a new User with the expected properties is created. (I confirm with Neoclipse after running the test). However, findByPropertyValue
fails to retrieve the user. It just returns null. When I debug I find that usrFromDb1
only seems to contain null-values, even those values that I later confirmed were infact saved in the databse!
Does anyone have an idea for a solution?
@Test(enabled = true, groups = {"functest"})
public void shouldGetUserDetails() throws Exception {
User user = new User("admin", "secretpw").persist();
User usrFromDb1 = userRepository.findOne(user.getId());
assertNotNull(usr1); //succeeds
User usrFromDb2 = userRepository.findByPropertyValue("username", "admin");
assertNotNull(usr2); //fails
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的用户名属性上是否有
@Indexed
属性。您能否显示您的
User
类?在这种映射模式下,调试 b/c 中的用户字段为 null,它们由 AspectJ 透明处理,如果您在调试器中调用
user.getUserName()
,这应该会产生该值。此外,断言中的变量名称与查询结果中的变量名称不匹配
.eg
usrFromDb2
与usr2
Do you have an
@Indexed
property on your username attribute.Could you please show your
User
class?The user's fields are null in debug b/c in this mapping mode they are handled transparently by AspectJ, if you call
user.getUserName()
in the debugger this should yield the value.Also the variable names in your asserts don't match those from your query-results
.e.g
usrFromDb2
vs.usr2