October 26, 2024
Chicago 12, Melborne City, USA
java

Stackoverflow when evaluate expression intellij with JPA Spring Boot


I asked today a question, i created a user model.

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "_user")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,property = "id")
public class User implements UserDetails {

  @Id
  @GeneratedValue
  private Integer id;
  private String firstname;
  private String lastname;
  @NotNull
  @Column(unique=true)
  private String email;
  @NotNull
  @Column(unique=true)
  private String usrname;

  @NotNull
  @ColumnDefault("'img/avatar1.jpg'")
  private String avatar;

  @JsonIgnore
  private String password;

  @Enumerated(EnumType.STRING)
  private Role role;

  @JsonIgnore
  @OneToMany(mappedBy = "user")
  private List<Token> tokens;

In my service, i’d like to get the result when i evaluate method :

User updateUser = userRepository.getById(userId)
                .orElseThrow(() -> new ResourceNotFoundException("L'utilisateur n'existe pas avec l'id: " + userId));

Here is my getById(userId)

@Query(value = "SELECT * FROM _user u where u.id = :id", nativeQuery = true)
  Optional<User> getById(int id);

When i evaluate method to get result, i got this :

enter image description here

But there is no problems, because my code continue executing ..

I want to enter in debug mode and evaluate result because i got a ERROR [https-jsse-nio-443-exec-3] c.d.x.ExceptionHandler: Could not commit JPA transaction error.

I hope soemone had this bug and solved it !

Thanks a lot

Best regards



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video