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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:33:01+00:00 2026-06-12T12:33:01+00:00

I have one to many mapping between School and Student entity’s. public class School{

  • 0

I have one to many mapping between School and Student entity’s.

public class School{
   @oneToMany
   private List<Student> students;
 ...
}

It makes sense that Hibernate by default fetches student lazily, but I’m not clear to me why it loads its own implementation of List (PersistantBag) instead of java ArrayList?

  • 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-12T12:33:02+00:00Added an answer on June 12, 2026 at 12:33 pm

    A List is an ordered collection. A PersistantBag on the other hand (according to the Hibernate API) is:

    An unordered, unkeyed collection that can contain the same element multiple times. The Java collections API, curiously, has no Bag. Most developers seem to use Lists to represent bag semantics, so Hibernate follows this practice.

    In other words a bag is just a random collection of the items in the list.

    In order for Hibernate to treat your List as an ordered collection it would need an index column (see Indexed Collections). But since you don’t have such a column Hibernate instead uses “bag semantics”. In the end there isn’t too much difference to you, the developer, since you are likely not relying on the order but if you do need it you can add an index column to get these features.

    Another nice feature that a bag has is that you can get the number of occurrences of an object in your collection, whereas in a List you would need to iterate over the whole list to find that out.

    Additional Resources:

    Why Hibernate does “delete all then re-insert” – its not so strange

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

Sidebar

Related Questions

I have the below unidirectional Many To One mapping @Entity public class Item implements
I have a one-to-many mapping between a parent entity and child entities. Now I
I have one to many association Student entity to Subject entity. Student entity association
I have one-to-many mapping in hibernate between a Parent and a Child . In
i have an entity Entity1 that have one to many relation with Entity2 as
I have a one-to-many relationship between two classes for this situation. I have a
I have a one-to-many relationship between Foo and Bar and I cannot perform an
I have one abstract class and many child classes. In child classes are from
I have many-to-one mappings working fine, but a one-to-many relationship between locations and location_times
I have a many-to-one relationship between objects Product and Supplier . I need to

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.