Open stefan1anuby opened 1 week ago
Model could be:
@Entity public class Payroll { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private Double salary; private String paymentDate; @OneToOne @JoinColumn(name = "employee_id") private Employee employee; // Getters and Setters }
Abstract repo could be:
@Repository public interface PayrollRepository extends JpaRepository<Payroll, Long> { Optional<Payroll> findByEmployeeId(Long employeeId); }
Service could be:
@Service public class PayrollService { @Autowired private PayrollRepository payrollRepository; public Payroll getPayrollByEmployeeId(Long employeeId) { return payrollRepository.findByEmployeeId(employeeId) .orElseThrow(() -> new EntityNotFoundException("Payroll not found")); } public Payroll savePayroll(Payroll payroll) { return payrollRepository.save(payroll); } }
Model could be:
Abstract repo could be:
Service could be: