- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Spring数据neo4j版本:3.3.0.RELEASENeo4j版本:2.2.2
当我尝试查询 spring-data 存储库上公开的默认方法时,我遇到了以下异常,即
personRepository.findAll(getDefaultPageable());
public static Pageable getDefaultPageable() {
BiFunction<Integer, Integer, Pageable> biFunction = PageRequest::new; // Method reference syntax in action
return biFunction.apply(DEFAULT_PAGE_NUMBER, DEFAULT_PAGE_SIZE);
}
Caused by: java.lang.IllegalStateException: No primary SDN label exists .. (i.e one starting with _) at org.springframework.data.neo4j.support.typerepresentation.LabelBasedNodeTypeRepresentationStrategy.readAliasFrom(LabelBasedNodeTypeRepresentationStrategy.java:136) at org.springframework.data.neo4j.support.typerepresentation.LabelBasedNodeTypeRepresentationStrategy.readAliasFrom(LabelBasedNodeTypeRepresentationStrategy.java:40) at org.springframework.data.neo4j.support.mapping.TRSTypeAliasAccessor.readAliasFrom(TRSTypeAliasAccessor.java:36) at org.springframework.data.neo4j.support.mapping.TRSTypeAliasAccessor.readAliasFrom(TRSTypeAliasAccessor.java:26) at org.springframework.data.convert.DefaultTypeMapper.readType(DefaultTypeMapper.java:102) at org.springframework.data.convert.DefaultTypeMapper.getDefaultedTypeToBeUsed(DefaultTypeMapper.java:165) at org.springframework.data.convert.DefaultTypeMapper.readType(DefaultTypeMapper.java:142) at org.springframework.data.neo4j.support.mapping.Neo4jEntityConverterImpl.read(Neo4jEntityConverterImpl.java:77) at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister$CachedConverter.read(Neo4jEntityPersister.java:170) at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister.createEntityFromState(Neo4jEntityPersister.java:189) at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister.projectTo(Neo4jEntityPersister.java:216) at org.springframework.data.neo4j.support.Neo4jTemplate.projectTo(Neo4jTemplate.java:241) at org.springframework.data.neo4j.support.conversion.EntityResultConverter.doConvert(EntityResultConverter.java:73) at org.springframework.data.neo4j.conversion.DefaultConverter.convert(DefaultConverter.java:44) at org.springframework.data.neo4j.support.conversion.EntityResultConverter.convert(EntityResultConverter.java:165) at org.springframework.data.neo4j.conversion.QueryResultBuilder$1.underlyingObjectToObject(QueryResultBuilder.java:86) at org.neo4j.helpers.collection.IterableWrapper$MyIteratorWrapper.underlyingObjectToObject(IterableWrapper.java:57) at org.neo4j.helpers.collection.IteratorWrapper.next(IteratorWrapper.java:47) at org.springframework.data.neo4j.repository.AbstractGraphRepository.subList(AbstractGraphRepository.java:371) at org.springframework.data.neo4j.repository.AbstractGraphRepository.extractPage(AbstractGraphRepository.java:355) at org.springframework.data.neo4j.repository.AbstractGraphRepository.findAll(AbstractGraphRepository.java:321) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:414) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:399) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:371) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) at com.sun.proxy.$Proxy60.findAll(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:201) at com.sun.proxy.$Proxy61.findAll(Unknown Source)
我真的不想在这里做任何复杂的事情,所以我很难理解我是否真的应该引入带有下划线前缀标签的自定义查询并使用注释@Query? Spring 数据中的默认方法不是只适用于 SDN 吗?
<小时/>我调整了密码查询,但仍然出现相同的错误。
used by: java.lang.IllegalStateException: No primary SDN label exists .. (i.e one starting with _) at org.springframework.data.neo4j.support.typerepresentation.LabelBasedNodeTypeRepresentationStrategy.readAliasFrom(LabelBasedNodeTypeRepresentationStrategy.java:136) at org.springframework.data.neo4j.support.typerepresentation.LabelBasedNodeTypeRepresentationStrategy.readAliasFrom(LabelBasedNodeTypeRepresentationStrategy.java:40) at org.springframework.data.neo4j.support.mapping.TRSTypeAliasAccessor.readAliasFrom(TRSTypeAliasAccessor.java:36) at org.springframework.data.neo4j.support.mapping.TRSTypeAliasAccessor.readAliasFrom(TRSTypeAliasAccessor.java:26) at org.springframework.data.convert.DefaultTypeMapper.readType(DefaultTypeMapper.java:102) at org.springframework.data.convert.DefaultTypeMapper.getDefaultedTypeToBeUsed(DefaultTypeMapper.java:165) at org.springframework.data.convert.DefaultTypeMapper.readType(DefaultTypeMapper.java:142) at org.springframework.data.neo4j.support.mapping.Neo4jEntityConverterImpl.read(Neo4jEntityConverterImpl.java:77) at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister$CachedConverter.read(Neo4jEntityPersister.java:170) at org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister.createEntityFromState(Neo4jEntityPersister.java:189) at org.springframework.data.neo4j.support.Neo4jTemplate.createEntityFromState(Neo4jTemplate.java:224)
你能看一下这些类(class),让我知道我哪里做错了,哪里做错了吗?
这是存储库类
public interface PersonRepository extends GraphRepository<Person>, CypherDslRepository<Person> {
String PERSONS_WITH_SEVERAL_ACME_IDENTITY = "MATCH (p:Person)-[r:HAS_LOGIN]->(a:AcmeIdp) " +
"SET p:_Person, a:_AcmeIdp "+
"WITH p, count(p) AS numoutgoing " +
"WHERE numoutgoing > 1 " +
"MATCH (p:Person)-[r:HAS_LOGIN]->(a:AcmeIdp) " +
"SET p:_Person, a:_AcmeIdp "+
"RETURN p";
Iterable<Person> findByFirstNameAndLastName(@NonNull final String firstName,@NonNull final String lastName);
Page<Person> findByFirstNameLike(@NonNull final String firstName,@NonNull final Pageable pageable);
@Query(PERSONS_WITH_SEVERAL_ACME_IDENTITY)
Page<Person> findOnesWithSeveralAcmeIdentities(@NonNull final Pageable pageable); }
人员实体类
import com.example.analytics.model.AbstractEntity;
import com.example.analytics.model.relationship.Login;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.neo4j.graphdb.Direction;
import org.springframework.data.neo4j.annotation.*;
import java.time.LocalDateTime;
import java.util.Set;
@NodeEntity(useShortNames = true)
public class Person extends AbstractEntity {
@GraphProperty(propertyName = "title", defaultValue = "")
private String title;
@GraphProperty(propertyName = "firstName", defaultValue = "")
private String firstName;
@GraphProperty(propertyName = "lastName", defaultValue = "")
private String lastName;
@GraphProperty(propertyName = "dateOfBirth", propertyType = String.class)
private LocalDateTime dateOfBirth;
@RelatedTo(type = "HAS_LOGIN", direction = Direction.OUTGOING, elementClass = AcmeIdentity.class)
private Set<Login> logins;
public String getTitle() {
return title;
}
public void setTitle(final String title) {
this.title = title;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(final String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(final String lastName) {
this.lastName = lastName;
}
public LocalDateTime getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(final LocalDateTime dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
public Set<Login> getLogins() {
return logins;
}
public void setLogins(@NonNull final Set<Login> logins) {
this.logins = logins;
}
}
转换器
import org.checkerframework.checker.nullness.qual.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@Component
public class LocalDateTimeToStringConverter implements Converter<LocalDateTime, String> {
private static final Logger LOG = LoggerFactory.getLogger(LocalDateTimeToStringConverter.class);
@Value("${neo4j.dateTime.format:yyyy-MM-dd HH:mm:ss}")
private String dateTimeFormat;
@Override
public String convert(@NonNull final LocalDateTime source) {
LOG.debug("Converting LocalDateTime into String using the format: {}", dateTimeFormat);
return String.valueOf(source.format(DateTimeFormatter.ofPattern(dateTimeFormat)));
}
}
反向转换器
import org.checkerframework.checker.nullness.qual.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@Component
public class StringToLocalDateTimeConverter implements Converter<String, LocalDateTime> {
private static final Logger LOG = LoggerFactory.getLogger(StringToLocalDateTimeConverter.class);
@Value("${neo4j.dateTime.format:yyyy-MM-dd HH:mm:ss}")
private String dateTimeFormat;
/**
* Convert the source of type S to target type T.
*
* @param source the source object to convert, which must be an instance of S (never {@code null})
* @return the converted object, which must be an instance of T (potentially {@code null})
* @throws IllegalArgumentException if the source could not be converted to the desired target type
*/
@Override
public LocalDateTime convert(@NonNull final String source) {
LOG.debug("Converting String {} into LocalDateTime using the format: {}",source, dateTimeFormat);
return LocalDateTime.parse(source, DateTimeFormatter.ofPattern(dateTimeFormat));
}
}
主要配置类
import com.example.analytics.converter.LocalDateTimeToStringConverter;
import com.example.analytics.converter.StringToLocalDateTimeConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.*;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.converter.ConverterRegistry;
import org.springframework.data.neo4j.config.Neo4jConfiguration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableAutoConfiguration
@EnableTransactionManagement(mode = AdviceMode.PROXY)
@ComponentScan(basePackages = {"com.example.analytics"})
@PropertySource(value = "classpath:application.yml", ignoreResourceNotFound = false)
@Import({DatabaseConnectionConfiguration.class})
public class MainConfiguration extends Neo4jConfiguration {
@Autowired
private StringToLocalDateTimeConverter stringToLocalDateTimeConverter;
@Autowired
private LocalDateTimeToStringConverter localDateTimeToStringConverter;
private static final Logger LOG = LoggerFactory.getLogger(MainConfiguration.class);
public MainConfiguration() {
setBasePackage("com.example.analytics.model");
}
@Bean
public static PropertySourcesPlaceholderConfigurer propertyConfigIn() {
return new PropertySourcesPlaceholderConfigurer();
}
@Bean
@DependsOn({ "stringToLocalDateTimeConverter", "localDateTimeToStringConverter" })
protected ConversionService neo4jConversionService() throws Exception {
LOG.debug("Adding custom converters to conversion service ...");
ConversionService conversionService = super.neo4jConversionService();
ConverterRegistry registry = (ConverterRegistry) conversionService;
registry.addConverter(stringToLocalDateTimeConverter);
registry.addConverter(localDateTimeToStringConverter);
LOG.debug("Addition of Converter from LocalDateTime to String and vice-versa has been completed!");
return conversionService;
}
}
使用存储库的服务片段
public Page<Person> findPersonsWithSeveralAcmeIdentitites(final Pageable pageable) {
LOG.debug("Fetching persons with several ACME identities");
if(pageable != null)
return personRepository.findOnesWithSeveralAcmeIdentities(pageable);
else
return personRepository.findOnesWithSeveralAcmeIdentities(getDefaultPageable());
}
最佳答案
然后,您必须检查节点并在每个节点上调用:
neo4jTemplate.postEntityCreation(node, MyEntity.class);
或者这也应该有效:
MATCH (n:User) set n:_User;
等等
我认为你对 Java8 方法引用过度了!!!只需使用普通的旧new
即可。否则你的代码将来将无法维护。
public static Pageable getDefaultPageable() {
return new PageRequest(DEFAULT_PAGE_NUMBER, DEFAULT_PAGE_SIZE);
}
关于java - 不存在主 SDN 标签..(即以 _ 开头的标签),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30948025/
2种参数:尺寸和价格。目前,我只能单击选择/突出显示尺寸列中的一个,也只能单击选择/突出显示价格列中的一个,而不会影响另一个列中的一个。 当我点击尺寸时,会添加一个 URL 参数“#size=4”。单
在css命名约定中,有什么原因,一些object最好以前缀o-和component开头> 以 c- 开头? 我知道 o- 代表 object 而 c- 代表 component,但为什么不呢?难道我们
这就很迷惑了,一下子,下面的代码就不行了。尝试让我的 Android 很好地显示网页已经显示的内容: HttpClient httpclient = new DefaultHttpClient();
我正在将我的网站发布到我无法控制的 IIS 服务器,我想从代码隐藏中了解它的 URL 是否以“http”或“https”开头。 首先,我在本地尝试了这两种解决方案,都返回了正确的值(“http”):
如果我运行: sbin/start-dfs.sh 然后它实际上并没有启动一个名称节点尽管打印: Starting namenodes on [0.0.0.0] 0.0.0.0: starting na
我正在开发一个包含一些数组的模块。现在我的数组包含: $omearray = array ( '#title' = 'title', 0 = array ( 'another array',
对于 PMD,我希望有一个规则来警告我那些以 my 开头的丑陋变量。 这意味着我必须接受所有不以my开头的变量。 所以,我需要一个正则表达式(re),其行为如下: re.match('myVar')
出于某种奇怪的原因,当我尝试使用 URLConnection 获取网页源时,我在输出中得到“null”。有人可以解释一下吗? 我的方法: public String getPageSource()
如何批量检查某个字符串(记录文本文件中的行)是否以特定单词开头? 我知道如何检查句子/行(字符串)中是否存在单词(子字符串),但我如何检查天气是否以这个词开头? 谢谢:) 最佳答案 这可以通过 FIN
我有一个列表,其中包含多个网址和一些字符串,例如#skipsideNav、#content。我正在从这些字符串中分离出 url if link.startswith('/'): local_u
我有以下 html 标记: 我想选择类 bubble bubble_white 和 bubble bubble_black。我正在考虑下面的代码,但它不起作用: $(".bubbl
我有一个用于文件名验证的正则表达式。在这里: /^[0-9a-zA-Z\^\&\'\@\{\}\[\]\,\$\=\!\-\#\(\)\.\%\+\~\_; ]+$/ 如何更改它以检查文件名不是以
我正在构建一个自动填充函数,它接受一个字符串输入并返回一个字符串建议列表。 Sequelize 的 iLike:query返回出现查询字符串的每个字符串。我想支持查询是前缀的字符串。例如当query=
我首先知道这可能是有史以来看起来最糟糕的正则表达式,但这里是。 我有这个正则表达式 (?:http://)?(?:www.)?youtu(?:be)?.(?:[a-z]){2,3}(?:[a-z/?=
尝试读取文件并根据行创建字典,跳过以#符号开头的行 文件示例: param1=val1 # here is comment 我的功能: def readFromFile(name): conf
我的程序正在读取文本文件并根据文本执行操作。但是文本的第一行是有问题的。显然它以“”开头。这弄乱了我的 startsWith() 检查。 为了理解这个问题,我使用了这段代码: System.ou
我的印象是变量名只能以字母和 _ 开头,但是在测试时,我还发现变量名可以以 $ 开头,如下所示: 代码 #include int main() { int myvar=13; int
我试过这个... Dim myMatches As String() = System.Text.RegularExpressions.Regex.Split(postRow.Item("Post")
开头
我正在使用CKEditor,默认情况下在内容的开头添加了。 即使将enterMode设置为,它也只会影响Enter键的作用,并保留开始的。 我遇到的问题是,如果文本以标记开头,它将围绕它包装,并且图像
我有一个List ,其中有五个字符串: abc def ghi jkl mno 我还有另一个字符串“pq”,我需要知道列表中的每个字符串是否都不以“pq”开头-我将如何使用LINQ(.NET 4.0)
我是一名优秀的程序员,十分优秀!