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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:01:37+00:00 2026-06-15T22:01:37+00:00

I just want to know what is the difference between all these annotations. Why

  • 0

I just want to know what is the difference between all these annotations. Why are we using these… means they have no effect especially field level and property level.

And what is the purpose of using mixed level annotation like:

@Entity
@Access(AccessType.FIELD)
class Employee {
    // why their is a field level access 
    private int id;

    // whats the purpose of transient here
    @Transient                               
    private String phnnumber;

    // why its a property level access
    @Access(AccessType.property)             
    public String getPhnnumber() {
        return "1234556";
    }

}

what exactly this class says?

  • 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-15T22:01:38+00:00Added an answer on June 15, 2026 at 10:01 pm

    By default the access type is defined by the place where you put your mapping annotations. If you put them on the field – it will be AccessType.FIELD, if you put them on the getters – it will be AccessType.PROPERTY.

    Sometimes you might want to annotate not fields but properties (e.g. because you want to have some arbitrary logic in the getter or because you prefer it that way.) In such situation you must define a getter and annotate it as AccessType.PROPERTY.

    As far as I remember, if you specify either AccessType.FIELD or AccessType.PROPERTY on any of the entity fields / methods you must specify the default behaviour for the whole class. And that’s why you need to have AccessType.FIELD on the class level (despite that AccessType.FIELD is the default value.)

    Now, if you wouldn’t have @Transient on the phnnumber field, the JPA would provide you with a 3 columns table:

    • id,
    • phnnumber,
    • getphnnumber.

    That’s because it would use AccessType.FIELD for all of the entity fields (id and phnnumber) and, at the same time, it’d use AccessType.PROPERTY for your getter (getPhnnumber()).
    You’ll end with phone number mapped twice in the database.

    Therefore, the @Transient annotation is required – it means that the entity won’t store the value of the field in the underlying storage but the value returned by your getter.

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

Sidebar

Related Questions

I just want to know what is the difference between these two messaging constants.
I just want to know the difference between List<string> lst = new List() and
I just want to know what is the actual difference between private and protected
I just want to know if is possible to calculate the diference between two
Just want to know if publishing an application on Google play is allowed using
I just want to know how to access an array in SMARTY that have
Just want to know how to read an attribute of a parent node from
I just want to know why both the paint and draw methods are used
i just want to know, how to write Code behind(Hyperlink1_Click()), for the hyper link
I just want to know how to code a animation like the one on

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.