I have a configuration property that needs to be sent to another system as part of a post body. lets say for example if have an application.properties file with my.property.raw=${parameter:some-…
Tag: spring
MyBatis oracle insert new row always return wrong primary id value
Try to get the primary id after inserting a new row to oracle DB Here is the java call New data/row can be inserted into DB with no issue with correct primary key/id. But myID is always returned as 1(supposed to be 8971). How can I get the correct value. Thanks in advcance. version: Answer Your insert returns…
Java – JPA-Specification: how to create criteria/specification on a field that belongs to a nested object?
I am using jdk 1.8 , hibernate and jpa in my project. And using specification/criteria to build my search query. I have a class A ( an hibernate entity) which has class B as an attribute. So, roughly, it looks like : and… My repository class looks like (roughly): } Most of the simple JPA queries are wor…
How to annotate Map with JPA?
The app’s stack: Spring MVC, Spring DataJPA, Hibernate. There are three entities: student, tutor, theme. Theme: Student: Tutor: For save student-tutor-theme relationships i want use this table (PostgreSQL): How i can to annotate tutors and students fields in entities, for their content correct persists …
Retrieving limited columns using jpa specifications
I am using spring boot JPA specifications for executing complex queries. However, the table I am querying contains more than 20 columns and I need to pull just 3. I tried cq.multiselect(…) but it didn’t work and returned me the entity with all the columns. On investigation, I got to know that it&#…
How to avoid using milliseconds when using OffsetDateTime.now()
I am using OffsetDateTime.now() to get the current date in UTC format and result includes milliseconds too. I don’t want milliseconds to be sent . Is there a way i can remove Milliseconds from OffsetDateTime.now() without using split. Answer tl;dr Details The date-time classes such as OffsetDateTime are…
how to resolve error executing ddl commands in spring boot
Hi I am new to spring Boot and i created new project(Demo) using spring initilizr Project structure is Project : Maven Project Language : Java Spring Boot : 2.4.2 application.propertites file is like I have Created some classes and controllers : Entity Repository : Service : Controller : But when i run the pr…
Spring Webflux: how to compare results from two Mono streams and save based on filter
The situation is as follows: I have two MongoDB documents: User and Reproduction. Based on a check if the User has a Reproduction entry (document), I want to add another entity in MongoDB. Currently I am using Spring Webflux and Spring Reactive Mongo. Please see code below. My question is as follows: how can …
Spring Security 5 – My custom UserDetailsService is not called
I have found several questions about similar problems but none of them is exactly my case. I am using the following class to configure the authentication/authorization in my application (a REST API). No matter what I try, my custom ApplicationUserDetailsService is never used. Can anyone see what is wrong with…
Spring Boot application.properties custom variable in a non-controller class
How come application.properties will work in a RestController, but not in a service class? Works Perfect! Returns “Null” Answer The inviteservice class is not configured for Spring IoC (Inversion of Control) as a bean, so Spring will not handle the inviteservice class lifecycle. In this case, @Aut…