spring-data

@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 @transactional not rolling back with SQL Server and after runtimeexception

老子叫甜甜 提交于 2020-01-06 03:41:04
问题 I've enabled my spring application to use transactions and annotated my service method accordingly but the changes to my DB persist when a RuntimeException is thrown. My Spring configuration looks like this: <!-- Data Source. --> <jee:jndi-lookup id="dataSource" jndi-name="java:/jdbc/BeheermoduleDS"/> <!-- JPA Entity Manager. --> <jee:jndi-lookup id="entityManagerFactory" jndi-name="java:/jpa/BeheermoduleDS"/> <bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">

Combining Starter POMs in Spring Boot

走远了吗. 提交于 2020-01-05 14:28:30
问题 Are the Spring Boot Starters meant to be combined? For example, I want to use Jersey and JPA in my Spring Boot application. Everything works OK if I start out with just spring-boot-starter-jersey but when I add spring-boot-starter-data-jpa to the POM the build fails with missing dependencies: 2015-01-12 15:34:48.731 WARN 9396 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt org.springframework.beans.factory

“spring.data.web.pageable.one-indexed-parameters=true” does not work

元气小坏坏 提交于 2020-01-05 08:45:14
问题 in my Spring Boot Rest Service I want to implement a getAll method with pagination for lazy loading in frontend later. At the moment I have to request with page 0 if I want the first set of rows. With the following config inserted in the application.properties it should work... spring.data.web.pageable.one-indexed-parameters=true ... but it doesn't. Does anybody knows why or is this a legacy way? I'm using spring-boot-starter-web and data-jpa in version 2.0.4.RELEASE. Thanks a lot! edit, here

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 using Neo4j and MongoDB

霸气de小男生 提交于 2020-01-05 08:21:33
问题 I am just about to go crazy,I just spent many hours to try work with spring-data for Neo4J ,working with spring-data for MongoDB was a walk in the park compared to that. My goals: 1) Working with spring-data to manage two data-stores Mongo,Neo4j. (correct me if I am wrong but there is no spring-data cross data store support for these two, which mean I will use different domain entities for each store) 2) Working with Neo4J embedded graph. 3) Will have the ability to monitor the graph with

Spring LdapRepository returns no results while Spring Security works

懵懂的女人 提交于 2020-01-05 07:33:30
问题 My Problem I am using an LdapRepository to get user information from an Ldap server. This Ldap server is also queried by Spring Security to authenticate user. My issue is, that Spring Security is able to find and identify users, while I'm unable to find users through my LdapRepository, using the same LdapContextSource. Querying the LdapRepository in any way does not return results ( null or empty Lists). What I have tried Using the ldapsearch tool directly - Works Using LdapQuery instead of

JPA 2 Criteria - using “in” and subqueries(?)

自作多情 提交于 2020-01-05 07:27:38
问题 I have a trouble with creating JPA 2 query (actually I'm using Spring Data JPA). I have a 2 tables: - Users (id,company_id,name,surname,status) - UsersGroup (id,user_id,group_id). Users can(and often are) connected to more than one group. What I'm trying to do is to get distinct list of users according to filtering options from search form (name,surname,status) and attributes taken from logged user (company_id, group_id), because I want to show this user only users within company and group he

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: