spring-data

Spring Test with JUnit 4 and Spring Data JPA: NoSuchMethodError org.hibernate.engine.spi.SessionFactoryImplementor.getProperties

你说的曾经没有我的故事 提交于 2020-01-05 04:52:21
问题 With SpringJUnit4ClassRunner , JUnit 4 and Spring Test I wrote unit test for Service which uses Spring Data JPA Repository and embedded HSQL database: @Ignore @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath*:unitTestFullConfig.xml") public class InMemoryDBFullTestBaseClass { } public final class ActorServiceImplTest extends InMemoryDBFullTestBaseClass { @Inject private ActorService service; @Test public final void saveActor () throws Exception { service.save(new

Spring Test with JUnit 4 and Spring Data JPA: NoSuchMethodError org.hibernate.engine.spi.SessionFactoryImplementor.getProperties

狂风中的少年 提交于 2020-01-05 04:51:29
问题 With SpringJUnit4ClassRunner , JUnit 4 and Spring Test I wrote unit test for Service which uses Spring Data JPA Repository and embedded HSQL database: @Ignore @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath*:unitTestFullConfig.xml") public class InMemoryDBFullTestBaseClass { } public final class ActorServiceImplTest extends InMemoryDBFullTestBaseClass { @Inject private ActorService service; @Test public final void saveActor () throws Exception { service.save(new

Spring data JPA does not allow an Entity to be peristed if the primary key is not null

主宰稳场 提交于 2020-01-05 04:39:10
问题 I have a Subscriber Entity which uses a user supplied email address as the primary key rather than an auto-generated value. This means that when the save method of the JpaRepository is called, the primary key value is not null . Spring data JPA documentation section 2.2.1 table 2.2 says the following: By default Spring Data JPA inspects the Id-Property of the given Entity. If the Id-Property is null, then the entity will be assumed as new, otherwise as not new. This behaviour prevents a new

parse localDateTime string correctly into spring boot @pathVariable

扶醉桌前 提交于 2020-01-05 04:22:06
问题 I'm trying to get all data of a user of a user with a timestamp: @GetMapping("/datum/{userID}/{timeStamp}") List<Datum> getDataSingleUserTimeRange(@PathVariable Long userID, @PathVariable LocalDateTime timeStamp) { .... } Now to test this Spring Boot rest api, in postman, I made this call GET and url - http://localhost:8080/datum/2/2019-12-15T19:37:15.330995 . But it gives me error saying : Failed to convert value of type 'java.lang.String' to required type 'java.time.LocalDateTime' How can I

Use @NodeEntity on interface/abstract class

核能气质少年 提交于 2020-01-05 03:35:36
问题 Is it possible to add @NodeEntity (or even @RelationshipEntity ) annotation from SpringData Neo4j on an interface or abstact class or their fields? If not, how do you manage these situations? 回答1: Definitely you can do that on Abstract classes , and I think it's a good practice in some common cases. Let me give you an example that I'm using in my graph model: @NodeEntity public abstract class BasicNodeEntity implements Serializable { @GraphId private Long nodeId; public Long getNodeId() {

Retrieving the specific MongoDB key from DuplicateKeyException that was actually duplicated (Java/Spring)

≡放荡痞女 提交于 2020-01-05 03:18:09
问题 I am working with Spring-Data/MongoDB and am properly catching duplicate keys upon a save/insert. As an example, let's say I have a User being saved to a Collection. The User object is annotated with two @Indexed(unique=true) (two unique keys). Let's say they are 'email' and 'username'. How do I retrieve which index was actually duplicated during the insert process. The closest I get is when I execute this type of example code: public boolean createNewUser() { MongoTemplate operations =

Spring Boot Inject CrudRepository into Service

纵饮孤独 提交于 2020-01-04 07:18:26
问题 I am having difficulty injecting a CrudRepository into a service annotated with the @Service annotation. I have two packages one "core" package containing @Service definitions and reusable controller definitions. My main application in the x.y.application package is as follows: package x.y.application; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;

Spring Data Neo4J - NotInTransactionException while modifying set of nodeEntity

て烟熏妆下的殇ゞ 提交于 2020-01-04 05:52:07
问题 We are using spring-data-neo4j with repository methods and annotated queries. Formerly, we used SDN with a rest connection to a standalone server. Performance was very poor, though, so we decided to use SDN with an embedded neo4j instance. But that does not work as expected. Here are some classes The node entity import java.util.Set; import org.codehaus.jackson.annotate.JsonIgnore; import org.neo4j.graphdb.Direction; import org.springframework.data.neo4j.annotation.Fetch; import org

Import JSON file in Mongo db using Spring Data Embedded Mongo

邮差的信 提交于 2020-01-04 05:49:07
问题 I am trying to write some integration tests relative to some methods that needs to extract data from MongoDB. In detail, I am using the Embedded Mongo given by Spring Data project. The embedded mongo is clearly provided by Flapdoodle. I need to import some json file into the Embedded Mongo. I have looked at the tests provided with flapdoodle , but I am not able to understand how they integrates with the magic given by Spring Data + Spring Boot. Can anyone post some clarifying snippets? 回答1:

Query Nested Objects in Redis using Spring Data

拈花ヽ惹草 提交于 2020-01-04 05:43:08
问题 I have a java object as below that i store in a redis store. @RedisHash("UserProfile") public class UserProfile implements Serializable { @Id String id; @Reference PersonalInfo personalInfo = new PersonalInfo(); @Reference BusinessInfo businessInfo = new BusinessInfo(); ... } Now, the PersonalInfo object is structured as: public class PersonalInfo { private String firstName; private String lastName; @Indexed private String userId; private ContactInfo contactInfo = new ContactInfo(); } Note