spring-data-jdbc

Problems to inject Repository when data-jpa dep is on

℡╲_俬逩灬. 提交于 2020-03-03 08:41:21
问题 I noticed, as soon as I un-comment JPA dep, see below: implementation("org.springframework.boot:spring-boot-starter-jdbc") implementation ("org.springframework.boot:spring-boot-starter-data-jdbc") //implementation ("org.springframework.boot:spring-boot-starter-data-jpa") I do not have any @Entity annotated classes in my code. I got an error on start: The bean 'myRepository', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is

Problems to inject Repository when data-jpa dep is on

故事扮演 提交于 2020-03-03 08:41:07
问题 I noticed, as soon as I un-comment JPA dep, see below: implementation("org.springframework.boot:spring-boot-starter-jdbc") implementation ("org.springframework.boot:spring-boot-starter-data-jdbc") //implementation ("org.springframework.boot:spring-boot-starter-data-jpa") I do not have any @Entity annotated classes in my code. I got an error on start: The bean 'myRepository', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is

NoSuchBeanDefinitionException after update to spring boot 2.2.1

∥☆過路亽.° 提交于 2020-01-25 00:20:07
问题 I face a strange issue after upgrading my existing code from spring boot 2.2.0 to 2.2.1. It seems that my spring data jdbc repositories are not getting scanned anymore somehow: Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'de.thd.dmpk.establishmentmanagement.IEstablishmentRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} Furthermore this informational debug line is there

How to handle compound keys with Spring Data JDBC

谁都会走 提交于 2020-01-14 14:44:08
问题 I'm trying to use Spring Data JDBC to access a table that has a compound key, and although I can find lots of info on how Spring Data JPA handles this, the same doesn't seem to apply to Spring Data JDBC. Can anyone give a quick example of how you need to declare an Entity/Repository with Spring Data JDBC to talk to a table with a compound primary key ? (Eg. Two Strings) 回答1: Using the CrudRepository for compound keys is currently (Version 1.0.2) not possible. Of course, you can still use

@CreatedDate annotated field is not written on Insert, @LastModifiedDate is

為{幸葍}努か 提交于 2020-01-06 06:36:14
问题 I created the following Entity and test it using h2: @Getter public class Topic { @Id private long id; private final Title title; @CreatedDate private LocalDateTime createdAt; @LastModifiedDate private LocalDateTime lastModified; // ... } The TopicRepository is an empty interface. The following test fails with the error that createdAt is null: @RunWith(SpringRunner.class) @SpringBootTest public class BasicRepositoryTests { @Autowired TopicRepository topicRepository; @Test public void

@CreatedDate annotated field is not written on Insert, @LastModifiedDate is

我是研究僧i 提交于 2020-01-06 06:36:13
问题 I created the following Entity and test it using h2: @Getter public class Topic { @Id private long id; private final Title title; @CreatedDate private LocalDateTime createdAt; @LastModifiedDate private LocalDateTime lastModified; // ... } The TopicRepository is an empty interface. The following test fails with the error that createdAt is null: @RunWith(SpringRunner.class) @SpringBootTest public class BasicRepositoryTests { @Autowired TopicRepository topicRepository; @Test public void

Spring Data JDBC invert OneToMany navigation

独自空忆成欢 提交于 2020-01-05 08:27:28
问题 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 Child class reference Parent and not Parent have a Set<Child> property? Maybe both? (I know it is possible with hibernate, but I'd like to stay with JDBC). I.e. I want something like this: @Data public class Parent { @Id private Long id; } @Data

Spring Data JDBC invert OneToOne navigation

ⅰ亾dé卋堺 提交于 2020-01-05 05:11:31
问题 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 table to have the foreign key column (the exception mentions a ...JOIN ON child.parent = parent.id ). Is it possible to inverse this to match the existing scheme? (I know it is with hibernate, but I'd like to stay with JDBC). Relevant code:

Spring Data JDBC invert OneToOne navigation

我与影子孤独终老i 提交于 2020-01-05 05:11:06
问题 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 table to have the foreign key column (the exception mentions a ...JOIN ON child.parent = parent.id ). Is it possible to inverse this to match the existing scheme? (I know it is with hibernate, but I'd like to stay with JDBC). Relevant code:

Spring Data JDBC - One to Many - Kotlin

安稳与你 提交于 2019-12-24 11:28:23
问题 I use spring boot 2.1.1.RELEASE and spring-data-jdbc 1.0.3.RELEASE, Kotlin 1.3.10. I have the following simple class definitions in kotlin: @Table(value = "CUSTOMER") data class Customer( @Id var id: Long?, @Column("NAME") var name: String, @Column("PUBLICATION_NAME") var publicationName: String, @Column("START_DATE") var startDate: String, @Column("END_DATE") var endDate: String, var items: MutableSet<Item> ) @Table(value = "ITEM") data class Item ( @Id var id: Long?, @Column("name") var