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

  • Home
  • SEARCH
  • 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 6855391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:45:09+00:00 2026-05-27T01:45:09+00:00

Hi all patient developers using spring data graph. Since there is so less documentation

  • 0

Hi all patient developers using spring data graph. Since there is so less documentation and pretty poor test coverage it is sometimes very difficult to understand what is the expected behavior of the underlying framework how the framework is supposed to work. Currently i have some questions related to new fetching approach introduced in SDG 1.1. As opposite to SDG 1.1 write\read through in 2.0 only relations and related object annotated with @Fetch annotation are eagerly fetched others are supposed to be fetched lazily .. and now my first question:

  • Is it possible to configure SDG so that if the loading of entity and
    invoking getter on lazy relation takes place in the same transaction,
    requested collection is fetch automatically? Kind of Persistence
    Context in transaction scope, or maybe it is planned for the feature
    releases.
  • How can I fetch lazy collection at once for @RelatedTo annotation ? fetch() method on from Neo4jOperation allows to fetch only one entity. Do i have to iterate through whole list and fetch entity for each object? What would be the best way to check if given object is already fetched / initialized or not?
  • As suggestion i think it would be more intuitive if there will be kind of lazy loading exception thrown instead of getting NPE when working with not initialized objects. Moreover the behavior is misleading since when object is not initialized and all member properties are null apart from id, equals method can provide true for different objects which has not been initialized, which is quite serious issues considering for example appliance of sets
  • Another issue which i noticed when working with SDG 2.0.0.RC1 is following: when i add new object to not fetched collection sometimes is properly added and persisted,however sometimes is not. I wrote test for this case and it works in non deterministic way. Sometimes it fails sometimes end with success. Here is the use case:

    Group groupFromDb = neoTemplate.findOne(group.getId(), Group.class);
    assertNotNull(groupFromDb);
    assertEquals("Number of members must be equals to 1", 1,    groupFromDb.getMembers().size());
    User secondMember = UserMappingTest.createUser("secondMember");
    groupFromDb.addMember(secondMember);
    neoTemplate.save(groupFromDb);
    Group groupAfterChange = neoTemplate.findOne(groupFromDb.getId(), Group.class);
    assertNotNull(groupAfterChange);
    assertEquals("Number of members must be equals to saved entity", groupFromDb.getMembers().size(), groupAfterChange.getMembers().size());
    assertEquals("Number of members must be equals to 2", 2, groupAfterChange.getMembers().size());
    

This test fails sometimes on the last assert, which would mean that sometimes member is added to the set and sometimes not. I guess that the problem lies somewhere in the ManagedFieldAccessorSet, but it is difficult to say since this is non deterministic. I run the test with mvn2 and mvn3 with java 1.6_22 and 1.6_27 and i got always the same result: sometimes is Ok sometimes test fails. Implementation of User equals seems as follows:

@Override
public boolean equals(final Object other) {
    if ( !(other instanceof User) ) {
        return false;
    }
    User castOther = (User) other;
    if(castOther.getId() == this.getId()) {
        return true;
    } 
    return new EqualsBuilder().append(username, castOther.username).isEquals();
}

– I find it also a bit problematic that for objects annotated with @Fetch java HashSet is used which is serializable, while using for lazy loaded fields ManagedFieldAccessorSet is used which is not serializable and causes not serializable exception.

Any help or advice are welcome. Thanks in advance!

  • 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-05-27T01:45:10+00:00Added an answer on May 27, 2026 at 1:45 am

    The simple mapping approach was only added to Spring Data Neo4j 2.0, so it is not as mature as the advanced AspectJ mapping. We’re currently working on documenting it more extensively.

    The lazy loading option was also added lately. So your feedback is very welcome.

    Right now SDN doesn’t employ a proxy approach for the lazily loaded objects. So the automatic “fetch on access” is not (yet) supported. That’s why also no exception is thrown when accessing non-loaded fields and there is no means of “discovering” if an entity was not fully loaded.

    In the current snapshot there is the template.fetch() operation to fully load lazy loaded objects and collections.

    We’ll look into the HashSet vs. ManagedSet issue, it is correct that this is not a good solution.

    For the test-case. is the getId() returning a Long object or a long primitive? It might be sensible to use getId().equals(castOther.getId()) here as reference equality is not guaranteed for Number objects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using a List<Patient> object as the data source to a data grid view.
Thanks all for providing suggestion on the question processing of hospital admission data using
Patient ------- PatientID Visit ----- VisitID PatientID HeartRate VisitDate How do I select all
All front-end developers know the pain of coding for Firefox, then viewing our then
Have two sets of data (two tables) for patient records, one 1999-2003, the other
Hi all I am programming a biomedical patient monitoring device. I need to read
When I do: conditions = {:first_name => 'Chris'} Patient.joins(:user).find(:all, :conditions => conditions) It Produces
well, I'm quite new to jQuery and while browsing all the documentation I found
Hey, I've made this site (please be patient, there's no preload yet, so it
I want to select all the Female patients from the patient table where the

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.