-
1. Re: ejb-ql relations/mapping problem
ojacobson May 30, 2007 5:14 PM (in response to ppogoda)SELECT ...
FROM DOCUMENTS d
LEFT JOIN DICTIONARIES d1 ON (d.dict1_id = d1.dict_id)
WHERE d1.dict_status = 1 AND d1.dict_locale = :param
should be morally equivalent. It's usually a bad idea to put filtering predicates in join predicates in SQL; I can't imagine it being any better for EJBQL. -
2. Re: ejb-ql relations/mapping problem
ppogoda May 31, 2007 4:02 AM (in response to ppogoda)But my problem is that i want to have OneToMany relation between
Documents and Dictionaries
@Entity
class Document {
...
@OneToMany (not ManyToMany)
private Collection dict1
...
}
With many to many i would have to create additional join table...
in Document bean I have only dict_id, without dict_status, dict_locale and using only dict_id in relation annotation give me ManyToMany no matter that I give additional condition in EJB-QL (dict_status, dict_locale)
The best would be to have some kind of parametrized relation with dict_status and dict_locale, that would give me OneToMany. -
3. Re: ejb-ql relations/mapping problem
fhh May 31, 2007 4:43 AM (in response to ppogoda)You probably want a @ManyToOne relationship since you have a collection on the Document side.
Regards
Felix -
4. Re: ejb-ql relations/mapping problem
ojacobson May 31, 2007 5:00 PM (in response to ppogoda)If the dict_status and dict_locale fields are not part of Dictionary's entity key then you can't (portably) use them in a container-managed relationship. There is a hibernate extension that works on jboss when using the hibernate entity manager: have a look at
http://www.hibernate.org/hib_docs/annotations/reference/en/html/entity.html#entity-hibspec-collection-enhance
(2.4.6.1. Enhance collection settings)