Queria entender o porque o lombok não está funcionando ele importa os metodos normalmente mais não funciona. Acabei de fazer uma inserção ele funcionou, fiz outra em seguida ele ja não funcionou mais.
public void cadastrarUsuario(Usuario usuario) throws SQLException{
EntityManager manager = JPAUtil.getEntityManager();
EntityTransaction transaction = manager.getTransaction();
try {
transaction.begin();
manager.persist(usuario);
transaction.commit();
} catch (Exception e) {
if(transaction.isActive()) {
transaction.rollback();
}
throw new SQLException(e);
} finally {
manager.close();
}
}
public void cadastrarUsuario(Usuario usuario) throws Exception, SQLException {
String senhaHash = EncriptarSenha.encriptarSenha(usuario.getSenha());
usuario.setSenha(senhaHash);
validarUsuario(usuario);
usuarioRepository.cadastrarUsuario(usuario);
}
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>review</groupId>
<artifactId>review</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.hibernate.orm/hibernate-core -->
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.3.1.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.mysql/mysql-connector-j -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.2.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>20</release>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
</plugin>
</plugins>
</build>
</project>
package br.com.review.model.entities;
import java.time.LocalDate; import java.util.List;
import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.OneToMany; import jakarta.persistence.Table; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString;
@Entity @Table(name = "usuarios") @Getter @Setter @NoArgsConstructor @ToString public class Usuario {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "usuario_id")
private Long id;
@Column(name = "nome")
private String nome;
@Column(name = "sobrenome")
private String sobrenome;
@Column(name = "email")
private String email;
@Column(name = "senha")
private String senha;
@Column(name = "data_nascimento")
private LocalDate dataDeNascimento;
@Column(name = "genero")
private String genero;
@Column(name = "ativo")
private Boolean ativo;
@OneToMany(mappedBy = "usuario")
private List<Avaliacoes> listAvaliacoes;
public Usuario(String nome, String sobrenome, String email, String senha, LocalDate dataDeNascimento,
String genero) {
this.nome = nome;
this.sobrenome = sobrenome;
this.email = email;
this.senha = senha;
this.dataDeNascimento = dataDeNascimento;
this.genero = genero;
this.ativo = true;
}
}