fluent-nhibernate
fluent-nhibernate copied to clipboard
What is Java hibernate JPA `@EntityGraph` equivalent in fluent-nhibernate?
I'm trying to solve n+1 query problem with fluent-nhibernate, as this article says,
For instance, in Hibernate, since JPA 2.1, we can use an EntityGraph to solve this problem. In C# Entity Framework, we can use an Include to fetch some lazy associations eagerly where we need them.
So how can we achieve that in fluent-nhibernate?
What I want to achieve is to fetch one-to-many/many-to-many fields into a collection of sql model instances(and each instance will have fields like List<ChildPost> childPosts) eagerly(no lazy initialized ChildPost), and orm should use one join sql to achieve that without subsequent sub-queries.
In java Spring data JPA, it can be easily achieved by utilizing entitygraph annotation and confirmed no sub-queries, for example:
public interface PostRepository extends JpaRepository<Post, Long> {
@EntityGraph(attributePaths = {"childPosts"})
List<Person> findAll();
}