Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 9 months ago. Improve this question I’m implementing Transactional Outbox pattern using Java. The Message Relay Service will poll the Outbox table for entries, and after an
Tag: spring-boot
How to change id column type already registered in the database
I’m trying to change my Id column type from int to bigInt because the records are too big and I’m getting an error if I try to store more records but I’m not sure if it’s safe to just alter the table like this: I’m using Java Springboot to create the entities and Hibernate for persistence. What’s the best way
mapper does not convert between dto to entity
I am new to mapsturct I just want to map between dto to entity those two; my bank class; my bank dto class; my mapper below; Answer Target and source properties don’t work well with collections mapping. You need additional mapping for single element. Update your mapper as below, so Mapstruct can use element mapper when mapping the collection: If
My custom validation annotation is not working in Spring Boot
i have created an annotation that has features such as checking if the entered string is null or at the assigned value.But the annotation doesn’t work. I don’t think it does any validation on the DTO.What am I doing wrong ? I also added the valid annotation on the controller. I don’t think the isValid() function works. Answer Record classes
Adding multipart file as an attachment to an email in Spring Boot
I want to send an email from Spring Boot with a pdf attachment. I have received the pdf file as a multipart file from a POST call. Here’s my controller class so far (sendEmails method is included in emailService service): And here’s sendEmails method: Now, in the sendEmailAndUpdate method I have the reciever’s email address, the pdf (as a MultipartFile),
Springboot 2.5.6 gives java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: OffsetSeconds issues
Since migration to springboot 2.5.6 I have to register our ObjectMapper with JavaTimeModule. However, I am getting the below error for the format “yyyy-MM-dd’T’HH:mm:ss.SSSZ”. How can I fix it? The input time that we get is something like 2020-07-01T10:00:00.000+0000 Error Our Serialization Answer LocalDateTime does not support timezones by definition. Therefore it doesn’t support OffsetSeconds. You should leave off the
Deleting an entity with one to one relation
My two entities have one to one relation I tried to delete my user entity by this method PasswordResetTokenRepository class which method I called in my service method, for deleting user I used regular hibernate method deleteById(Long id) But when I try to delete by this method I got this error: not-null property references a null or transient value :
Using Optionals correctly in service layer of spring boot application
I new to spring boot application development. I using service layer in my application, but came across the repository method that return Optional as shown below. My question is , whether I am using the Optional correctly here. And is it ok to check this optional (isPresent()) in the RestController and throughing exception is not present.Like below Answer I wouldn’t
Return link from Hateos
I have this old Spring Hateos code which I want to migrate to the latest version: I tried this: I get error at this line: Can you advise what is the correct way to implement this? Answer Based on your comments & question for migration this is what I am suggesting: …. //calling addLinlk And inside addLink: Tested with Java
Many to many relationship doesn’t add new Entity into the table
I have two entities Book and BookTag. They are connect by many to many relationship. I try to add to the set of bookTags new BookTag entity using such service method But it doesn’t work, after I saved an entity into the mysql database it work correctly view of books_tags table after inserting a new tag to the book After