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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:18:54+00:00 2026-05-19T01:18:54+00:00

very stupid question since I’ve been using hibernate for some time now but I

  • 0

very stupid question since I’ve been using hibernate for some time now but I was facing a special case and suddenly realised that I’m not sure how hibernate populates the DB entities.

public class User {
    ...
    @Column
    private String name;

    public void setName(String name) {
        this.name = name;
    }
}

When hibernate creates a new instance of User (when loading from the DB) how will it populate the property name of that instance? I always assumed hibernate would call setName for this but the case I’m having makes me suspect hibernate ignores the setter and (with reflection) sets the field’s value directly?

thanks,
Stijn

  • 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-19T01:18:54+00:00Added an answer on May 19, 2026 at 1:18 am

    Hibernate annotations and JPA use the placement of the Annotation to determine what kind of access to use. In the example you provided above, it would use field access.

    from the Hibernate Annotations documentation:

    Depending on whether you annotate fields or methods, the access type used by Hibernate will be field or property. The EJB3 spec requires that you declare annotations on the element type that will be accessed, i.e. the getter method if you use property access, the field if you use field access. Mixing annotations in both fields and methods should be avoided.

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

Sidebar

Related Questions

Ok - this may be a very stupid question, but it's been bothering me.
This is probably a very stupid question for SQL stalwarts, but I just want
This might be a very stupid question :P But I found this really interessting:
This might be a very silly / stupid question, but, my defence is that
This might seem a very stupid question but things are pretty complex for me
This is probably a very stupid question. But assume that I have a DLL
Excuse me for the maybe very stupid question, but my curiosity is killing me,
I know this might be a very stupid question but I am new to
I feel like this is a stupid question, but I can't think of a
I know that might sound like a stupid question since it's a trivial feature

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.