How to Implement a Custom Repository in Spring Data
Create a fragment interface and an Impl class, then extend it from your repository to add custom queries to Spring Data JPA while keeping derived methods.
2,886 posts about Java: questions with answers, tutorials and articles, newest first.
Create a fragment interface and an Impl class, then extend it from your repository to add custom queries to Spring Data JPA while keeping derived methods.
@DiscriminatorValue gives each JPA entity subclass a marker value in the discriminator column, so Hibernate can load the right type from shared tables.
Use onException, a dead letter channel and doTry/doCatch to retry, reroute or recover failed messages in Apache Camel routes on Spring Boot.
Use @DiscriminatorValue and @DiscriminatorColumn to tell JPA which subclass each row represents in single-table and joined inheritance.
ChoiceDefinition is the model class behind Camel's choice() DSL. Learn how when() and otherwise() route messages, and how to avoid the missing end() bug.
@DiscriminatorColumn names the column JPA uses to tell subclasses apart in an inheritance hierarchy. Attributes, types and a SINGLE_TABLE example.
Learn how @DiscriminatorColumn and @DiscriminatorValue tell JPA which subclass a row belongs to, including types, defaults and Hibernate's formula option.
Camel's Choice EIP routes each message by its content. Learn choice, when and otherwise with Simple, JSONPath, XPath, YAML and XML examples.
Learn the purpose of the Apache Camel Processor interface: process an Exchange in a route, use lambdas and beans, handle errors and test it.
TABLE_PER_CLASS gives every concrete entity its own table with all inherited columns. Learn its mapping, id restrictions and query trade-offs against other strategies.
Annotate the root entity with @Inheritance(strategy = JOINED) to give each class its own table, and see the trade-offs against other strategies.
from() defines where a Camel route starts and to() sends the message onward. See examples with files, choice routing, toD and error handling in Camel 4.
SINGLE_TABLE stores a whole entity hierarchy in one table, split by a discriminator column. See a Jakarta Persistence example, trade-offs and alternatives.
Compare the three JPA inheritance strategies and @MappedSuperclass with entity examples, resulting tables and guidance on when to use each.
Apache Camel maps Enterprise Integration Patterns to Java DSL steps in a RouteBuilder. See working routing, transformation, aggregation and error handling examples.
RouteBuilder is the base class for defining Apache Camel routes in Java. You override configure() to say where messages come from, how they change and where they go.
@Inheritance chooses how JPA stores an entity class hierarchy. Compare the three strategies, their schemas and when to use each.
Compare the JPA inheritance strategies SINGLE_TABLE, JOINED and TABLE_PER_CLASS, plus @MappedSuperclass, with working jakarta.persistence examples.
@Version turns on optimistic locking in JPA. Learn how the version check works in SQL, how to handle the exception in Spring, and when to use pessimistic locks instead.
Use @Version for optimistic locking in JPA: how the version column works, how to handle conflicts in Spring Boot and when to choose pessimistic locks.