Let's make a journey...
What I want to achieve is
SELECT * FROM people WHERE interest->'interests' ?| ARRAY['sport','cars'];
into my Repository defined as
public interface PeopleRepository extends CrudRepository {
@Query("SELECT *…
I'm trying to use Spring Data JDBC with Kotlin data-classes, and after adding @Transient property to primary constructor I received error on simple findById call:
java.lang.IllegalStateException: Required property transient not found for class…
Do I need to configure the beans in the example below for my Spring Data JDBC project?
Even without those beans, I was able to have my repository queries working correctly.
As I understand, NamedParameterJdbcOperations is used only internally to…
CrudRepository#save doesn't allow you to use default columns. null-fields of an entity are interpreted as NULL not DEFAULT.
If I use a custom @Query("INSERT INTO ... DEFAULT ..."), then I'm unable to obtain the ID of the inserted row.
In a spring test there was the question:
"Would Spring Data JDBC dependency autoconfigure a Datasource and a JDBCTemplate?"
I would say no because, you need a database connector dependency like h2 or oracle right to autoconfigure a datasource? And a…
First of all I want to say that I really like the Spring Data abstraction and the way how it helps me to unify handling in the persistence layer of Spring application.
Recently I noticed that Spring Data JDBC came out so I decided to use it in a…
Does Spring Data JDBC validate entities while persisting - as Spring Data JPA does with the help of hibernate?
I have this scenario:
Entity (more or less a copy of the actual database table)
EntityDto (Data Transfer Object) with validation…
I'm working on a new project, using concepts like clean architecture, protecting my model and business rules from external dependencies and frameworks. Also, I prefer not to use traditional ORM libraries (like JPA/Hibernate) and have choose to use…
I have an entity
public class Arena {
@Id
private final Long id;
@Embedded(onEmpty = Embedded.OnEmpty.USE_NULL)
final Point location;
}
Point comes from org.springframework.data.geo package
and Postgres schema to it
CREATE TABLE…
I am developing an app that uses Spring Boot 2 and Spring Data JDBC. The final app will use MySQL.
I currently have a persistence layer and a service layer together with a few repositories derived from CrudRepository.
For my unit tests, I want to…
Let's take a following entity:
class Item{
@Id
Long id;
String name;
org.joda.money.Money price;
}
and a corresponding repository:
interface ItemRepository extends CrudRepository {
}
Is it possible to persist Item in a…
I have an existing data scheme I'm reluctant to change. There are two entities/tables: parent and child, with child having the foreign key column parent_id. It's a 1(parent)-to-n(children) relationship.
Is it possible within Spring Data JDBC to have…
I have an existing data scheme I'm reluctant to change. There are two entities/tables: parent and child, with parent having the foreign key column child_id. It's a 1-to-1 relationship.
The problem is: the magic behind the scenes expects the child…
How can I write Queries for entities containing a 1-n reference?
Based on the spring-data-jdbc examples I will explain it with the following unit-test:
@Test
public void customQuery_ReferenceMultipleInstances() {
// prepare
LegoSet smallCar =…
I am trying spring data jdbc with @query and I met a question: If I have a query that joins 2
tables like this:
@Query("select a.*, b.* from master a, detail b where b.master_id=a.id and a.id=:id")
How do I get the response?
The official Spring…