Today, when doing the project, there are two entities: style, brand relationship is many-to-many relationships, the realization of the function is: through the selection of styles, showing the style of all brands. The HQL statement is as follows:
From Brand as b where b.styles.styleid=?
This exception error occurred at runtime: Org.hibernate.QueryException:illegal attempt to dereference collection.
through data found in the above statement, Brand's associated entity styles is a set set, not a style entity. In previous version, hibernateinner Join The statement is 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 statement. If is a single associative entity or a common attribute, then the Span style= "Font-family:times New Roman;" >hibernateinner join< Span style= "font-family: the song Body;" > But if is a collection, then I'm sorry, the system will appear org.hibernate.queryexception: illegal attempt to dereference collection exception. For the solution, either you return Hibernate3.2.2 statement:
from as Inner Join Fetch as where S.styleid=?
Fix org.hibernate.QueryException illegal attempt to dereference collection exception error