In the project, you will encounter a one-to-many entity relationship mapping, and you should also isolate the associated entity properties, and use the join statement in HQL to associate two entity objects with the following code:
1 New Customerrequirement (c.pname,c.salesman,c.pdate) from customerrequirement C inner joins c.requirementdeatils r on C = C.req Uirementdeatils.customerrequirement
Run the discovery report with the following error:
Org.hibernate.QueryException illegal attempt to dereference collection
This is because in the HQL statement above, Customerrequirement's associated entity requirementdeatils is a set set, not an entity. In previous versions of Hibernate3.2.2, Hibernate automatically used an implicit inner join for the associated entity, meaning that using the HQL statement above was no problem.
However, after the Hibernate3.2.2 version, Hibernate changed this strategy. It uses the following policy to correlate entities.
also for the above HQL statement. If requirementdeatils is a single associated entity or is a normal attribute, Hibernate automatically uses the implicit inner join. But if requirementdeatils is a collection, then there will be org.hibernate.QueryException illegal attempt to dereference Collection exception, for the solution is either to return to the hibernate3.2.2 version before, or use the following form of the HQL statement:
New Customerrequirement (c.pname,c.salesman,c.pdate) from customerrequirement C INNER join fetch c.requirementdeatils r on C = C.requirementdeatils.customerrequirement
Fix org.hibernate.QueryException illegal attempt to dereference collection exception error