这是我的代码。
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;
}
我遇到此错误:
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
请,您对此错误有一个了解吗?我必须像crud存储库一样将主键更改为整数?
非常感谢。