Using this annotation in a pet project seems to work just fine, I'm a boss and two employees, etc. But in real large-scale projects, you end the accounting year associated with 100,000 signs or a city with 1,000,000 citizens and naively try to extract all of them in ArrayList, OutOfMemory leads to errors.
A good approach is to not define this relationship (but @ManyToOne) and retrieve the paginated results that you want to do with them.
So, ¿Is there any Observer template or similar for working with a large database model? ¿Any configuration that you can use to manage memory?
Let's say you have an application that displays all the citizen data for a particular city. There are 1,000,000 people in this city, so you want to display this many lines on the user interface.
Do you think it makes sense to display that much data right away or do you think pagination is necessary? I would say that the latter applies to the case, because no one will read through a million entries in the user interface.
Just to suggest something, if you have a lot of data, do not use entities to display information in the user interface. Instead, use forecasts that contain the exact data you need to show +, you can also easily enter pagination.
, Spring Data JPA, .
, , , , - . , . .
, . - 1 . , , .
, @ManyToOne -, ORM .
@ManyToOne
, , .
OneToMany , , . Scrum Team Scrum, 3-9 . , OneToMany .
, , : , , , . , , OneToMany . Spring Data, , . OneToMany, .
: : ManyToOne, mappedBy , , . , , . ... , , OneToMany.
, @OneToMany .
@OneToMany
However, the case where such an association may still be convenient is with JPQL / HQL queries, since you could use route navigation from the parent. To make sure that the collection is not available, you can simply provide the mappings in the private field of the collection without exposing getter and setter for it (and, of course, leave the association lazy).
Source: https://habr.com/ru/post/1671992/More articles:TypeError at / app / profile /, the 'list' object is not processed handle_pageBegin args = () - pythonWhat exactly happens if I delete the object that contains this lambda inside the lambda? - c ++Why is there a temporary dead zone? - javascriptPython graphviz node positioning - pythonCalculate Height Using Leaflets - leafletWhy should I use my own StyleSheet React? - stylesheetHow to get CSS override properties for Javascript / jQuery only - jqueryWhy can't we check the style attribute of the app responsible for the response? - javascriptis (: visible) returns true even if the overlay is hidden jQuery - javascriptExpress.js HTTP call inside route does not update variable - javascriptAll Articles