I can not figure out how to set the initial value for the @GenerateValue @Id. I have tried using GenerationType.SEQUENCE but that is not allowed in MySQL. How can I set the initial value to be used for the @GenerateValue? Using both AUTO and TABLE I can still not get the initial value to start at anything but 1 Thank
Tag: spring
How to find cortege with OneToMany relation in Spring Data JPA
I use Spring Data JPA and have two entities: and And repository: I need to find available vehicles, which not booked by time. How can I do this? Answer I would go for something like: BTW I think that you might wanna try to change FetchType from EAGER to LAZY for bookingTime and then use join fetch in select query.
mock resttemplate to test a service as restFul client
I have a service class, written in spring, with some methods. One of this acts as a restful consumer like below: I want to use Mockito to mock my service, but every method that interacts with restful server instance a new RestTemplate. I’ve to create a static class to Inject it into my service? Answer One of the benefits from
Using @RequestParam for multipartfile is a right way?
I’m developing a spring mvc application and I want to handle multipart request in my controller. In the request I’m passing MultiPartFile also, currently I’m using @RequestParam to get the file parameter, the method look like, Above code works well in my service and the file is getting on the server side. Now somewhere I saw that in cases that
`Type cannot be null` exception when trying to run out Stored Procedure using Spring Data JPA
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 following: I have followed the instructions
Unexpected empty result using spring query method
I am building an application with a REST API using spring boot and JPA connected to a MySQL database. To search for names in the User class I have implemented a query method: List< User > findByFirstnameLike( String name ); This method only returns a result on an exact match, which is not what I wanted. Have I misunderstood something
java.lang.IllegalArgumentException: Result Maps collection already contains value for
Hey I’m using Mybatis with Spring Annotations. and getting this error: here is the domain class (sans getters and setters): here is my Mapper.Java class lastly here is the Mapper.xml I’m inclined to believe there is something wrong with the xml select statement. Probably with how I am using foreach. I have another mapper using a similar format it just
spring-boot – turn off console logging
Want to configure a spring-boot (1.3.5) application to send log-output only to a file — turn off the console. It looks very easy, according to the docs: howto-logging.html — section ยง 72.1.1 Configure logback for file only output But I just cannot get this to work — it still logs both to file and console, whatever I try. Been googling
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 Security – multiple logged users
I have a problem with Spring Security configuration. When I log in on one computer as a user1 and then I will log in as a user2 on another computer, the first computer after refresh sees everything as a user2. In other words, it is impossible to have two sessions with different users at the same time. Configuration: Spring Security