我为我的表创建了一个数据类,该数据类在命名查询中引发错误

发布于 2025-01-10 19:42:02 字数 1417 浏览 0 评论 0原文

实体名称与表名称类似。


@Table
@Entity(name = "CKYCUploadTransactions")
@Access(AccessType.FIELD)
@NamedQueries({
       @NamedQuery(name = "CKYCUploadTransactions.byUserId", query = "select k from CKYCUploadTransactions k where" +
               "k.userId = :user_id"),
       @NamedQuery(name = "CKYCUploadTransactions.byUserIdAndTxnTypeAndStatus", query = "select k from CKYCUploadTransactions k where" +
               "k.userId = :user_id AND k.txnType = :txn_type AND k.status = :status"),
       @NamedQuery(name = "CKYCUploadTransactions.byUserIdAndContext", query = "select k from CKYCUploadTransactions k where" +
               "k.userId = :user_id and k.context = :context")
})
@Data
public class CKYCUploadTransactions {

    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(name = "user_id")
    private String userId;

    @Column(name = "context")
    private String context;

    @Column(name = "txn_type")
    private String txnType;

    @Enumerated(EnumType.STRING)
    @Column(name = "status", length = 20)
    private Status status;

    public enum Status{
        initiated,
        success,
        failed
    }

}

我不明白为什么它会抛出此错误,我创建了另一个类似的实体,但没有遇到那里的问题。

异常:命名查询中的错误:CKYCUploadTransactions.byUserIdAndTxnTypeAndStatus、CKYCUploadTransactions.byUserIdAndContext、CKYCUploadTransactions.byUserId

Entity name is similar to name of the table.


@Table
@Entity(name = "CKYCUploadTransactions")
@Access(AccessType.FIELD)
@NamedQueries({
       @NamedQuery(name = "CKYCUploadTransactions.byUserId", query = "select k from CKYCUploadTransactions k where" +
               "k.userId = :user_id"),
       @NamedQuery(name = "CKYCUploadTransactions.byUserIdAndTxnTypeAndStatus", query = "select k from CKYCUploadTransactions k where" +
               "k.userId = :user_id AND k.txnType = :txn_type AND k.status = :status"),
       @NamedQuery(name = "CKYCUploadTransactions.byUserIdAndContext", query = "select k from CKYCUploadTransactions k where" +
               "k.userId = :user_id and k.context = :context")
})
@Data
public class CKYCUploadTransactions {

    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(name = "user_id")
    private String userId;

    @Column(name = "context")
    private String context;

    @Column(name = "txn_type")
    private String txnType;

    @Enumerated(EnumType.STRING)
    @Column(name = "status", length = 20)
    private Status status;

    public enum Status{
        initiated,
        success,
        failed
    }

}

I am not understanding why it is throwing this error, I have created another entity like this but not facing the issues there.

Exception: Errors in named queries: CKYCUploadTransactions.byUserIdAndTxnTypeAndStatus, CKYCUploadTransactions.byUserIdAndContext, CKYCUploadTransactions.byUserId

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

分分钟 2025-01-17 19:42:02

您可以按照此 JPA 命名查询

CKYCUploadTransactions.byUserId
应该是
CKYCUploadTransactions.findByUserId

You can follow this JPA Named Queries

CKYCUploadTransactions.byUserId
should be
CKYCUploadTransactions.findByUserId

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文