I came across some hibernate annotations in the source code at work, to be more specific "@FetchProfile". I hadn't seen that one before, so I went onto the Internet.
In my case it was used for Batch jobs, in which all associations were always fetched, and needed to be changed to "EAGER", during the session.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@FetchProfile(name = "STUFF", fetchOverrides = { | |
@FetchProfile.FetchOverride(entity = Orders.class, association = "customer", mode = FetchMode.JOIN), | |
}) | |
... | |
Session session = sessionFactory.getCurrentSession(); | |
session.enableFetchProfile("STUFF"); | |
session.setHibernateFlushMode(FlushMode.MANUAL); |
References
- A Java geek — Hibernate hard facts - Part 6
- https://blog.frankel.ch/hibernate-hard-facts/6/
- JBoss Docs Hibernate - 20.1.7. Fetch profiles
- https://docs.jboss.org/hibernate/core/3.5/reference/en/html/performance.html#performance-fetching-profiles
- JBoss Docs Hibernate Annotations - 2.4.12. Fetch profiles
- https://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#d0e3524
No comments:
Post a Comment