According to this User Guide, when using advanced mapping mode, any access to properties and relationships will in general read through down to the database. Is that means the whole object will not be fetch and only necessary properties will be read? Correct me if Im wrong.
I am using advanced mapping mode, here is my maven setting (only necessary codes are shown):
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j-aspects</artifactId>
<version>3.3.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.6</version>
</dependency>
.........
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*.*</exclude>
</excludes>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.6</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.8.6</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<outxml>true</outxml>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
<aspectLibrary>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
My Spring Configuration goes well, so I just skip it and save some places.
Here is something strange, when I access User object's lover property's name property, it always return null:
@RelatedTo(type = "loves", direction = Direction.OUTGOING)
private User lover;
and the system println result is :
{id=0, theme=null, name=Pamela, password=2663, lover={id=1, name=null}}
when the @Fetch is added:
@RelatedTo(type = "loves", direction = Direction.OUTGOING)
@Fetch
private User lover;
it turns out to be right:
{id=0, theme=null, name=Pamela, password=2663, lover={id=1, name=Bond}}
Anyone knows what is going wrong? Thx