My organization works on Spring MVC with Hibernate We always specify foreign key constraints in the mapping file, such as a person This mapping will create multiple relationships between However, now the organization has decided not to mention any kind of relationship in the mapping file, in this case In such a case, if we want to get the person's contact list, then we will have to ask two questions so that for a person's contact list, suppose that we want to receive the person's list. Contact list will then have to do When I ask why not specify a relationship then the senior said, If the foreign key is in DB, then we do not divide the pieces and divide Can. When we set fire to join the query DB takes much time to execute it. Which can slow down the DB server. But, my question is - If I type This type of looping can be slowed or What if I The person wants to bring its list, list address, merit list, with the issue of n + 1 due to this? Whether or not to specify a mapping, this situation is more beneficial. OK, I divide one of the early days into Microsoft SQL (MS) The states doing this have shown a query, which is selected from a partition table, which contains the population data in many parties, and its indexes and statistics are not used to reach those divisions, which have no relevant data was not. Of course if you do not have the FK stable then it can not use the index and the data so that you know about FK. I am pretty sure that this will be covered by Cullen Delanye in his book (for the relevant edition of MSSQL). The key is that the data will include the necessary information to prevent unnecessary efforts. Demo actually used a union to display the effect Person.hbm.xml
& lt; Set name = "ContactList" & gt; & Lt; Major column = "PersonId" foreign-key = "Fk_Peson_Contact" /> & Lt; One-to-many classes = "sample.model.contact" / & gt; & Lt; / Set & gt;
person and
contacts , and
PersonID < In the form of a foreign key column in the Code> Contacts table.
person near the map
contact Instead of mapping, there will be no one-to-many mappings of any type
personID to capture columns Create this scenario table In
person and
contact will look the same but the difference is that their Coz no mapping is specified, there is no connection between
person and
contact .
for loop for the person's list and will bring its contact list which will reduce the number of questions.
for looping I do it, is it possible that many questions will be asked to bring the contacts?
No comments:
Post a Comment