fetching-strategy

NHibernate Eager Fetching Over Multiple Levels

I have a 3-leveled hierarchy of entities: Customer-Order-Line, which I would like to retrieve in entirety for a given customer, using ISession.Get(id). I have the following XML fragments: customer.hbm.xml: <bag name="Orders" cascade="all-delete-orphan" inverse="false" fetch="join"> <key column="CustomerID" /> <one-to-many class="O...

Join two data tables from different source databases in .NET?

How do you join two data tables from different source databases in .NET? Ideally, I can craft two queries manually and simply join on a single field. In this case, linked servers and scheduled imports are not an option. I've looked into the data relation object, but (correct me if I'm wrong) that only works for parent-child relationshi...

Is there a way to change the JPA fetch type on a method?

Is there a way to change the JPA fetch type on a single method without editing the entity object? I have a shared ORM layer consisting of JPA entity classes. This ORM layer is accessed by two DAO layers. One DAO needs lazy fetching, as it is for my web application, the other needs eager fetching, as I need it to be threadsafe. Here is ...

Hibernate: batch_size? Second Level Cache ?

I have a Hibernate domain object that gets loaded by different parts of the application. Sometimes it's advantageous to lazy load every association and others it's better to load the entire thing in one join. As a hopefully happy compromise I've found: Using batch fetching, Hibernate can load several uninitialized proxies if one proxy...

iphone tabbar where to load data?

Hi, I have two tabbar items(views) that use the same data, whats the best solution for getting the data? Make two fetch request for the same data in each view controller. Make one fetch request in appDelegate, and use sharedApplication to get to the data in appDelegate. I can use KVO and notifications to notify the views if the data h...

How to change hibernate's default fetching strategy?

I know hibernate's default fetching strategy is LAZY for collections, is there a way to change the default fetching strategy system wide through configuration file? ...

NHibernate: is there limitation of batch-size to 10 items?

Hi! I am having a problem with NHibernate (SQL Server 2000, if it matters). It seems like NHibernate uses batch-size equal to 10 even if I specify 500 (but if I specify size less than 10, say 3 - it uses 3) <bag name="RiskTypes" table="CalculationQuery" lazy="false" batch-size="50"> <key column="CalculationID"></key> <many-to-many...

Force an eager select in NHibernate

I am trying to eagerly fetch collections using selects, but all I am getting is inner joins. What is going on? Session.CreateCriteria(typeof(Foo)) .SetFetchMode("Bars", FetchMode.Select) .CreateAlias("Bars", "b") .SetFetchMode("b.Bazes", FetchMode.Select) .List(); I have tried changing FetchMode to Eager but that doesn...

NHibernate: How to fetch an object without its child collections?

Hi, My objects of type Object1 contain List Children1 property. I would love to get these objects without children. Seems like detachedCriteria.SetFetchMode ("Children1", FetchMode.Lazy) should be the thing, but apparently it's not :( I tried getting the data in using (new SessionScope()) and setting null to .Children1 but it didn't suc...

Real world experiences with AutoFetch for Hibernate?

I saw the project AutoFetch for Hibernate. It sounds pretty cool - when Hibernate queries are executed, it checks for the N+1 problem. If there was a problem, next time that query (it figures out which one it is by looking at the stacktrace) gets executed it adds appropriate fetch statements. It says on the website "Autofetch integrates...

Hibernate fetches incorrectly using @ManyToOne EAGER

I have two entities, let's call them X and Y. They have many-to-many relation but I never needed to use that relation, i.e x.getYs(), so I did not set it up to keep things simple. I have a table that holds the relationship and has only rows that are keys to X and Y. In other words that x_y table's rows are only x_id and y_id What I need...

Is this the right way of using ThenFetch() to load multiple collections?

I'm trying to load all the collections eagerly, using NHibernate 3 alpha 1. I'm wondering if this the right way of using ThenFetch()? Properties with plural names are collections. The others are just a single object. IQueryable<T> milestoneInstances = Db.Find<T, IQueryable<T>>(db => from mi in db whe...

How to set NHibernate Linq fetch strategy through a façade layer

I’m using NHibernate for data access, but accessing it through a façade layer. This layer consists of interfaces for the repositories, plus an IUnitOfWork interface which corresponds to the ISession object. In order that retrieved entities are managed correctly, repositories are passed an IUnitOfWork in their constructor and the IUnitOf...

How does Hibernate's batch-fetching algorithm work?

I found this description of the batch-fetching algorithm in "Manning - Java Persistence with Hibernate": What is the real batch-fetching algorithm? (...) Imagine a batch size of 20 and a total number of 119 uninitialized proxies that have to be loaded in batches. At startup time, Hibernate reads the mapping metadata and c...

Nhibernate - Paging and eager loading entities

I have two entities, a team and an employee. I want get a list of employees with eager loaded teams. The list has to be paged. public PagedList<Employee> GetAllEmployeesWithEagerLoadedTeams(int page, int pageSize) { var criteria = GetSession() .CreateCriteria(typeof (Employee)) .SetFetchMode(DomainModelHelper.GetAss...

HIbernate fetch join issuing additional sql statements.

Consider the following Parent class that has two ManyToOne references. @Entity @Table(name = "PARENT") public class Parent { private static final long serialVersionUID = 3730163805206219313L; @Id @SequenceGenerator(name = "SEQ#PARENT", sequenceName = "SEQ#PARENT", allocationSize = 1) @GeneratedValue(strategy = GenerationType.SEQUENCE,...

SetFetchMode call ignored

I have a problem with SetFetchMode call in Criteria API in following query: DetachedCriteria.For<User>() .Add<User>(u => u.Status == UserStatus.Live) .CreateAlias("UniqueId", "uid") .CreateAlias("Companies", "comp") .Add(Restrictions.Disjunction() ...