Witam

Czy da się w jpa named query użyć join gdy kolekcja encji nie jest zadeklarowana jako @OneToMany ??
Obecnie dodałem sobie @OneToMany undirectional tylko po to aby wykorzystać to w zapytaniu, które i tak nie dziala poprawnie :/

Mam takie NamedQuery:

		@NamedQuery(name = MessageArchive.GROUP_CHAT, query = "Select NEW pl.pisystem.gwt.client.im.dto.MessageArchiveDTO(ma.conversationid, ma.fromjid, ma.fromjidresource, ma.tojid, ma.tojidresource, ma.sentdate, ma.body, ma.conversation.room, ma.conversation.isexternal,ma.conversation.startdate,ma.conversation.lastactivity) "
				+ " from MessageArchive ma"
				+ " join  ma.participants p where p.joineddate>=:startDate and p.barejid=:person"
				+ " and ma.conversation.room is not null ")

Niestety nie działa ono poprawnie :/

Tak moje query wygląda w sql:

 
select ma.conversationid,ma.fromjid, ma.tojid,ma.sentdate, ma.body from ofmessagearchive ma
join ofconversation c on c.conversationid = ma.conversationid and c.room is not null 
join ofconparticipant p on  ma.conversationid = p.conversationid and p.joineddate>='1365862298960' and p.barejid = '[email protected]'

Zastanawiam się nad 2 opcjami:

  1. stworzyć natywne query
  2. 2 query : 1 w encji Participant i wyciągnąć wszystkie conversationid a następnie wybrać wszystkie wiadomośći w ofmessagearchive.