Java Reference
In-Depth Information
public void persist(final T entity) {
public List<T> findAll() {
final CriteriaQuery<T> criteriaQuery =
public void deleteAll() {
final CriteriaDelete<T> criteriaDelete =
As you can see, both SeatDao and SeatTypeDao beans extend the generic Ab-
stractDao class. It wraps EntityManager and provides basic type-safe CRUD op-
erations such as findAll , persist , and so on using the JPA Criteria API. JPA allows
execution of the following three types of queries:
Native SQL : These queries use the standard SQL language. When using this type
of queries, you have to remember queries can be incompatible when migrating
between different databases.
Java Persistence Query Language ( JPQL ): These queries can be formed using
special language similar to SQL. In practice, this method is often hard to maintain
without good IDE support, especially during refactoring. These queries can also
be compiled at startup, which means that they are not resolved multiple times.
Finally, they can be used by a caching mechanism to avoid unnecessary database
operations for queries that are called frequently. You can define a query and its
name in the entity in the @NamedQuery(name="…", query="…") annota-
Search WWH ::

Custom Search