Exception in using logged in user id in Query

I am trying to use the number of records from Message Entity with the condition of recipient. Recipient is actually user.

Entity



@NamePattern("%s|title")
@Table(name = "ERP_MESSAGE")
@Entity(name = "erp$Message")
public class Message extends StandardEntity {
    private static final long serialVersionUID = 7633510543683363969L;

    @Column(name = "TITLE")
    protected String title;

    @Lob
    @Column(name = "MESSAGE_TEXT")
    protected String messageText;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "EXPIRE_DATE")
    protected Date expireDate;

    @Column(name = "READ_")
    protected Boolean read;

    @Lookup(type = LookupType.DROPDOWN, actions = {"lookup", "open"})
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SENDER_ID")
    protected ExtUser sender;

    @Lookup(type = LookupType.DROPDOWN, actions = {"lookup", "open"})
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "RECIPIENT_ID")
    protected ExtUser recipient;

.....

I have used the following SQL in xml as collection datasource


select e from erp$Message e
 where e.recipient = :session$userLogin

while trying to refresh the datasource, getting the following exception.


IllegalArgumentException: You have attempted to set a value of type class java.lang.String for parameter session_userLogin with expected type of class com.inteacc.erp.entity.gen.ExtUser from query string 
                select e from erp$Message e
 where e.recipient = :session_userLogin

Your query should be:

select e from erp$Message e 
 where e.recipient.loginLowerCase = :session$userLogin

Thank you Konstantin.