I am trying to make this Aggregation bellow using Spring Java, but it’s returning an Empty List on my console. This is working on MongoDB, but not on my spring application. This is my MongoDB Query: It’s return me 2 results: My Problem is when I do this using Mongo with Spring Java: My Repository A part of My Service
Tag: spring
Saving entity with Spring JPA Repository resets enum ttype value
I have an TimelineEntity entity, that uses HoTimelineType enum with custom integer value. That custom integer value is stored in the database. Implemented via Using @PostLoad and @PrePersist Annotations Sprint JPA Repository is used to save and get entities. Here is the issue: When the newTE entity is saved, prePersist is invoked, and inside this method, the hoTimelineType is null
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
Spring Data Jpa: persisting child entities from parent entity does not update child identity
Environment: OS: Ubuntu 20.04 LTS Java: OpenJDK 17.0.3 Spring Boot: 2.6.7 MySQL: 8.0.29 Is it normal for Spring Data Jpa (or Jpa in general) to NOT update child identity attributes when the child is persisted (saved) via the parent entity repository? Consider this: When I call someClassFunction() I get: The database assigned id is NOT available to me immediately. I
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),
Jedis does not support returning PendingMessagesSummary
When I start the spring app write with Java 11, show error like this: I have already upgrade the Jedis version to the newest 4.2.3, why still did not support the Redis pending command? I have already read the Jedis issue. They already added the pending support in the Jedis 3.6.0, why still tell me that did not support? This
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 :
Spring SQL: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement “; expected “identifier”, when using INSERT INTO
I am working on a Spring Web Application. I am using mysql database, but for my unit tests, I want to run them in H2 database. Test specific application properties: As you can see, my database is in MODE=MYSQL, since my data.sql is in MySQL dialect. But during initialization of of data.sql I get this error: I suppose from this
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
Overriding transaction propagation levels for methods having Spring’s @transactional
I have multiple methods in my codebase annotated with Spring’s @transactional with different propgation levels (lets ignore the idea behind choosing the propagation levels). Example – Now I have a new use case where I want to perform all these operations in a single transaction (for this specific use case only, without modifying existing behavior), overriding any annotated propagation levels.