После оценки хранилища # Ошибка как показано: Я сгенерировал сущность в jhipster с возможностями разбивки на страницы. После сгенерированного был столбец по умолчанию с именем Id, который не упоминается в json. Как бы то ни было, в домене я упомянул еще один столбец как @Id. Затем методы post работают нормально, но метод get не работает. Выдает исключение с грамматикой sql. Мой домен, коды ресурсов и репозитория:
**InsInsuranceType.java**
package com.insursoft.domain;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Objects;
/**
* A InsInsuranceType.
*/
@Entity
@Table(name = "ins_insurance_type")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class InsInsuranceType implements Serializable {
private static final long serialVersionUID = 1L;
/*@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;*/
@Id
@Column(name = "ins_tp_cd")
private Integer insTpCd;
@Column(name = "short_nm")
private String shortNm;
@Column(name = "ins_tp_nm")
private String insTpNm;
// jhipster-needle-entity-add-field - JHipster will add fields here,
do not remove
public Integer getInsTpCd() {
return insTpCd;
}
public InsInsuranceType insTpCd(Integer insTpCd) {
this.insTpCd = insTpCd;
return this;
}
public String getShortNm() {
return shortNm;
}
public InsInsuranceType shortNm(String shortNm) {
this.shortNm = shortNm;
return this;
}
public void setShortNm(String shortNm) {
this.shortNm = shortNm;
}
public String getInsTpNm() {
return insTpNm;
}
public InsInsuranceType insTpNm(String insTpNm) {
this.insTpNm = insTpNm;
return this;
}
public void setInsTpNm(String insTpNm) {
this.insTpNm = insTpNm;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
InsInsuranceType insInsuranceType = (InsInsuranceType) o;
if (insInsuranceType.getInsTpCd() == null || getInsTpCd() == null) {
return false;
}
return Objects.equals(getInsTpCd(), insInsuranceType.getInsTpCd());
}
@Override
public int hashCode() {
return Objects.hashCode(getInsTpCd());
}
@Override
public String toString() {
return "InsInsuranceType{" +
", insTpCd=" + getInsTpCd() +
", shortNm='" + getShortNm() + "'" +
", insTpNm='" + getInsTpNm() + "'" +
"}";
}
}
InsInsuranceTypeResource.java
/**
* GET /ins-insurance-types : get all the insInsuranceTypes.
*
* @param pageable the pagination information
* @return the ResponseEntity with status 200 (OK) and the list of
insInsuranceTypes in body
*/
@GetMapping("/ins-insurance-types")
@Timed
public ResponseEntity<List<InsInsuranceType>>
getAllInsInsuranceTypes(Pageable pageable) {
log.debug("REST request to get a page of InsInsuranceTypes");
Page<InsInsuranceType> page = insInsuranceTypeRepository.findAllByInsTpCd(pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/ins-insurance-types");
return ResponseEntity.ok().headers(headers).body(page.getContent());
}
**** InsInsuranceTyperepository.java:****
package com.insursoft.repository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import com.insursoft.domain.InsInsuranceType;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
/**
* Spring Data repository for the InsInsuranceType entity.
*/
@SuppressWarnings("unused")
@Repository
public interface InsInsuranceTypeRepository extends JpaRepository<InsInsuranceType, Integer> {
@Query("SELECT model FROM InsInsuranceType model")
Page<InsInsuranceType> findAllByInsTpCd(Pageable pageable);
}
The error :
result = {InvalidDataAccessResourceUsageException@15933} Method threw 'org.springframework.dao.InvalidDataAccessResourceUsageException' exception.
detailMessage = "could not extract ResultSet; SQL [n/a]"
value = {char[38]@15946}
hash = 0
cause = {SQLGrammarException@15939} "org.hibernate.exception.SQLGrammarException: could not extract ResultSet"
sqlException = {SQLSyntaxErrorException@15947} "java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended\n"
sql = "n/a"
detailMessage = "could not extract ResultSet"
value = {char[27]@15952}
hash = 0
cause = {SQLSyntaxErrorException@15947} "java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended\n"
stackTrace = {StackTraceElement[188]@15949}
suppressedExceptions = {Collections$UnmodifiableRandomAccessList@15493} size = 0
stackTrace = {StackTraceElement[154]@15940}
suppressedExceptions = {Collections$UnmodifiableRandomAccessList@15493} size = 0