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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:14:11+00:00 2026-06-15T19:14:11+00:00

Is it necessary that the default contructor is empty when working with JPA? Since

  • 0

Is it necessary that the default contructor is empty when working with JPA?
Since I have no clue of how JPA internally works I somehow fear that an object could be falsely initialised by JPA when the default contructor does some stuff on his own like filling attributes with default values and the like.

Thanks.

  • 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-15T19:14:12+00:00Added an answer on June 15, 2026 at 7:14 pm

    The short answer is no. It is not required to be empty.

    However, you need to be aware that when the JPA implementation materializes an instance from persistence, it will do things to the instance after the no-args constructor completes. This might undo things that your constructor has done.

    To understand whether the constructor needs to be empty, you need to consider that the constructor is going to be called in two scenarios.

    • When you are creating a “new” object, the constructor needs to produce an object that is sufficiently initialized to be used by normal code. Fields that need to be initialized to non-default states should be dealt with.

    • When JPA is materializing an object from the persistent store, the materialization is then going to “fill in the details” of the newly constructed instance. This will typically overwrite the object state of the constructed object.

    Of course, your code may be designed so that it doesn’t directly use the no-args constructor. This renders the first scenario moot, and also renders moot the potentially wasteful “double initialization” that might occur.

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

Sidebar

Related Questions

I have the following XML Document (that can be redesigned if necessary) that stores
I know that most people have DirectX9-capable cards but is it really necessary to
Background: Back at work, I'm working on a Web Forms App that uses default,
I have setup my default android Preferences with the necessary options. The prime reason
Is it necessary that the assignment operator ( = ) always copies the rvalue
When importing or exporting Databases using Taps in heroku , is it necessary that
My question is : from basic which are the necessary jars that should required
I'm using Spring to define stages in my application. It's configured that the necessary
I believe that I did everything necessary to change my app for ipad (was
What is necessary to tell a server that a Webclient supports the SPDY protocol

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.