native-sql

NHibernate: References still being eagerly selected after specifying AddJoin

I have a query which is something like this: Session.CreateSQLQuery( @"SELECT f.*, b.*, z.* FROM Foo f LEFT OUTER JOIN Bar b ON b.Id = f.BarId LEFT OUTER JOIN Zar z ON z.Id = b.ZarId" ) .AddEntity("f", typeof(Foo)) .AddJoin("b", "f.BarId") .AddJoin("z", "b.ZarId") .List<Foo>(); The problem is that I ...

Native SQL query for an Hibernate entity using @Formula results in NullPointerException

I've got an simple Hibernate entity for which I use the @Formula annotion: @Id private Long id; private String name; @Formula("(select count(f.*) from foo f where f.id = id)") private long bar; When I try to load an entity with a native SQL Query: EM.createNativeQuery("SELECT f.*, count(something) as bar FROM foo f WHERE f.name...

Syntax help for Load-Collection Query with Composite Key in Hibernate

I'm working with an existing database (that cannot be changed) that uses composite keys. I trying to create a native SQL join for a collection however Hibernate is trying to retrieve a value from the result set that isn't there ("PID1_0_"). I'm almost certain I'm missing something in my "load-collection" element. Can you please help? ...

Hibernate = Column not found

I am running an aggregate function in java through hibernate and for some reason it is giving me this error: INFO Binary:182 - could not read column value from result set: l_date; Column 'l_date' not found. When I run the MySQL query the column names are l_date and logins and I can not figure out why it is not finding that. I have ...

NHibernate/Hibernate define mapping without a class

I have a particular case where I need to define a query including a table ASpecialTable for which I don't have any mapping or business class defined. However, the return type of the query is an existing business class MyBO. For that particular table, I'll never need it in my code, and it doesn't contain a primary key, or to be short: I...

getting result set into DTO in SQL Query in Hibernate

I have a query like below select f.id, s.name, ss.name from first f left join second s on f.id = s.id left join second ss on f.sId = ss.id If I could have used HQL, I would have used constructor syntax to directly populate DTO with the result set. But, since hibernate don't allow left join without having an association in place I have...