Sample application that demonstrates the use of Hibernate as a JPA provider with Spring Data JPA.
The following concepts are currently demonstrated:
Concept | Description | See |
---|---|---|
Spring Data JPA repositories | Perform CRUD operations agains a relational database using the Repository pattern | LibraryRepository.java |
Direct EntityManager access |
Accessing the JPA EntityManager directly for fine-grained control over database interactions |
QuizPersistenceTest.java |
Collection size | Find size of a mapped collection without having to load all elements in the collection | QuizPersistenceTest.java |
Multiple EntityManager s |
Use multiple EntityManager s in a single application |
springContext.xml |
Manual identifier generation | Generate entity identifiers manually | Invoice.java and InvoiceRepositoryTest.java |
JTA transactions | Support JTA transactions across multiple data stores using Bitronix | springContext.xml |
@OneToOne with foreign keys |
@OneToOne association between two entity classes using a foreign key column |
Employee.java |
JPA count query on abstract class |
Executing a count query on an abstract class |
WorkdayRepositoryTest.java |
Custom JPA functionality | Extending Spring Data JpaRepository to provide custom functionality for all repositories |
ExtendedJpaRepository.java |
AspectJ integration | Intercepting Spring Data repository method calls using AspectJ | RepositoryInterceptionAdvice.java |
SQL Injection protection | Use type-safe, parameterized queries to prevent SQL Injection attacks | StockRepositoryTest.java |
Native SQL queries | Use native SQL queries in cases where either JPQL is inadequate or native SQL is simply easier to write | JobRepository.java |
Spring Data JPA with Scala | Use Spring Data JPA with Scala classes and traits | SubjectRepository.scala |
Single Table inheritance |
Single-table inheritance for storing related objects | Card.java |
Polymorphism with generics | Demonstrate inheritance-based polymorphism along with generics | CardInstance.java |
This sample application and its associated source code in its entirety is being made available under the following licensing terms.
Copyright (C) 2015
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in the
Software without restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.