2

I dont understand why NHibernate returns an object[] when a join is performed but Hibernate does not. For example.

The mapping

The query session.CreateQuery("From CameraMount m left join m.Presets").List();

This will return an object[] where I would expect it to return a CameraMount that has its set of Presets initialized.

Why?

2 Answers 2

1

I guess this is just the implementation that is slightly different due to support for generic and non-generic collections in .NET. If you want strongly typed CameraMount objects you could request:

List<CameraMount> cameramounts = 
session.CreateQuery("From CameraMount m left join m.Presets")
.List<CameraMount>();

instead. Hope that helps.

Sign up to request clarification or add additional context in comments.

Comments

1

Also, you can try Select m from CameraMount m left join m.Presets This should give you the CameraMount Objects back.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.