cannot simultaneously fetch multiple bags

Front end developers must read! Starting from scratch, teach you to build a low code website platform in stages>>>

JPA Caused by: org.hibernate.HibernateException: cannot simultaneously fetch multiple bags

—–The reference comes from the network

When the persistence framework grabs one party’s object, it loads the multi-party object into the container at the same time, and the multi-party object may be associated with other objects. In JPA implemented by hibernate, the default maximum grabbing depth is level 4 (it has a property configuration of 0-3). If there are duplicate values in the multi-party (Level 2)

Then the values captured in the third level cannot be mapped. According to this principle, an exception that cannot load multiple packages at the same time should be reported

In other words, the many sides of @ manytomany or @ onetomany must be stored in a set container instead of a list collection

However, some functions of Hibernate go beyond the JPA specification. It supports real list sets. The way to map sets is exactly the same as before, except that you need to add the @ indexcolumn annotation, which allows you to specify the fields where index values are stored. But in fact, it is the only way to create a unique index, and the result of multi-party crawling is also unique, which is the same reason that the set container does not allow duplicate elements

If this exception occurs, first check whether you have used the list collection to cause this problem. If you still have this problem with set, check whether there are similar problems in the class of the object in the set container

Similar Posts: