I am trying to invoke a Stored Procedure whose signature looks like the following: I am using Spring-Data JPA and have tried a number of different variants, but all of them follow more or less the following pattern. My entity model is decorated as follows: Then I have my repository which looks like the follow…
Tag: spring-data
Calling stored procedure using OUT parameter with Spring Spring JPA 2.*
I am calling a stored procedure using IN parameter – it’s working fine. Need help how to do it for OUT parameters. Answer Refer below link for how to call a stored procedure. https://dzone.com/articles/calling-stored-procedures-from-spring-data-jpa
Spring Data MongoDB Annotation @CreatedDate isn’t working, when ID is assigned manually
I’m trying to use auditing to save dateCreated and dateUpdated in my objects, but since I set ID manually, there’s some additional work. Following Oliver Gierke’s suggestion in DATAMONGO-946 I’m trying to figure out how to correctly implement it. As original poster in Jira task above, …
How to handle transactions with concurrent access in Spring
I have a service with one method: And I’m running Gatling with 2 parallel calls config with testModelId = 1L argument. As a result of these calls I’m getting error: What I can see from logs is that two calls have entered this method at once and each printed log I assumed that adding transaction an…
Spring Data Rest – Soft Delete
I’ve been using spring data rest without any problem but now I have a requirement that when a user performs a DELETE operation on a given entity i.e. DELETE /accounts/<id> I need to set a flag on the database marking that entity as deleted but i do want to keep the record. Basically this means tha…
How to inject multiple JPA EntityManager (persistence units) when using Spring
I need to use one database for queries (non-modifying) and one for commands (modifying). I am using Spring Data JPA, so I have two configuration classes: In my repository I sometimes need to decide with EntityManager to use like so: I am using persistence unit’s name as defined in my persistence.xml: Sp…
How to disable the default exposure of Spring Data REST repositories?
I have a project that uses spring-data-rest, and has a dependency project that only uses Spring Data. Both projects have spring data repositories and use @EnableJpaRepositories to implement their repository interfaces, but I only want to export the repositories in the parent project. Here’s my question:…
What is the difference between Transaction manager and Entity Manager
As a student, i read nearly all spring documentation. As far as i understood that spring is configuration monster. Annotation based or Xml based, it doesn’t matter but what i really don’t understand is what is the difference between transaction manager and entity manager. If we have injected entit…
Spring data mongodb. Generating id’s error
I have made an experiment… one common entity for two Spring data’s repositories: – JPA – MongoDB first of all I’ using following libraries versions: spring-data-jpa : 1.7.0.RELEASE spring-data-mongodb : 1.6.0.RELEASE I have an Entity: JPA Repository has following look: MongoDB re…
How to log Spring Data JPA repository method execution time?
I have simple Spring Data JPA repository. Is there any way to monitor execution time for methods generated by Spring (for example findOne(…))? Answer The easiest way is to use a CustomizableTraceInterceptor as follows: