Skip to content

Instantly share code, notes, and snippets.

View azizkale's full-sized avatar
🇮🇹
</>

Aziz Kale azizkale

🇮🇹
</>
View GitHub Profile
@azizkale
azizkale / EmployeeServiceImpl.java
Created August 21, 2023 15:23
the article - How to implement Hibernate in Spring Boot
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;
@azizkale
azizkale / EmployeeRepositoryImpl.java
Created August 21, 2023 11:44
the article - How to implement Hibernate in Spring Boot
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
@azizkale
azizkale / EmployeeController.java
Created August 20, 2023 14:56
the article - How to implement Hibernate in Spring Boot
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.*;
@azizkale
azizkale / InternalServerException.java
Created August 20, 2023 14:54
the article - How to implement Hibernate in Spring Boot
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);
}
@azizkale
azizkale / EmployeeNotFoundException.java
Created August 20, 2023 14:53
the article - How to implement Hibernate in Spring Boot
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);
}
}
@azizkale
azizkale / Employee.java
Last active August 20, 2023 14:40
the article - How to implement Hibernate in Spring Boot
package com.kale.hibernatetutorial.model;
import jakarta.persistence.*;
@Entity
@Table(name="employee")
public class Employee {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column
private Integer id;
@azizkale
azizkale / EmployeeServiceImpl.java
Created August 20, 2023 13:22
the article - How to implement Hibernate in Spring Boot
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;
}
@azizkale
azizkale / EmployeeService.java
Created August 20, 2023 13:21
the article - How to implement Hibernate in Spring Boot
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);
@azizkale
azizkale / EmployeeRepositoryImpl.java
Last active August 20, 2023 13:17
the article - How to implement Hibernate in Spring Boot
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;
}
@azizkale
azizkale / EmployeeRepository.java
Last active August 20, 2023 13:14
the article - How to implement Hibernate in Spring Boot
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);