0

Here is my code.

public interface EmployeRepository extends CrudRepository<Employe, Integer>         
{}


@Entity
public class Employe implements Serializable {

private static final long serialVersionUID = -1396669830860400871L;

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;

private String prenom;

private String nom;

//@Column(unique=true)
private String email;

private boolean isActif;

@Enumerated(EnumType.STRING)
//@NotNull
private Role role;


@ManyToMany(mappedBy="employes" )
//@NotNull
private List<Departement> departements;

}

I have this error :

Exception in thread "main" org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: tn.esprit.spring.entities.Departement.employes, could not initialize proxy - no Session

Please, have you an idea about this error ? I have to change the primary key to integer like crud repository ?

Many thanks.

Fabrizio
  • 7,190
  • 6
  • 37
  • 86
user1543915
  • 985
  • 1
  • 9
  • 16

0 Answers0