{"id":17350334,"url":"https://github.com/codecshekhar/spring-boot-hibernate-jpl-example","last_synced_at":"2026-05-18T02:04:09.420Z","repository":{"id":257826364,"uuid":"860758739","full_name":"CodeCshekhar/spring-boot-hibernate-jpl-example","owner":"CodeCshekhar","description":"This repository contains spring-boot-hibernate-jpl-example concepts to illustrate its advantages ","archived":false,"fork":false,"pushed_at":"2024-09-21T05:42:38.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T12:19:02.024Z","etag":null,"topics":["annotations","hibernate-jpl","lombok","spring-boot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CodeCshekhar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-21T05:13:49.000Z","updated_at":"2024-12-04T07:09:17.000Z","dependencies_parsed_at":"2024-10-14T20:50:45.625Z","dependency_job_id":null,"html_url":"https://github.com/CodeCshekhar/spring-boot-hibernate-jpl-example","commit_stats":null,"previous_names":["codecshekhar/spring-boot-hibernate-jpl-example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeCshekhar%2Fspring-boot-hibernate-jpl-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeCshekhar%2Fspring-boot-hibernate-jpl-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeCshekhar%2Fspring-boot-hibernate-jpl-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeCshekhar%2Fspring-boot-hibernate-jpl-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodeCshekhar","download_url":"https://codeload.github.com/CodeCshekhar/spring-boot-hibernate-jpl-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245841760,"owners_count":20681196,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["annotations","hibernate-jpl","lombok","spring-boot"],"created_at":"2024-10-15T17:06:34.425Z","updated_at":"2025-10-04T00:39:14.954Z","avatar_url":"https://github.com/CodeCshekhar.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring Boot with Jakarta Persistence Layer and H2 Database\n\nThis project demonstrates the integration of Spring Boot with Jakarta Persistence Layer (formerly JPA) using H2 as an in-memory database, featuring separate repository interfaces.\n\n## Table of Contents\n- [Technologies Used](#technologies-used)\n- [Project Setup](#project-setup)\n- [Configuration](#configuration)\n- [Project Structure](#project-structure)\n- [Running the Application](#running-the-application)\n- [Key Components](#key-components)\n- [H2 Database Configuration](#h2-database-configuration)\n- [Best Practices](#best-practices)\n\n## Technologies Used\n- Spring Boot\n- Jakarta Persistence\n- Spring Data JPA\n- Maven (for dependency management)\n- H2 Database (in-memory database)\n\n## Project Setup\n1. Ensure you have Java JDK 17 or later installed (required for Jakarta EE 9+).\n2. Install Maven if not already installed.\n3. Clone this repository: `git clone https://github.com/Chandrashkhareagh/spring-boot-jpl-example.git`\n4. Navigate to the project directory: `cd spring-boot-jpl-example`\n5. Build the project: `mvn clean install`\n\n## Configuration\n(Configuration section remains the same as in the previous version)\n\n## Project Structure\n```\nsrc\n├── main\n│   ├── java\n  │   └── com\n  │       └── yourcompany\n  │           └── project\n  │               ├── controller\n  │               ├── model\n  │               ├── repository\n  │               │   ├── UserRepository.java\n  │               │   └── UserRepositoryImpl.java\n  │               ├── service\n  │               └── Application.java\n  └── resources\n      └── application.properties\n\n```\n\n## Running the Application\n(Running the Application section remains the same as in the previous version)\n\n## Key Components\n\n### 1. Entity\n(Entity section remains the same as in the previous version)\n\n### 2. Repository\nCreate separate repository interfaces in the `repository` package:\n\n```java\n// UserRepository.java\nimport org.springframework.data.jpa.repository.JpaRepository;\nimport org.springframework.stereotype.Repository;\n\n@Repository\npublic interface UserRepository extends JpaRepository\u003cUser, Long\u003e {\n    // Standard JPA methods are inherited\n    User findByEmail(String email);\n    List\u003cUser\u003e findByLastName(String lastName);\n}\n\n// UserRepositoryImpl.java\nimport org.springframework.stereotype.Repository;\n\n@Repository\npublic interface UserRepositoryCustom {\n    List\u003cUser\u003e findByNameContaining(String name);\n    List\u003cUser\u003e findActiveUsers();\n    void updateUserStatus(Long userId, boolean isActive);\n}\n```\n\nIn this structure:\n- `UserRepository` extends `JpaRepository` to inherit standard CRUD operations and defines some common query methods.\n- `UserRepositoryImpl` defines additional custom methods that may require more complex logic.\n\n### 3. Service\nThe service can use both repositories:\n\n```java\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.stereotype.Service;\n\n@Service\npublic class UserService {\n    @Autowired\n    private UserRepository userRepository;\n    \n    @Autowired\n    private UserRepositoryCustom userRepositoryCustom;\n    \n    public User saveUser(User user) {\n        return userRepository.save(user);\n    }\n    \n    public List\u003cUser\u003e findUsersByNameContaining(String name) {\n        return userRepositoryCustom.findByNameContaining(name);\n    }\n    \n    public List\u003cUser\u003e findActiveUsers() {\n        return userRepositoryCustom.findActiveUsers();\n    }\n    \n    // Other service methods\n}\n```\n\n### 4. Controller\n(Controller section remains the same as in the previous version)\n\n## H2 Database Configuration\n(H2 Database Configuration section remains the same as in the previous version)\n\n## Best Practices\n1. Use DTOs (Data Transfer Objects) to separate your API models from database entities.\n2. Implement proper exception handling and validation.\n3. Use Spring Profiles for different environments (dev, test, prod).\n4. Write unit tests for your services and repositories.\n5. Use `@Transactional` for operations that require atomic execution.\n6. Implement proper logging using SLF4J and Logback.\n7. For production, consider using a persistent database instead of H2.\n8. Use Jakarta Persistence annotations (`jakarta.persistence.*`) instead of the older `javax.persistence.*`.\n9. Separate repository interfaces based on functionality for better organization and modularity.\n10. Use `@Repository` annotation on repository interfaces to indicate they are Spring components.\n11. Consider using Spring Data JPA's query methods naming conventions for simple queries in the main repository.\n12. Use the custom repository interface for more complex operations that may require manual implementation.\n\nFor more detailed information, refer to the official documentation:\n- [Spring Boot Documentation](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/)\n- [Spring Data JPA Documentation](https://docs.spring.io/spring-data/jpa/docs/current/reference/html/)\n- [Jakarta Persistence Specification](https://jakarta.ee/specifications/persistence/)\n- [H2 Database Engine](https://www.h2database.com/html/main.html)\n## License\n\nThis project is licensed under the MIT License - see the `LICENSE.md` file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodecshekhar%2Fspring-boot-hibernate-jpl-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodecshekhar%2Fspring-boot-hibernate-jpl-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodecshekhar%2Fspring-boot-hibernate-jpl-example/lists"}