XDoclet & Hibernate Mapping HQL Issue

Hi there,

I’m having an issue with HQL. I added a new Map field to the class and now I’m unsure on how to add the join to the existing query. The way I’m doing is returning 0 result set. I’m unsure on how the HQL would map.

Below are the snippets of what was working previously:

String newQuery = "select rrt from ReservType as rrt left join rrt.Agencies agency where agency is null or agency.name = :agencyAcronym"

**This was added previously in ReservType class and the query worked as expected.** 
@ManyToMany(targetEntity = Agency.class, fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
    @JoinTable(name="RES_AGENCY", joinColumns={@JoinColumn(name="reserv_type_id")}
                                        , inverseJoinColumns={@JoinColumn(name="agency_id")})	
	private Collection<Agency> allowedAgencies = new ArrayList<Agency>();

NOW, I added the below field to the class, and then modified the query as below and this is probably messing it up. Any suggestions or thoughts would be appreciated:

*@ElementCollection* (fetch = *FetchType* . ***LAZY*** )
*@CollectionTable* (name = "RES_DESC",
joinColumns = *@JoinColumn* (name = "reserv_type_id"))
*@MapKeyJoinColumn* (name="agency_id")
*@Column* (name = "description_id")
private Map<Agency,Description> descriptions = new HashMap<Agency, Description>();

New Query:
"select rrt from ReservType as rrt left join rrt.agencies agency join rrt.descriptions desc where agency is null or agency.name = :agencyAcronym and (desc is null or desc.agency_id = 1)";

This query would not return anything may be because the mapping is not set right in the query.

If I just do “select rrt from ReservType rrt”, it works as expected. Please help. I’m adding the below description of the tables involved in the above mappings.

I have the below tables:
ReservType: (id, resType)
Agency: (id, name, code)
Description: (id, description)

Now I have the below two join tables:
Res_Agency (reservType_id, agency_id)
Res_Desc (reservType_id, agency_id, description_id)

I’m trying to join the above two join tables in the query basically. Any help would be appreciated. Thank you