SQLGrammarException:没有为条件为参数1指定值

时间:2012-12-03 20:26:02

标签: java hibernate hql

1-1协会:

@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "messageDetails")
public MessageEntry getMessageEntry() {
    return messageEntry;
}

@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
public MessageDetails getMessageDetails() {
    return messageDetails;
}

想要在无状态会话中加载依赖条目:

    MessageDetails messageDetails =
            (MessageDetails) sess.createCriteria(MessageDetails.class)
                    .add(Restrictions.eq("messageEntry", messageEntry))
            .uniqueResult();

我得到了

Exception in thread "main" org.hibernate.exception.SQLGrammarException: No value specified for parameter 1
    at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:122)
    at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)

SQL不是我想要的。可能是我不明白?

03:21:13,274 DEBUG SQL:104 - /* criteria query */ select this_.id as id11_0_, this_.date as date11_0_, this_.messageId as messageId11_0_, this_.replyTo as replyTo11_0_, this_.subject as subject11_0_ from MessageDetails this_ where this_.id=?

我想通过其属性messageEntry选择MessageDetails,是不是可能?感谢名单。

0 个答案:

没有答案