Hibernate version:2.1.7 or 2.1.6 (tried both)
Mapping documents:Middlegen 2.1
Name and version of the database you are using:Firebird 1.5.1
Hi, I have a table called 'Collections' and another called 'BorrowerTypes'. There is an 'overrides' table (called Overrides_Collectns_Brwrtypes) that associates the two and is a many-many. i.e There can be an override between one collection and several borrower types. (Of course these tables have been renamed by middlegen.)
I want to list the pk of all Collection rows, so in HQL I do this:
Code:
select c.collectionSn from Collection c
which gives me 51 records, which is correct.
I also want to indicate in the results whether (for each row) there is 0 or more 'overrides' records. This could either be a count of 0-n or a List of 0-n records, it doesn't matter.
So I modified the HQL:
Code:
select c.collectionSn, count(c.overridesCollectnsBrwrtypes) from Collection c
However I get the error
Quote:
Column unknown C.OVERRIDESCOLLECTNSBRWRTYPES
Examining the SQL in the hibern8ide console, I see
Code:
[java] Hibernate: select collection0_.COLLECTION_SN as x0_0_, count(c.overridesCollectnsBrwrtypes) as x1_0_ from COLLECTIONS collection0_
The column c.overridesCollectnsBrwrtypes is a hibernate representation of my table; it seems that either hibern8ide or hibernate has not generated the correct SQL code.
Can anyone tell if the query should be done differently?
Could there be some sort of mapping error (in one of my mapping files)?
Regardless, hibernate should not be submitting this malformed SQL to the database - it is clearly using a hibernate-generated field name whose name differs from those in the database. It also hasn't resolved the relationship that exists between the Collections and Overrides_Collectns_Brwrtypes tables (i.e some sort of join).
TIA
PS. Clutching at straws, this also fails (same type of error):
Code:
select c.collectionSn, count(ocb.collectionSn) from Collection c join c.overridesCollectnsBrwrtypes ocb