Home » Tag Archives: JPA

Tag Archives: JPA

WebSocket Client API in Java EE 7

java-interview-questions-answers

In this post, let’s explore the less talked about Web Socket Client API and how to leverage it within a Java EE 7 container itself. Web Socket Server API rules The server side API of JSR 356 (Web Socket API for Java) is most commonly used for building Web Socket endpoint implementations. More often than not, from a client perspective, ...

Read More »

Using JPA And CDI Beans With Camel on WildFly

jboss-wildfly-logo

I didn’t really plan for it, but with a conference free month, I had the chance to dig around a little more and show you even more of the Camel on WildFly magic, that the WildFly-Camel subsystem provides. The Business Background The demo is derived from one on JBoss Demo-Central by Christina Lin. She demonstrates the use of File and JDBC ...

Read More »

How To Stream/Serialize JPA Result As JAX-RS Response For Large Data

java-interview-questions-answers

There are times that retrieving a large data set through JPA is necessary (e.g. more than 1,000,000 records) and having them stuffed into a single instance of java.util.List is just risky (memory barrier). So, here’s a quick solution of how a JAX-RS REST resource end-point could still give us a timely Response without breaking the memory constrain through streaming or ...

Read More »

Custom Boolean User Type with Hibernate JPA

jboss-hibernate-logo

The ANSI SQL 1999 standard introduced a BOOLEAN data type (although unfortunately only as an optional feature). But to date it still isn’t implemented by most major database systems. As a consequence boolean columns are implemented in various ways. E.g., CHAR columns containing ‘Y’ or ‘N’, or using BIT columns. Subsequently, there is no way for JPA to provide a ...

Read More »

Type Safe Queries for JPA’s Native Query API

java-interview-questions-answers

When you’re using JPA – sometimes – JPQL won’t do the trick and you’ll have to resort to native SQL. From the very beginning, ORMs like Hibernate kept an open “backdoor” for these cases and offered a similar API to Spring’s JdbcTemplate, to Apache DbUtils, or to jOOQ for plain SQL. This is useful as you can continue using your ...

Read More »

How JPA 2.1 has become the new EJB 2.0

java-interview-questions-answers

Beauty lies in the eye of the beholder. So does “ease”: Learn more about SQL Result Set Mappings and handle your native query results with ease: http://t.co/WH4BTlClIP #JPA #Java #JavaEE — Thorben Janssen (@thjanssen123) April 15, 2015 Thorben writes very good and useful articles about JPA, and he’s recently started an excellent series about JPA 2.1’s new features. Among which: ...

Read More »

Enumerating @NamedQuery within @NamedQueries

java-interview-questions-answers

Introduction If you’re a Java developer using JPA, chances are that you’ve declared one or more @NamedQuery objects on your entities. To declare a @NamedQuery on a class, the class must simply be annotated with the name of the query and its JPQL, such as: @Entity @NamedQuery(name = "findAllProjects", query = "select p from Project p order by p.id") public ...

Read More »

JPA Database Schema Generation

java-interview-questions-answers

For some time now, most of the main implementations of JPA, like Hibernate, EclipseLink or OpenJPA, offered ways to generate database schema objects. These include generation of tables, primary keys, foreign keys, indexes and other objects. Unfortunately, these are not standard between the implementations, when dealing with multiple environments. Only in the latest JPA 2.1 specification, the Schema Generation standardization ...

Read More »

A beginner’s guide to JPA and Hibernate Cascade Types

jboss-hibernate-logo

Introduction JPA translates entity state transitions to database DML statements. Because it’s common to operate on entity graphs, JPA allows us to propagate entity state changes from Parents to Child entities. This behavior is configured through the CascadeType mappings. JPA vs Hibernate Cascade Types Hibernate supports all JPA Cascade Types and some additional legacy cascading styles. The following table draws ...

Read More »

JPA 2.1: Unsynchronized persistence context

java-interview-questions-answers

The JPA version 2.1 brings a new way how to handle the synchronization between the persistence context and the current JTA transaction as well as the resource manager. The term resource manager comes from the Java Transaction API and denotes a component that manipulates one resource (for example a concrete database that is manipulated by using its JDBC driver). Per ...

Read More »
Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.