嗨,我需要添加两个mongo存储库才能使其工作吗?或一个通用的仓库可以创建两个收藏夹?
`公共接口EmployeeRepository扩展了MongoRepository { {
}
manager
{
id:"abc",
name:”PP”,
age:26
}
supervisor
{
id:"abc",
name:"Raj",
age:25
}
public class Employee
{
private String id;
private String name;
private int age;
}
@Document(collection="manager")
public class Manager extends Employee
{
}
@Document(collection="supervisor")
public class Supervisor extends Employee
{
}
public interface EmployeeService<T>
{
public T save(T employee);
}
@Service
public class EmployeeServiceImpl<T> implements EmployeeService<T>
{
@Autowired
EmployeeRepository employeeRepository;
@Override
public T save(T obj) {
return (T) employeeRepository.save(obj);
}
}
`