I'm currently creating a simple application with a psql DB using Micronaut Data, and I'm using a CrudRepository to make queries. However I keep receiving the following error when trying to use the "findBySymbol" query :
[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
This is my Entity:
@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;
}
and repository:
@Repository
public interface QuotesRepository extends CrudRepository<QuoteEntity, Integer> {
@Override
List<QuoteEntity> findAll();
Optional<QuoteEntity> findBySymbol(SymbolEntity symbol);
}
and the controller I'm making the call from:
@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());
}
has anyone got any idea's on where the issue is coming from?