I'm using Micronaut Data JDBC (not JPA). It works fine with queries, where I can extend the CrudRepositry interface and add the queries as needed. For example:
@JdbcRepository
public interface MyRespository extends CrudRepository<MyEntity, String> {
@Query(
value = "...",
countQuery = "..."
)
Page<String> findByNameEquals(String name, Pageable pageable);
}
All seems fine until I want to override the save(MyEntity myEntity) method. I'm expecting something like this:
@Insert(
value = "insert into my_entity (id, name) values (uuid_to_bin(uuid()), :myEntity.name"
)
public MyEntity(MyEntity myEntity)
But it doesn't seem to exist.
Does it mean I have to write another class for this save method, and as a result will end up with two repository classes, one for queries and one for overriding the save method? If yes how do I get a database connection object with which I can create and execute my sql statement?
Thanks! -Fujian