Почему не понимает Sql запрос?
2020-03-17 16:35:02.936 ERROR 4800 --- [nio-8080-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: could not execute query; SQL [select cancelledc0_.ID as id1_0_, cancelledc0_.PERSON_FULL_NAME as person_f2_0_, cancelledc0_.LAWYER_ID as lawyer_i3_0_, (select l.version from lawyers l where l.id = cancelledc0_.lawyer_id) as formula1_ from COMMON_BASE_DOC cancelledc0_]; nested exception is org.hibernate.exception.DataException: could not execute query] with root cause
org.firebirdsql.gds.GDSException: multiple rows in singleton select
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.readStatusVector(AbstractJavaGDSImpl.java:2103) ~[jaybird-jdk18-2.2.15.jar:2.2.15-JDK_1.8 (build: tag=v2.2.15 date=201904061030)]
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.receiveResponse(AbstractJavaGDSImpl.java:2053) ~[jaybird-jdk18-2.2.15.jar:2.2.15-JDK_1.8 (build: tag=v2.2.15 date=201904061030)]
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlFetch(AbstractJavaGDSImpl.java:1318) ~[jaybird-jdk18-2.2.15.jar:2.2.15-JDK_1.8 (build: tag=v2.2.15 date=201904061030)]
Tue Mar 17 15:57:36 MSK 2020
There was an unexpected error (type=Internal Server Error, status=500).
could not execute query; SQL [select cancelledc0_.ID as id1_0_, cancelledc0_.PERSON_FULL_NAME as person_f2_0_, cancelledc0_.LAWYER_ID as lawyer_i3_0_, (select l.version from lawyers l where l.id = cancelledc0_.lawyer_id) as formula1_ from COMMON_BASE_DOC cancelledc0_]; nested exception is org.hibernate.exception.DataException: could not execute query
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
@Entity
@Table(name = "COMMON_BASE_DOC")
public class CancelledCertificates{
public CancelledCertificates() {
}
@Id
@Column(name = "ID")
private Long id;
@Column(name = "REG_CAPTION", insertable = false, updatable = false)
private String reg_caption;
@Column(name = "REG_CODE", insertable = false, updatable = false)
private String reg_code;
@Formula("(select l.version fromlawyers l, common_base_doc cbd, where l.id = cbd.lawyer_id and cbd.id = id)")
private Integer version;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getFio() {
return fio;
}
public void setFio(String fio) {
this.fio = fio;
}
public Long getLawyer_id() {
return lawyer_id;
}
public void setLawyer_id(Long lawyer_id) {
this.lawyer_id = lawyer_id;
}
public Integer getIs_not_returned() {
return is_not_returned;
}
public void setIs_not_returned(Integer is_not_returned) {
this.is_not_returned = is_not_returned;
}
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}
}
Hibernate не понимает sql запрос, хотя в редакторе запрос выполняется.
@Formula("(select l.version from lawyers l, common_base_doc cbd" +
"where l.id = cbd.lawyer_id and cbd.id = id)")
private Integer version;
There was an unexpected error (type=Internal Server Error, status=500).
could not prepare statement; SQL [select cancelledc0_.ID as id1_0_, cancelledc0_.PERSON_FULL_NAME as person_f2_0_, cancelledc0_.LAWYER_ID as lawyer_i3_0_, (select lic.is_not_returned from LAWYER_IDENTITY_CARD lic, common_base_doc where lic.id = common_base_doc.id and common_base_doc.id = cancelledc0_.id) as formula1_, (select l.version from LAWYER_IDENT ITY_CARD cancelledc0_.lic, lawyers l, common_base_doc cbd, where l.id = cbd.lawyer_id and lic.id = cbd.id and cbd.id = cancelledc0_.id) as formula2_ from COMMON_BASE_DOC cancelledc0_]; nested exception is org.hibernate.exception.SQLGrammarException: could not prepare statement