Home » Tag Archives: JPA (page 2)

Tag Archives: JPA

Pitfalls of the MyBatis Caches with Apache Ignite

A week ago, MyBatis and Apache ignite announced of support apache ignite as a MyBatis cache (L2 cache). technically MyBatis support two levels of Caches: Local cache, which is always enable by default L2 cache, optional As Apache Ignite project is fast growing with it’s various functionality, in this blog post we are going to examine the MyBatis support in ...

Read More »

JPQL Enhancements in JPA 2.1 and Java EE 7 (part 1 – JOIN ON)

java-interview-questions-answers

Java EE 7 is around for a few years already, and provides several very useful and long-awaited features, like entity graphs and better support for stored procedures and results mapping. For an overview, have a look at Thorben Janssen’s blog post. However, I’d like add a more detailed summary about features in the JPA query language. All of them are ...

Read More »

Differences in JPA entity locking modes

java-interview-questions-answers

JPA provides essentially 2 types of locking mechanisms to help synchronize access to entities. Both mechanisms prevent a scenario, where 2 transactions overwrite data of each other without knowing it. By entity locking, we typically want to prevent following scenario with 2 parallel transactions: Adam’s transaction reads data X Barbara’s transaction reads data X Adam’s transaction modifies data X, and ...

Read More »

JPA Pitfalls / Mistakes

java-interview-questions-answers

From my experience, both in helping teams and conducting training, here are some pitfalls/mistakes I have encountered that caused some problems in Java-based systems that use JPA. Requiring a public no-arg constructor Always using bi-directional associations/relationships Using @OneToMany for collections that can become huge Requiring a Public No-arg Constructor Yes, a JPA @Entity requires a zero-arguments (or default no-args) constructor. ...

Read More »

A Working DeltaSpike Tutorial

java-interview-questions-answers

On a recent project, I was faced with an interesting problem: take a service method that was given a single object and reuse the same code in the context of a nightly process that would run independently of the application over thousands of the same type of object. It would have been ridiculous to try to maintain an identical process ...

Read More »

Pre Java EE 7 alternative to JPA 2.1 unsynchronized persistence context

java-interview-questions-answers

Unsynchronized persistence context in Java EE 7 JPA 2.1 introduced the concept of unsynchronized persistence context which allows fine grained control over flushing of the JPA Entity Manager i.e. by explicitly calling EntityManager#joinTransaction. Previously, this was defaulted to end of JTA transaction e.g. in a typical Stateless EJB, the entity manager would flush its state to the DB at the ...

Read More »

JPA in case of asynchronous processing

java-interview-questions-answers

Few years ago in Java world it was almost obvious that every “enterprise” class project needed JPA to communicate with database. JPA is a perfect example of “leaky abstraction” described by Joel Spolsky. Great and easy at the beginning but hard to tune and limiting at the end. Hacking and working directly with caches, flushes and native queries is a daily ...

Read More »

Integrating JPA Hibernate with OptaPlanner

We’ve been improving the integration of OptaPlanner with the rest of JEE, so it’s easier to build end user applications that just work. Let’s take a look at the improved JPA Hibernate integration. The basics Both JPA Hibernate and OptaPlanner work on POJO’s (Plain Old Java Objects), so just add some JPA annotations on your domain objects to persist them ...

Read More »

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 »