spring-data-jpa

org.hibernate.MappingException: Could not determine type for: at table: for columns: [org.hibernate.mapping.Column(plant)

旧时模样 提交于 2021-01-28 20:03:25
问题 I know this question have been asked several times but, they didn't help me. I have the following test: public class PlantCatalogTests { @Autowired PlantInventoryEntryRepository plantRepo; @Test public void queryPlantCatalog() { assertThat(plantRepo.count(), is(14l)); } and here is PlantInventoryEntryRepository @Repository public interface PlantInventoryEntryRepository extends JpaRepository<PlantInventoryEntry, Long> {} As you see, this repository is based on the class PlantInventoryEntry

Exclude certain DataSource(s) from HibernateJpaAutoConfiguration

左心房为你撑大大i 提交于 2021-01-28 19:51:01
问题 I have a project with 2 DataSources. One is for PostgreSQL and other is for ClickHouse. No problem so far. I intend to use ClickHouse with native SQL via JDBC only. But I would like to use JPA based repositories with PostgreSQL datasource. And if I add spring-boot-starter-data-jpa dependency, HibernateJpaAutoConfiguration kicks in for ALL registered DataSource beans . ClickHouse is not a transactional relational DB and its JDBC implementation is very limited and basic, never intended for use

How to resolve No converter found capable of converting from type TupleBackedMap to type [com.example.dto.ExampleDto]

吃可爱长大的小学妹 提交于 2021-01-28 18:54:57
问题 org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type [com.example.dto.ExampleDto] at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:321) ~[spring-core-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.core.convert.support.GenericConversionService.convert

(Spring/JpaRepository ) Inheriting methods of JpaRepository from BaseEntityRepository to SubEntityRepository

自作多情 提交于 2021-01-28 18:26:32
问题 What would be the best practice for the following case? You have the following entities: @Entity public class BaseEntity { } @Entity public class SubEntity extends BaseEntity { } And you have a JpaRepository for BaseEntity having multiple select-methods: public interface BaseEntityRepository extends JpaRepository<BaseEntity, Long> { Set<BaseEntity> findAll(); Set<BaseEntity> findSome...(); } Now you want a JpaRepository for SubEntity inheriting all the methods from BaseEntityRepository. Now I

org.postgresql.util.PSQLException: ERROR: operator does not exist: integer = bytea

随声附和 提交于 2021-01-28 14:38:46
问题 I am trying to execute a Native Query from a Spring Boot application, but i am getting this error " org.postgresql.util.PSQLException: ERROR: operator does not exist: integer = bytea " Here are the codes i have written to implement this @SqlResultSetMapping( name = "StudentAssessmentValue", classes = @ConstructorResult( targetClass = StudentAssessmentDTO.class, columns = { @ColumnResult(name = "subject_title", type = String.class), @ColumnResult(name = "assessment", type = String.class), } )

JPA @OnetoOne self reference relationship with both columns non null

耗尽温柔 提交于 2021-01-28 05:28:16
问题 I have an existing database table For e.g. T_STUDENTS on top of which I have to create a JPA entity. All three columns in the table are NON NULL and the table has a self-reference as mentor_id id | name | mentor_id -----|---------|---------- 1 | John | 1 -----|---------|---------- 2 | Marc | 1 -----|---------|---------- 3 | Abby | 2 -----|---------|---------- 4 | Jimy | 3 -----|---------|---------- 5 | Boni | 4 -----|---------|---------- Each student has a mentor who is also a student. There

why saveAll() always inserts data instead of update it?

狂风中的少年 提交于 2021-01-28 04:51:51
问题 Spring Boot 2.4.0 , DB is MySql 8 . Data is fetched every 15 seconds from remote with REST and storing it to MySql DB with saveAll() . Which call the save() method for all the given entities. All data has set ID. And I am expecting that if there is no such id at DB - it will be inserted . If such ID is already presented at DB - it will be updated . Here is snipped from the console: Hibernate: insert into iot_entity (controller_ref, description, device_id, device_ref, entity_type_ref, hw

How to use multiple LIKE '%keyword%' in Sping JPA on same column?

江枫思渺然 提交于 2021-01-28 03:59:00
问题 I am able to search for a keyword in a column using List<Application> findByProposalContainingIgnoreCase(String keyword); How can I achieve the same using a list of keywords? For example: List<Application> findByProposalContainingIgnoreCase(List<String> keywords); UPDATE: If it is not possible to do so, is the below way effective: @Autowired private ApplicationService applicationService; List<Application> applications = new ArrayList<>(); for (String keyword : keywords) { applications.addAll

Spring MVC OptionalValidatorFactoryBean not found

眉间皱痕 提交于 2021-01-28 03:56:00
问题 Hi I have set up a Spring MVC (4)+Postgresql+JPA app and I encountered the following situation: I want to set up custom queries for my "User" repository so added these lines to the existing (empty) UserRepository: public interface AccountRepository extends JpaRepository<User,Long> { @Query("select u from User u where u.Email = ?1") User findByEmail(String emailAddress); } With the empty Repository, everything is OK with the server, with the verison above I got the following exception on

Validate minimum length of parameter in Spring Jpa Query

不打扰是莪最后的温柔 提交于 2021-01-28 03:51:56
问题 We have a data object Foo that has a string property Bar, and a jpa repository with a method to find Foo by Bar: @Entity @Table(name = "FOO") public class Foo { @Id @GeneratedValue private Long id; @Column(name = "BAR", length = 16, nullable = false) private String bar; public String getBar() { return bar; } public void setBar(String bar) { this.bar = bar; } } public interface FooJpaRepository extends JpaRepository<Foo, Long> { @Transactional(propagation = Propagation.REQUIRED, readOnly =