Database Reference
In-Depth Information
The output is shown in the following screenshot:
We can also verify the same by enhancing our Spring Data Neo4j code and adding some
methods for searching the Neo4j database.
Let's add a new method searchData() in PersistNeo4JData and add the follow-
ing code in this new method:
@Transactional
public void searchData(){
System.out.println("Retrieving Roles from Database");
Result<Role> result =
neo4jTemplate.findAll(org.neo4j.spring.samples.domain.Role.class);
while (result.iterator().hasNext()) {
Role role = result.iterator().next();
System.out.println(role.toString());
}
System.out.println("Artists and Roles retrieved from
Database");
}
Next, import org.springframework.data.neo4j.conversion.* as a new
package in PersistNeo4JData and invoke the searchData() method from
MainClass.java .
Note
In order to see some meaningful values on the console, add a toString() method in
Role.java, which returns a formatted string containing the values of the attributes.
Search WWH ::




Custom Search