Home » Tag Archives: JPA (page 2)

Tag Archives: JPA

JPA Entity Graphs

java-interview-questions-answers

One of the latest features in JPA 2.1 is the ability to specify fetch plans using Entity Graphs. This is useful since it allows you to customise the data that is retrieved with a query or find operation. When working with mid to large size applications is common to display data from the same entity in different and many ways. ...

Read More »

JPA Tutorial: Mapping Entities – Part 3

java-interview-questions-answers

In my last article I showed two different ways to read/write persistent entity state – field and property. When field access mode is used, JPA directly reads the state values from the fields of an entity using reflection. It directly translates the field names into database column names if we do not specify the column names explicitly.  In case of property access mode, ...

Read More »

JPA Tutorial: Mapping Entities – Part 2

java-interview-questions-answers

In my last post I showed a simple way of persisting an entity. I explained the default approach that JPA uses to determine the default table for an entity. Let’s assume that we want to override this default name. We may like to do so because the data model has been designed and fixed before and the table names do ...

Read More »

Preventing lost updates in long conversations

software-development-2-logo

Introduction All database statements are executed within the context of a physical transaction, even when we don’t explicitly declare transaction boundaries (BEGIN/COMMIT/ROLLBACK). Data integrity is enforced by the ACID properties of database transactions. Logical vs Physical transactions An logical transaction is an application-level unit of work that may span over multiple physical (database) transactions. Holding the database connection open throughout ...

Read More »

JPA tutorial: Mapping Entities – Part 1

java-interview-questions-answers

In this article I will discuss about the entity mapping procedure in JPA. As for my examples I will use the same schema that I used in one of my previous articles. In my two previous articles I explained how to set up JPA in a Java SE environment. I do not intend to write the setup procedure for a ...

Read More »

JPA Hibernate Alternatives. What can I use if JPA or Hibernate is not good enough for my project?

java-interview-questions-answers

Hello, how are you? Today we will talk about situations that the use of the JPA/Hibernate is not recommended. Which alternatives do we have outside the JPA world? What we will talk about:             JPA/Hibernate problems Solutions to some of the JPA/Hibernate problems Criteria for choosing the frameworks described here Spring JDBC Template MyBatis Sormula ...

Read More »

JPA Tutorial – Setting Up JPA in a Java SE Environment

java-interview-questions-answers

JPA stands for Java Persistence API, which basically is a specification that describes a way to persist data into a persistent storage, usually a database. We can think of it as something similar to ORM tools like Hibernate, except that it is an official part of the Java EE specification (and it’s also supported on Java SE). There are many reasons to learn an ...

Read More »

Compile-time checking JPA queries

java-interview-questions-answers

JPA provides several alternatives for querying data. Such alternatives may be classified attending to a variety of criteria, eg, language used (SQL vs JPQL) or whether queries are static (compilation time) or dynamic (execution time). Static queries are defined using annotations @NamedQuery (javax.persistence.NamedQuery) and @NamedQueries (javax.persistence.NamedQueries) in the @Entity class definition itself:         @NamedQuery( name="findAllCustomersWithName", query="SELECT c ...

Read More »

A beginner’s guide to JPA/Hibernate flush strategies

jboss-hibernate-logo

Introduction In my previous post I introduced the entity state transitions Object-relational mapping paradigm. All managed entity state transitions are translated to associated database statements when the current Persistence Context gets flushed. Hibernate’s flush behavior is not always as obvious as one might think.       Write-behind Hibernate tries to defer the Persistence Context flushing up until the last ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close