java - No primary SDN label exists .. (i.e one starting with _) -


spring data neo4j version: 3.3.0.release neo4j version: 2.2.2

i ran following exception when tried query default methods exposed on spring-data repository i.e.

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 1 starting _) @ org.springframework.data.neo4j.support.typerepresentation.labelbasednodetyperepresentationstrategy.readaliasfrom(labelbasednodetyperepresentationstrategy.java:136) @ org.springframework.data.neo4j.support.typerepresentation.labelbasednodetyperepresentationstrategy.readaliasfrom(labelbasednodetyperepresentationstrategy.java:40) @ org.springframework.data.neo4j.support.mapping.trstypealiasaccessor.readaliasfrom(trstypealiasaccessor.java:36) @ org.springframework.data.neo4j.support.mapping.trstypealiasaccessor.readaliasfrom(trstypealiasaccessor.java:26) @ org.springframework.data.convert.defaulttypemapper.readtype(defaulttypemapper.java:102) @ org.springframework.data.convert.defaulttypemapper.getdefaultedtypetobeused(defaulttypemapper.java:165) @ org.springframework.data.convert.defaulttypemapper.readtype(defaulttypemapper.java:142) @ org.springframework.data.neo4j.support.mapping.neo4jentityconverterimpl.read(neo4jentityconverterimpl.java:77) @ org.springframework.data.neo4j.support.mapping.neo4jentitypersister$cachedconverter.read(neo4jentitypersister.java:170) @ org.springframework.data.neo4j.support.mapping.neo4jentitypersister.createentityfromstate(neo4jentitypersister.java:189) @ org.springframework.data.neo4j.support.mapping.neo4jentitypersister.projectto(neo4jentitypersister.java:216) @ org.springframework.data.neo4j.support.neo4jtemplate.projectto(neo4jtemplate.java:241) @ org.springframework.data.neo4j.support.conversion.entityresultconverter.doconvert(entityresultconverter.java:73) @ org.springframework.data.neo4j.conversion.defaultconverter.convert(defaultconverter.java:44) @ org.springframework.data.neo4j.support.conversion.entityresultconverter.convert(entityresultconverter.java:165) @ org.springframework.data.neo4j.conversion.queryresultbuilder$1.underlyingobjecttoobject(queryresultbuilder.java:86) @ org.neo4j.helpers.collection.iterablewrapper$myiteratorwrapper.underlyingobjecttoobject(iterablewrapper.java:57) @ org.neo4j.helpers.collection.iteratorwrapper.next(iteratorwrapper.java:47) @ org.springframework.data.neo4j.repository.abstractgraphrepository.sublist(abstractgraphrepository.java:371) @ org.springframework.data.neo4j.repository.abstractgraphrepository.extractpage(abstractgraphrepository.java:355) @ org.springframework.data.neo4j.repository.abstractgraphrepository.findall(abstractgraphrepository.java:321) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:497) @ org.springframework.data.repository.core.support.repositoryfactorysupport$queryexecutormethodinterceptor.executemethodon(repositoryfactorysupport.java:414) @ org.springframework.data.repository.core.support.repositoryfactorysupport$queryexecutormethodinterceptor.doinvoke(repositoryfactorysupport.java:399) @ org.springframework.data.repository.core.support.repositoryfactorysupport$queryexecutormethodinterceptor.invoke(repositoryfactorysupport.java:371) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) @ org.springframework.data.projection.defaultmethodinvokingmethodinterceptor.invoke(defaultmethodinvokingmethodinterceptor.java:61) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) @ org.springframework.transaction.interceptor.transactioninterceptor$1.proceedwithinvocation(transactioninterceptor.java:99) @ org.springframework.transaction.interceptor.transactionaspectsupport.invokewithintransaction(transactionaspectsupport.java:281) @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:96) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) @ org.springframework.dao.support.persistenceexceptiontranslationinterceptor.invoke(persistenceexceptiontranslationinterceptor.java:136) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:207) @ com.sun.proxy.$proxy60.findall(unknown source) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:497) @ org.springframework.aop.support.aoputils.invokejoinpointusingreflection(aoputils.java:317) @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:201) @ com.sun.proxy.$proxy61.findall(unknown source)

i not trying complicated here i'm struggling understand if should introduce custom query underscore prefixed labels , use annotation @query it? don't default methods spring data work on sdn?


## update ##

i adapted cypher query , still ended same error.

used by: java.lang.illegalstateexception: no primary sdn label exists .. (i.e 1 starting _) @ org.springframework.data.neo4j.support.typerepresentation.labelbasednodetyperepresentationstrategy.readaliasfrom(labelbasednodetyperepresentationstrategy.java:136) @ org.springframework.data.neo4j.support.typerepresentation.labelbasednodetyperepresentationstrategy.readaliasfrom(labelbasednodetyperepresentationstrategy.java:40) @ org.springframework.data.neo4j.support.mapping.trstypealiasaccessor.readaliasfrom(trstypealiasaccessor.java:36) @ org.springframework.data.neo4j.support.mapping.trstypealiasaccessor.readaliasfrom(trstypealiasaccessor.java:26) @ org.springframework.data.convert.defaulttypemapper.readtype(defaulttypemapper.java:102) @ org.springframework.data.convert.defaulttypemapper.getdefaultedtypetobeused(defaulttypemapper.java:165) @ org.springframework.data.convert.defaulttypemapper.readtype(defaulttypemapper.java:142) @ org.springframework.data.neo4j.support.mapping.neo4jentityconverterimpl.read(neo4jentityconverterimpl.java:77) @ org.springframework.data.neo4j.support.mapping.neo4jentitypersister$cachedconverter.read(neo4jentitypersister.java:170) @ org.springframework.data.neo4j.support.mapping.neo4jentitypersister.createentityfromstate(neo4jentitypersister.java:189) @ org.springframework.data.neo4j.support.neo4jtemplate.createentityfromstate(neo4jtemplate.java:224)

can please take @ classes , let me know , i'm doing incorrectly?

here's repository 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) 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); } 

the person entity class

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;     } } 

the converter

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 string using format: {}", datetimeformat);         return string.valueof(source.format(datetimeformatter.ofpattern(datetimeformat)));     }  } 

the reverse converter

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 source of type s target type t.      *      * @param source source object convert, must instance of s (never {@code null})      * @return converted object, must instance of t (potentially {@code null})      * @throws illegalargumentexception if source not converted desired target type      */     @override     public localdatetime convert(@nonnull final string source) {         log.debug("converting string {} localdatetime using format: {}",source, datetimeformat);         return localdatetime.parse(source, datetimeformatter.ofpattern(datetimeformat));     }  } 

the main configuration class

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 conversion service ...");         conversionservice conversionservice = super.neo4jconversionservice();         converterregistry registry = (converterregistry) conversionservice;         registry.addconverter(stringtolocaldatetimeconverter);         registry.addconverter(localdatetimetostringconverter);         log.debug("addition of converter localdatetime string , vice-versa has been completed!");         return conversionservice;     } } 

snippet of service using repository

public page<person> findpersonswithseveralacmeidentitites(final pageable pageable) {     log.debug("fetching persons several acme identities");      if(pageable != null)         return personrepository.findoneswithseveralacmeidentities(pageable);    else          return personrepository.findoneswithseveralacmeidentities(getdefaultpageable());  } 

you have go on nodes , on each of them call:

neo4jtemplate.postentitycreation(node, myentity.class); 

alternatively should work too:

match (n:user) set n:_user; 

etc.

i think you're overdoing java8 method references !!! use plain old new. otherwise code unmaintainable going forward.

public static pageable getdefaultpageable() {     return new pagerequest(default_page_number, default_page_size); } 

Comments

Popular posts from this blog

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -