hibernate

Unable To use java.time.LocalDate in JPA entity with MySql

自古美人都是妖i 提交于 2021-02-19 04:47:07
问题 I am trying to use LocalDate in my entities and this usage has plenty of documentation around the net. Which is why I am baffled it doesn't work. Here is my error: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect date value: '\xAC\xED\x00\x05sr\x00\x0Djava.time.Ser\x95]\x84\xBA\x1B"H\xB2\x0C\x00\x00xpw\x07\x03\x00\x00\x07\xD7\x0C\x03x' So, it obviously needs a converter. I have tried the following links: This one says to add the spring converters to the scan path for the

Can I mix both update and insert in saveAll from JpaRepository

限于喜欢 提交于 2021-02-19 04:43:06
问题 I am using Spring Boot and Spring Data JPA and Hibernate as the persistence provider. I have extended my Repository interface with JPARepository . I have a list of Entity Bean for a table. Some of them already exist and some of them not. I want to know what will happen when I call saveAll from my service layer and pass this List ? 回答1: If you look at the SimpleJpaRepository which is a common implementation of the CrudRepository you can see that it will simply invoke save for each of the

How can I store and load an encrypted value using custom annotation

末鹿安然 提交于 2021-02-19 04:40:06
问题 I am new to Java custom annotations I am developing a custom annotation which encrypt and decrypt a string and store it in database using spring and mongodb and for encryption I am using jasypt. I am not getting the exact procedure to do so. My code. Entity public class Demo { @Id private Long id; private String somethingPublic; @EncryptDemo() private String somethingPrivate; //getter setter } custom annotation @Target({ ElementType.METHOD, ElementType.FIELD }) @Retention(RetentionPolicy

How spring data clean persited entities in transactional method?

房东的猫 提交于 2021-02-19 03:48:31
问题 I need to receive and save huge amount of data using spring data over hibernate. Our server allocated not enough RAM for persisting all entities at the same time. We will definitely get OutOfMemory error. So we need to save data by batches it's obvious. Also we need to use @Transactional to be sure that all data persisted or non was persisted in case of even single error. So, the question: does spring data during @Transactional method keep storing entities in RAM or entities which were

H2 database doesn't work in memory only with file

寵の児 提交于 2021-02-19 03:17:57
问题 I have a Spring MVC project set up with Hibernate and wanted to create some tests for some Services. The main application uses a PostgreSQL database and for tests I want to use H2 in memory database I created separate configuration files for the tests (both Spring and Hibernate) Everything works well until I try to hit the in memory database Hibernate configuration: @Configuration @EnableTransactionManagement @EnableJpaRepositories("<repository>") public class DataSourceTestConfig { private

H2 database doesn't work in memory only with file

↘锁芯ラ 提交于 2021-02-19 03:16:44
问题 I have a Spring MVC project set up with Hibernate and wanted to create some tests for some Services. The main application uses a PostgreSQL database and for tests I want to use H2 in memory database I created separate configuration files for the tests (both Spring and Hibernate) Everything works well until I try to hit the in memory database Hibernate configuration: @Configuration @EnableTransactionManagement @EnableJpaRepositories("<repository>") public class DataSourceTestConfig { private

H2 database doesn't work in memory only with file

我的未来我决定 提交于 2021-02-19 03:15:08
问题 I have a Spring MVC project set up with Hibernate and wanted to create some tests for some Services. The main application uses a PostgreSQL database and for tests I want to use H2 in memory database I created separate configuration files for the tests (both Spring and Hibernate) Everything works well until I try to hit the in memory database Hibernate configuration: @Configuration @EnableTransactionManagement @EnableJpaRepositories("<repository>") public class DataSourceTestConfig { private

How to filter postgres array column with the JPA criteria API?

大憨熊 提交于 2021-02-18 23:01:48
问题 I am using: Hibernate 4.3.5 Spring JPA 1.6.0 Javax Persistence API 2.1 The "refcodemailing" column is defined as an array of int: int[] My entity object: @Entity @Table public class CalendarEvent implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id = 0; @Convert(converter = IntegerArrayConverter.class) @Column(name = "refcodemailing") private final List<Integer> mailingCodes = new ArrayList<>(); // .... } I am trying to filter the column array with the

What are the alternatives to using an ORDER BY in a Subquery in the JPA Criteria API?

喜你入骨 提交于 2021-02-18 22:01:57
问题 Consider the following two tables: Project ( id, project_name) Status ( id, id_project, status_name) Where Status contains all statuses in which a Project has been. Lets say we want to query all projects for which the latest status has the name "new". The Sql query that I come up with is: SELECT q.id_project FROM status q WHERE q.status_name like 'new' AND q.id IN ( SELECT TOP 1 sq.id from status sq WHERE q.id_project = sq.id_project ORDER BY sq.id DESC ) I'm trying to replicate the above

What are the alternatives to using an ORDER BY in a Subquery in the JPA Criteria API?

末鹿安然 提交于 2021-02-18 22:00:39
问题 Consider the following two tables: Project ( id, project_name) Status ( id, id_project, status_name) Where Status contains all statuses in which a Project has been. Lets say we want to query all projects for which the latest status has the name "new". The Sql query that I come up with is: SELECT q.id_project FROM status q WHERE q.status_name like 'new' AND q.id IN ( SELECT TOP 1 sq.id from status sq WHERE q.id_project = sq.id_project ORDER BY sq.id DESC ) I'm trying to replicate the above