gpt4 book ai didi

java - hibernate 上的 native 查询不起作用(意外标记)

转载 作者:行者123 更新时间:2023-12-01 09:47:52 24 4
gpt4 key购买 nike

我正在使用 hibernate 编写此查询。但它不起作用。似乎别名 c 未知。有人知道问题出在哪里吗?

static final  String BEGIN_QUERY = "SELECT c.contratoId, c.contrato, c.classificacao, c.responsavel, c.uf, c.sigla,"
+ "c.statusContrato, c.fornecedor, c.site, c.login, c.senha, c.telefone, c.cnpj, c.codigoFornecedor, c.hidrometro"
+ "c.nome, c.endereco, c.despesa, c.descricao, c.mp, c.status, c.estadoLancamento"
+ "h.historicoId, h.dataCobranca, h.dataVencimento, h.dataEmissao, h.dataLancamento, h.dataCompensacao, h.dataAtualizacao, h.docPgt, h.docCompensacao"
+ "FROM Contrato c, Historico h"
+ "WHERE c.contratoId = h.contratoId"
+ "AND 1=1";

异常(exception):

    Caused by: org.hsqldb.HsqlException: unexpected token: C
at org.hsqldb.error.Error.parseError(Unknown Source)
at org.hsqldb.ParserBase.unexpectedToken(Unknown Source)
at org.hsqldb.ParserDQL.XreadSelect(Unknown Source)
at org.hsqldb.ParserDQL.XreadQuerySpecification(Unknown Source)
at org.hsqldb.ParserDQL.XreadSimpleTable(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryTerm(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpressionBody(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpression(Unknown Source)
at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatement(Unknown Source)
at org.hsqldb.Session.compileStatement(Unknown Source)
at org.hsqldb.StatementManager.compile(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 19 more

最佳答案

您错过了几个空格和逗号

static final  String BEGIN_QUERY = "SELECT c.contratoId, c.contrato, c.classificacao, c.responsavel, c.uf, c.sigla, "
+ "c.statusContrato, c.fornecedor, c.site, c.login, c.senha, c.telefone, c.cnpj, c.codigoFornecedor, c.hidrometro, " // here
+ "c.nome, c.endereco, c.despesa, c.descricao, c.mp, c.status, c.estadoLancamento, " // here
+ "h.historicoId, h.dataCobranca, h.dataVencimento, h.dataEmissao, h.dataLancamento, h.dataCompensacao, h.dataAtualizacao, h.docPgt, h.docCompensacao " // here
+ "FROM Contrato c, Historico h " // here
+ "WHERE c.contratoId = h.contratoId " // and here
+ "AND 1=1";

关于java - hibernate 上的 native 查询不起作用(意外标记),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37836150/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com