Skip to content

jpa

A type-safe named query design approach for JPA

The starting point In a JEE you normally use the Java-Persistence-API JPA to access the data. JPA provides named queries which are statically defined queries with an unmodifiable query string. Because the query string is unmodifiable a client must still be able to provide parameters that concretize a query. Those query parameters are placed in the query string in a special format, e.g. :username. So if we define a named query in the simplest way it will look like this: @Entity @NamedQueries( { @NamedQuery( name = "findOrdersByUsername", query = "select distinct o from Order o JOIN order.user AS u where u.username = :username") } ) public class Order { ...… Read More »A type-safe named query design approach for JPA
GDPR Cookie Consent with Real Cookie Banner