簡體   English   中英

Hibernate Micronaut 數據 JPA:命名參數未綁定:p1

[英]Hibernate Micronaut Data JPA: Named parameter not bound : p1

我目前正在使用 Micronaut Data 創建一個帶有 psql DB 的簡單應用程序,並且我正在使用 CrudRepository 進行查詢。 但是,在嘗試使用“ findBySymbol ”查詢時,我不斷收到以下錯誤:

    [default-nioEventLoopGroup-1-3] ERROR io.micronaut.http.server.RouteExecutor - Unexpected error occurred: Named parameter not bound : p1
org.hibernate.QueryException: Named parameter not bound : p1

這是我的實體:

 @Entity(name = "quote")
@Table(name = "quote", schema = "mn")
@Data
@Introspected
public class QuoteEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @ManyToOne(targetEntity = SymbolEntity.class)
    @JoinColumn(name = "symbol", referencedColumnName = "value")
    private SymbolEntity symbol;

    private BigDecimal bid;

    private BigDecimal ask;
    @Column(name = "last_price")
    private BigDecimal lastPrice;

    private BigDecimal volume;
    
}

和存儲庫:

@Repository
public interface QuotesRepository extends CrudRepository<QuoteEntity, Integer> {

    @Override
    List<QuoteEntity> findAll();

    Optional<QuoteEntity> findBySymbol(SymbolEntity symbol);
}

和 controller 我正在撥打電話:

 @Operation(summary = "Returns a quote for the given symbol via JPA fetched from the DB")
    @ApiResponse(content = @Content(mediaType = MediaType.APPLICATION_JSON))
    @ApiResponse(responseCode = "400", description = "Invalid symbol")
    @Tag(name = "Quotes")
    @Get("/{symbol}/jpa")
    public HttpResponse getQuoteViaJPA(@PathVariable String symbol) {
        final Optional<QuoteEntity> quote = repository.findBySymbol(new SymbolEntity(symbol));
        if (quote.isEmpty()) {
            final CustomError notFound = CustomError.builder()
                    .status(HttpStatus.NOT_FOUND.getCode())
                    .error(HttpStatus.NOT_FOUND.name())
                    .message("Quote for symbol not available in DB")
                    .path("/quotes/" + symbol + "/jpa")
                    .build();
            return HttpResponse.notFound(notFound);
        }
        return HttpResponse.ok(quote.get());
    }

有沒有人知道問題出在哪里?

3.2.2 版本的 Micronaut-data-hibernate-jpa 似乎存在問題,將版本更改回 3.0.0 似乎已經解決了問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM