Hello! This query is working fine
SELECT DISTINCT $1 FROM ChatHistoryItem $1 JOIN $1.recipient $2 JOIN $1.sender $3 WHERE ($2.id='22afeafe-363f-4397-8553-cc5688ba142d') OR ($3.id='22afeafe-363f-4397-8553-cc5688ba142d') ORDER BY MAX($1.createDate) DESC
but this query returns an exception "com.objectdb.o.NLV cannot be cast to com.objectdb.o.RSV"
SELECT DISTINCT $1 FROM ChatHistoryItem $1 JOIN $1.recipient $2 WHERE ($2.id='22afeafe-363f-4397-8553-cc5688ba142d') ORDER BY MAX($1.createDate) DESC
entity object is:
@Entity public class ChatHistoryItem extends AbstractObject { private static final long serialVersionUID = 1L; @Column(length=1024) private String text; @Embedded private PersonData sender; @Embedded private PersonData recipient; @ElementCollection(targetClass = ChatAttachment.class, fetch = FetchType.EAGER) private List<ChatAttachment> attachments; private boolean isSystem; private boolean isViewed; private boolean isPriority; public String getText() { return text; } public void setText(String text) { this.text = text; } public PersonData getSender() { return sender; } public void setSender(PersonData sender) { this.sender = sender; } public PersonData getRecipient() { return recipient; } public void setRecipient(PersonData recipient) { this.recipient = recipient; } public List<ChatAttachment> getAttachments() { return attachments; } public void setAttachments(List<ChatAttachment> attachments) { this.attachments = attachments; } public boolean getIsSystem() { return isSystem; } public void setIsSystem(boolean isSystem) { this.isSystem = isSystem; } public boolean getIsViewed() { return isViewed; } public void setIsViewed(boolean isViewed) { this.isViewed = isViewed; } public boolean isIsPriority() { return isPriority; } public void setIsPriority(boolean isPriority) { this.isPriority = isPriority; } @Override public String toString() { return "granat.dp.domain.entity.DialogItem[ id=" + getId() + " ]"; } }
Thanks for your help.