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 9217229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:35:32+00:00 2026-06-18T02:35:32+00:00

I have read http://static.springsource.org/spring-data/data-mongo/docs/1.1.0.RELEASE/reference/html/#mapping-chapter but cannot find the answer to the following basic spring-data-mongodb

  • 0

I have read http://static.springsource.org/spring-data/data-mongo/docs/1.1.0.RELEASE/reference/html/#mapping-chapter but cannot find the answer to the following basic spring-data-mongodb object mapping question:

If I load an instance of the following class from MongoDB:

public class Test {
    private String str1;
    private String str2;
    private Date date3;

    public Test(String str1) {
        this.str1 = str1;
        this.date3=new Date();
    }
}

I understand that the constructor Test(String str1) will be invoked with the value found in the top-level field str1 of the MongoDB document.
I assume this constructor is equivalent to declaring a @PersistenceConstructor explicitly.

But what happens to the fields str2, date3 in this case? Will all fields that are not part of the constructor still be initialized, or will the str2, date3 values be lost since a PeristenceConstructor using only str1 was found?

And lastly, in what order will this happen? Will date3 be set by the constructor, then be overwritten by the previously persisted field, or vice versa?

  • 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-18T02:35:33+00:00Added an answer on June 18, 2026 at 2:35 am

    The population process is two fold and orthogonal to some degree. Mostly, you’ve already stated the correct behavior. The constructor is invoked to create an object instance. The parameter values are retrieved from the DBObject read and might cause a recursive creation of objects in case you hand complex objects into the constructor that need to be unmarshalled from a nested DBObject.

    The next step is that your persistent fields get populated. The only difference in your case to the case with a default constructor is that we remember the field values you handed into the constructor and do not re-populate those.

    The dateproperty in your example would still get set after the initialization in the constructor if the source document the object is materialized from contains a value for date.

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

Sidebar

Related Questions

I've read through all of the Spring 3 Web docs: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/spring-web.html but have been
I have a question about the C++ visibility attribute. I have read http://gcc.gnu.org/wiki/Visibility and
I have read here http://lostechies.com/jimmybogard/2009/09/18/the-case-for-two-way-mapping-in-automapper/ about how you probably shouldn't be trying to un-flatten
I have read the documentation ( http://dev.mysql.com/doc/refman/5.1/en/partitioning.html ), but I would like, in your
I have read the explanation in http://en.wikipedia.org/wiki/PageRank and i understand that the page rank
I have read this in order to compile NH spatial for Nhibernate 3.1 http://build-failed.blogspot.it/2012/02/nhibernate-spatial-part-2.html
I am trying to learn HTTPUnit and have read cookbook mentioned on http://httpunit.sourceforge.net/doc/cookbook.html But
So I've carefully read this page https://docs.djangoproject.com/en/1.2/howto/static-files/ . I have done the following: In
I read http://code.google.com/speed/page-speed/docs/caching.html . It says that proxy servers may cache cookies. I need
I have read from this article http://codahale.com/how-to-safely-store-a-password/ and it says using a salt isn't

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.