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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:30:34+00:00 2026-06-11T09:30:34+00:00

I have entities which are divided into categories. Each entity can belong to many

  • 0

I have entities which are divided into categories. Each entity can belong to many categories, so I have one to many association.

Is it ORM-ed correctly below:

@OneToMany
@Access(AccessType.FIELD)
private Set<Category> parents = new HashSet<Category>();
public Set<Category> getParents() {
    return parents;
}
public boolean addParent(Category parent) {
    return parents.add(parent);
}
public boolean removeParent(Category parent) {
    return parents.remove(parent);
}

My specific question is am I need to use @Access annotation or not? If I won’t use it then how Hibernate will know not to map getParents getter?

  • 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-11T09:30:35+00:00Added an answer on June 11, 2026 at 9:30 am

    I do not know whether or not you need the @Access(AccessType.FIELD) annotation, because this depends on some defaults (see below).
    But if you use Field access type (by default or by @Access(AccessType.FIELD)) then
    Hibernate will access the FIELD directly and not use the getter or setter!

    See Hibernate Reference, chapter 5.1.4.1.2. Access type, for more details about the access type determination algorithm.

    By default the access type of a class hierarchy is defined by the position of the @Id or @EmbeddedId annotations. If these annotations are on a field, then only fields are considered for persistence and the state is accessed via the field. If there annotations are on a getter, then only the getters are considered for persistence and the state is accessed via the getter/setter. That works well in practice and is the recommended approach.

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

Sidebar

Related Questions

Currently I have one managedContext, many NSArrayControllers of entities which are all pretty interrelated,
I have an Article and Comments entities which are related together in a one-to-many
I have two entities Group and Contact. A contact can belong to many groups,
I have Entity Framework entities Events which have an EntityCollection of RSVP. I want
I'm trying to configure a one to one relationship between entities which both have
i have two entities one called User and another called Membership which has a
I have entities Word and Tag . Both have To-Many relationship to each other,
I have three core data entities which I am importing into, they are: •
I have an entity set called Entities which has a field Name and a
I have a Core Data based application which is built around one main entity.

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.