Home » Tag Archives: JPA

Tag Archives: JPA

Reference by Identity in JPA

java-interview-questions-answers

In a previous post, I mentioned that I opted to reference other aggregates by their primary key, and not by type. I usually use this approach (a.k.a. disconnected domain model) when working with large or complex domain models. In this post, let me try to explain further how it can be done in JPA. Note that the resulting DDL scripts ...

Read More »

OpenMap Tutorial 5 – 3-tier GIS application

java-logo

1. Introduction Welcome to the 5th tutorial of the OpenMap series of Tutorials.  OpenMap is a free open source Java GIS library. Here is a list of previous tutorials: In the first tutorial we created a basic OpenMap GIS application that displays a map with one shape layer, loaded from the filesystem, inside a JFrame. That tutorial was based on ...

Read More »

Using Stored Procedures With JPA, JDBC. Meh, Just Use jOOQ

jooq-logo

The current edition of the Java magazine has an article about Big Data Best Practices for JDBC and JPA by Josh Juneau: http://www.javamagazine.mozaicreader.com/MayJune2016 The article shows how to use a stored procedure with JDBC (notice how resources aren’t closed, unfortunately. This is commonly forgotten, even in Java Magazine articles) // Using JDBC to call upon a database stored // procedure CallableStatement ...

Read More »

Spring boot and Spring data JPA integration

spring-interview-questions-answers

Nowadays spring and JPA integration has become a piece of cake thanks to Spring Boot and spring Data. I am gonna setup a postgresql server docker pull postgres #run the container docker run --name postgreslocal -e POSTGRES_PASSWORD=postgres -d postgres #get the ip docker inspect --format '{{ .NetworkSettings.IPAddress }}' postgreslocal #get the port docker inspect --format '{{ .NetworkSettings.Ports }}' postgreslocal Create ...

Read More »

Using JINQ with JPA and H2

java-interview-questions-answers

A few days ago I have read the interesting interview with Ming-Yee Iu about JINQ. JINQ is, like the name already suggests, the attempt to provide something similar to LINQ for Java. The basic idea is to close the semantic gap between object-oriented code that executes queries on a relational data model. The queries for the relational database model should be ...

Read More »

Pitfalls of the MyBatis Caches with Apache Ignite

mybatis-logo

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 »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Advanced Java Guide
  • Java Design Patterns
  • JMeter Tutorial
  • Java 8 Features Tutorial
  • JUnit Tutorial
  • JSF Programming Cookbook
  • Java Concurrency Essentials