在字符 1 处遇到 "INSERT",但预期为:["DELETE"、"SELECT"、"UPDATE"]
Encountered "INSERT" at character 1, but expected: ["DELETE", "SELECT", "UPDATE"]
我有一个插入 JPA 命名查询,如下所示。当我尝试使用实体管理器从我的 DAO 执行它时,出现以下错误。我正在使用 Apache OpenJPA,我无法确定此问题的根本原因。由于域对象的复杂性,我无法使用持久化方法。
在字符 1 处遇到 "INSERT",但预期为:["DELETE"、"SELECT"、"UPDATE"].
@NamedQuery(
name=IuaPersistenceConstants.QUERY_INSERT_AGREEMENT_ACKNOWLEDGEMENT,
query="INSERT INTO AgreementAcknowledgement agrackn VALUES agrackn.id.agrmntCntntUrl = :agrmntCntntUrl, agrackn.id.prvsndUserSqn = :prvsndUserSqn, agrackn.id.prvsnUserEffD = :userEffDate, " +
"agrackn.id.agrmntacknEffD = :agrmntacknEffD, agrackn.acknExpD = :acknExpD, agrackn.crtTs = :crtTs, agrackn.crtUidC = :crtUidC, agrackn.lstUpdtTs = :lstUpdtTs, agrackn.lstUpdtUidC = :lstUpdtUidC")
Query ackQuery =getEntityManager().createNamedQuery(IuaPersistenceConstants.QUERY_INSERT_AGREEMENT_ACKNOWLEDGEMENT);
ackQuery.setParameter("agrmntCntntUrl", agreementDO.getAgreementURL());
ackQuery.setParameter("agrmntacknEffD", agreementDO.getAgreementEffDate());
ackQuery.setParameter("acknExpD", agreementDO.getAgreementExpDate());
ackQuery.setParameter("prvsndUserSqn", userDO.getUserSequence());
ackQuery.setParameter("userEffDate", userDO.getUserEffDate());
ackQuery.setParameter("crtTs", new Date());
ackQuery.setParameter("crtUidC", "WS");
ackQuery.setParameter("lstUpdtTs", new Date());
ackQuery.setParameter("lstUpdtUidC", "WS");
ackQuery.executeUpdate();
OpenJPA doesn't seem to support JPQL "INSERT" queries。但这并不奇怪,因为 JPA 没有定义 INSERT 查询。它定义了 SELECT、UPDATE、DELETE 查询,仅此而已。请参阅 JPA 规范。这不是 SQL。
我有一个插入 JPA 命名查询,如下所示。当我尝试使用实体管理器从我的 DAO 执行它时,出现以下错误。我正在使用 Apache OpenJPA,我无法确定此问题的根本原因。由于域对象的复杂性,我无法使用持久化方法。
在字符 1 处遇到 "INSERT",但预期为:["DELETE"、"SELECT"、"UPDATE"].
@NamedQuery(
name=IuaPersistenceConstants.QUERY_INSERT_AGREEMENT_ACKNOWLEDGEMENT,
query="INSERT INTO AgreementAcknowledgement agrackn VALUES agrackn.id.agrmntCntntUrl = :agrmntCntntUrl, agrackn.id.prvsndUserSqn = :prvsndUserSqn, agrackn.id.prvsnUserEffD = :userEffDate, " +
"agrackn.id.agrmntacknEffD = :agrmntacknEffD, agrackn.acknExpD = :acknExpD, agrackn.crtTs = :crtTs, agrackn.crtUidC = :crtUidC, agrackn.lstUpdtTs = :lstUpdtTs, agrackn.lstUpdtUidC = :lstUpdtUidC")
Query ackQuery =getEntityManager().createNamedQuery(IuaPersistenceConstants.QUERY_INSERT_AGREEMENT_ACKNOWLEDGEMENT);
ackQuery.setParameter("agrmntCntntUrl", agreementDO.getAgreementURL());
ackQuery.setParameter("agrmntacknEffD", agreementDO.getAgreementEffDate());
ackQuery.setParameter("acknExpD", agreementDO.getAgreementExpDate());
ackQuery.setParameter("prvsndUserSqn", userDO.getUserSequence());
ackQuery.setParameter("userEffDate", userDO.getUserEffDate());
ackQuery.setParameter("crtTs", new Date());
ackQuery.setParameter("crtUidC", "WS");
ackQuery.setParameter("lstUpdtTs", new Date());
ackQuery.setParameter("lstUpdtUidC", "WS");
ackQuery.executeUpdate();
OpenJPA doesn't seem to support JPQL "INSERT" queries。但这并不奇怪,因为 JPA 没有定义 INSERT 查询。它定义了 SELECT、UPDATE、DELETE 查询,仅此而已。请参阅 JPA 规范。这不是 SQL。