私はSpringブートとデータレストを使用してJava8で簡単なマイクロサービスを作成し、ポストグレス例外を取得します。春のデータレスト:「日付がnullです」クエリがポストグルの例外をスローする
マイエンティティ:
@Entity
public class ArchivedInvoice implements Serializable {
...
@Column
private String invoiceNumber;
@Column
private java.sql.Date invoiceDate;
...
}
マイリポジトリインタフェース:
@RepositoryRestResource(collectionResourceRel = "archivedinvoices", path = "archivedinvoices")
public interface ArchivedInvoiceRepository extends PagingAndSortingRepository < ArchivedInvoice, Long > {
...
@RestResource(rel = "findByXYZ", path = "findByXYZ")
@Query(value = "SELECT ai FROM #{#entityName} ai WHERE "
+ "(:invoiceNumber IS NULL OR ai.invoiceNumber LIKE :invoiceNumber) AND "
+ "(:invoiceDate IS NULL OR ai.invoiceDate = :invoiceDate)"
)
public Page <ArchivedInvoice> findByXYZ(
@Param("invoiceNumber") @Nullable String invoiceNumber,
@Param("invoiceDate") @Nullable Date invoiceDate,
Pageable p);
...
}
私は」?.../findByXYZ invoiceDate = 2016年2" 月22日と呼んでいる場合、私は以下を取得しますエラーメッセージ:
org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
...
Caused by: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
...
Caused by: org.postgresql.util.PSQLException: FEHLER: could not determine data type of parameter
":invoiceDate IS NULL"部分を削除すると機能します。 invoiceDateパラメータがnullの場合、どうすれば確認できますか?
あなたはhttp://stackoverflow.com/a/27193644/2055854、このいずれかを試みることができる –