Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8041047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:05:20+00:00 2026-06-05T04:05:20+00:00

We are currently working on a Java project with neo4j. We use Spring Data

  • 0

We are currently working on a Java project with neo4j.

We use Spring Data Neo4j and get most of the information out of the Good Relationships book.

This document states, that the standard entity type representation in the graph is IndexingNodeTypeRepresentationStrategy.

For our project we would prefer the one with subreference nodes.

How can we configure neo4j to use this strategy when working with repositories. We started with the HelloWorld example, so we currently have a repository interface as follows:

public interface IWebsiteGraphRepository extends GraphRepository<Website> {}

Additionally we have our node entity (I omit most of the irrelevant code):

@NodeEntity
public class Website {
    ...
}

Can anyone provide a small example of how to set the TypeRepresentationStrategy ?

Can this be done in the Spring configuration?

The config would be:

<context:annotation-config />
<tx:annotation-driven mode="aspectj" transaction-manager="neo4jTransactionManager" />
<context:component-scan base-package="my.base">
    <context:exclude-filter type="annotation" 
                  expression="org.springframework.stereotype.Controller" />
    </context:component-scan>
<neo4j:config storeDirectory="target/neo4j-db" />
<neo4j:repositories base-package="my.base.packages.repositories" />

Edit:

After another session I finally was able to get it to work! I started based on Michael Hungers answer, but was not able to create the Bean. I found where his example may be from: gitHub. This, however, still did not work for me. I began looking deeper into the source code of the TypeRepresentationStrategyFactory class. I found out, that Strategy is a private enumeration. This is the second constructor arg I tried to provide. In my project it did never detect it as of type Strategy.

First I was a little sceptic, because Strategy is private. I mean, I couldn’t even instanciate a TypeRepresentationStrategyFactory in Code, because it would not find the type Strategy. I soon found out, that Spring supposedly can do things like that: Beans with private constructor.

In the end I had to adjust Michaels solution, as it was not identifying the constructor argument whatsoever. No matter what I did. Maybe it’s my setup, I really don’t know. But finally I came up with the solution to create a bean from the private enumeration and provide this as a reference to the constructor:

<bean id="subref" factory-method="valueOf"
class="org.springframework.data.neo4j.support.typerepresentation.TypeRepresentationStrategyFactory.Strategy">
    <constructor-arg>
        <value>SubRef</value>
    </constructor-arg>
</bean>

<bean id="typeRepresentationStrategyFactory"
    class="org.springframework.data.neo4j.support.typerepresentation.TypeRepresentationStrategyFactory">
    <constructor-arg index="0" ref="delegatingGraphDatabase" />
    <constructor-arg index="1" ref="subref" />
</bean>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:05:22+00:00Added an answer on June 5, 2026 at 4:05 am

    This should do:

    <bean id="typeRepresentationStrategyFactory" class="org.springframework.data.neo4j.support.typerepresentation.TypeRepresentationStrategyFactory">
        <constructor-arg index="0" ref="graphDatabaseService"/>
        <constructor-arg index="1" value="SubRef"/>
    </bean>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on a Java web project (Spring) which involves heavy use of
I am currently working Java project with use of apache poi. Now in my
I'm currently working on a java project that requires me to make a system
I'm currently working on a project that is building a java-based desktop application to
I'm currently working on a project where I'm converting database info to java objects,
I'm currently working on building a java web app. I've been looking to use
I am currently working on a Java EE project. I have successfully developed a
I am currently working on a project in java. I need to create a
I am currently working on a project with both java and C# codes within.
I am currently working on a project that requires the use of a semi-colon

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.