This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kale.hibernatetutorial.service; | |
import com.kale.hibernatetutorial.dao.EmployeeRepository; | |
import com.kale.hibernatetutorial.exception.EmployeeNotFoundException; | |
import com.kale.hibernatetutorial.model.Employee; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.stereotype.Service; | |
import org.springframework.transaction.annotation.Propagation; | |
import org.springframework.transaction.annotation.Transactional; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kale.hibernatetutorial.dao; | |
import com.kale.hibernatetutorial.model.Employee; | |
import jakarta.persistence.EntityManager; | |
import jakarta.persistence.PersistenceContext; | |
import org.springframework.stereotype.Repository; | |
import java.util.List; | |
@Repository |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kale.hibernatetutorial.controller; | |
import com.kale.hibernatetutorial.exception.EmployeeNotFoundException; | |
import com.kale.hibernatetutorial.exception.InternalServerException; | |
import com.kale.hibernatetutorial.model.Employee; | |
import com.kale.hibernatetutorial.service.EmployeeService; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.http.HttpStatus; | |
import org.springframework.http.ResponseEntity; | |
import org.springframework.web.bind.annotation.*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kale.hibernatetutorial.exception; | |
import org.springframework.http.HttpStatus; | |
import org.springframework.web.bind.annotation.ResponseStatus; | |
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) | |
public class InternalServerException extends RuntimeException { | |
public InternalServerException(Throwable cause) { | |
super(cause); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kale.hibernatetutorial.exception; | |
import org.springframework.http.HttpStatus; | |
import org.springframework.web.bind.annotation.ResponseStatus; | |
@ResponseStatus(HttpStatus.NOT_FOUND) | |
public class EmployeeNotFoundException extends RuntimeException{ | |
public EmployeeNotFoundException(String message) { | |
super(message); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kale.hibernatetutorial.model; | |
import jakarta.persistence.*; | |
@Entity | |
@Table(name="employee") | |
public class Employee { | |
@Id | |
@GeneratedValue(strategy = GenerationType.IDENTITY) | |
@Column | |
private Integer id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kale.hibernatetutorial.service; | |
import com.kale.hibernatetutorial.model.Employee; | |
import java.util.List; | |
public class EmployeeServiceImpl implements EmployeeService { | |
@Override | |
public List<Employee> findAll() { | |
return null; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kale.hibernatetutorial.service; | |
import com.kale.hibernatetutorial.model.Employee; | |
import java.util.List; | |
public interface EmployeeService { | |
List<Employee> findAll(); | |
Employee findById(int id); | |
void create(Employee employee); | |
void delete (int id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kale.hibernatetutorial.dao; | |
import com.kale.hibernatetutorial.model.Employee; | |
import java.util.List; | |
public class EmployeeRepositoryImpl implements EmployeeRepository { | |
@Override | |
public List<Employee> findAll() { | |
return null; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kale.hibernatetutorial.dao; | |
import com.kale.hibernatetutorial.model.Employee; | |
import java.util.List; | |
public interface EmployeeRepository { | |
List<Employee> findAll(); | |
Employee findById(int id); | |
void create(Employee employee); | |
void delete (int id); | |
Employee update(Employee employee); |
NewerOlder