I'm trying to get started understanding the Neo4J capabilities, but running into a configuration issue.
Here's my Person @NodeEntity:
Code:@NodeEntity(useShortNames = false) public class Person { @GraphId private long id; private String name; @RelatedTo(type = "pets", elementClass = Pet.class) private Set<Pet> pets; public long getId() { return id; } public void setId(long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public String toString() { return "User [id=" + id + ", name=" + name + ", pets=" + pets + "]"; } }
And here's my repository code where I'm trying to use the FindFactory for locating a Person node:
Code:@Repository public class PersonDao { @Autowired private FinderFactory finderFactory; private NodeFinder<Person> finder; @PostConstruct public void init() { finder = finderFactory.createNodeEntityFinder(Person.class); } public List<Person> getAll() { List<Person> retVal = new LinkedList<Person>(); Iterator<Person> itr = finder.findAll().iterator(); while (itr.hasNext()) { retVal.add(itr.next()); } return retVal; } }
Finally, my Java-based config:
My unit test encounters the following error while trying to load the application context:Code:@Configuration @Import({Neo4jConfiguration.class, AppFeatures.class}) public class AppConfig { @Bean(destroyMethod = "shutdown") public EmbeddedGraphDatabase graphDatabaseService() { EmbeddedGraphDatabase retVal = new EmbeddedGraphDatabase( "c:/temp/neoEmbedded"); return retVal; } } @FeatureConfiguration class AppFeatures { @Feature public ComponentScanSpec scan() { return new ComponentScanSpec("org.mycompany.graphexample") .excludeFilters(configPackages()); } @Feature public TxAnnotationDriven txAnnotationDriven() { TxAnnotationDriven retVal = new TxAnnotationDriven(); retVal.mode(AdviceMode.ASPECTJ); return retVal; } private TypeFilter configPackages() { return new RegexPatternTypeFilter(Pattern .compile("org\\.mycompany\\.graphexample\\.AppConfig")); } }
Code:Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personDao' defined in file [C:\Documents and Settings\jq240d\Documents\workspace-sts-2.3.2.RELEASE\org.mycompany.graphexample\bin\org\mycompany\graphexample\PersonDao.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.mycompany.graphexample.PersonDao]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems: Bound mismatch: The type Person is not a valid substitute for the bounded parameter <T extends GraphBacked<Node>> of the type NodeFinder<T> Bound mismatch: The generic method createNodeEntityFinder(Class<T>) of type FinderFactory is not applicable for the arguments (Class<Person>). The inferred type Person is not a valid substitute for the bounded parameter <T extends NodeBacked> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:900) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:455) at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:68) at org.mycompany.graphexample.AnnotationConfigContextLoader.loadContext(AnnotationConfigContextLoader.java:17) at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:280) at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:304) ... 24 more Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.mycompany.graphexample.PersonDao]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems: Bound mismatch: The type Person is not a valid substitute for the bounded parameter <T extends GraphBacked<Node>> of the type NodeFinder<T> Bound mismatch: The generic method createNodeEntityFinder(Class<T>) of type FinderFactory is not applicable for the arguments (Class<Person>). The inferred type Person is not a valid substitute for the bounded parameter <T extends NodeBacked> at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958) ... 38 more Caused by: java.lang.Error: Unresolved compilation problems: Bound mismatch: The type Person is not a valid substitute for the bounded parameter <T extends GraphBacked<Node>> of the type NodeFinder<T> Bound mismatch: The generic method createNodeEntityFinder(Class<T>) of type FinderFactory is not applicable for the arguments (Class<Person>). The inferred type Person is not a valid substitute for the bounded parameter <T extends NodeBacked> at org.mycompany.graphexample.PersonDao.<init>(PersonDao.java:20) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147) ... 40 more


Reply With Quote