Home » Tag Archives: JPA (page 6)

Tag Archives: JPA

JPA 2.0 Criteria Query with Hibernate

jboss-hibernate-logo

Criteria Query has been introduced in JPA 2.0. With the help of criteria queries you can write your queries in a type-safe way. Before criteria queries, developers had to write queries through the construction of object-based query definitions. There might be chances of incorrect syntax while building the queries. The criteria query API provides feature to create structured and nested ...

Read More »

JPA and CMT – Why Catching Persistence Exception is Not Enough?

java-interview-questions-answers

Being in EJB and JPA world using CMT (Container Managed Transactions) is very comfortable. Just define few annotations to demarcate transaction boundary (or use the defaults) and that’s it – no fiddling with manual begin, commit or rollback operations. One way to rollback your transaction is to throw non-application exception (or application exception with rollback = true) from your EJB’s ...

Read More »

Types of Entity Managers: Application-managed EntityManager

java-logo

JPA specification defines few types of EntityManagers / Persistence Contexts. We can have: extended and transactional-scoped EntityManagers, container-managed or application-managed EntityManagers. JTA or resource-local EntityManager, Besides the above distinction, we also have two main contexts in which EntityManager / Persistence Context can exist – Java EE and Java SE. Not every option is available for Java EE and not every ...

Read More »

Bidirectional @OneToMany / @ManyToOne association

jboss-hibernate-logo

One of goals in programming is representing of models from real world. Very often an application need to model some relationship between entities. In the last article about Hibernate associations I have described rules of setting up the “one to one” relationship. Today I’m going to show you how to setup bidirectional “one to many” and “many to one” association. ...

Read More »

Bidirectional @OneToOne primary key association

jboss-hibernate-logo

It’s time to continue articles about Hibernate. The last one was dedicated to unidirectional @OneToOne association. So today I will show you how to obtain bidirectional @OneTonOne primary key association. An example from this tutorial based on previous article. Let’s get started. I will work with the same tables which I have created previously. In order to setup a bidirectional ...

Read More »

EasyCriteria 2.0 – JPA Criteria should be easy

java-interview-questions-answers

In the post today we will see about the new version of the framework named EasyCriteria. At the end of this post we will see what is to come here in the blog. Unfortunately the JPA criteria has a huge problem that is its verbosity. Why not make easier? Thinking like this that EasyCriteria framework were born and now it ...

Read More »

Spring Data JPA and pagination

spring-interview-questions-answers

Let us start with the classic JPA way to support pagination. Consider a simple domain class – A ‘Member’ with attributes first name, last name. To support pagination on a list of members, the JPA way is to support a finder which takes in the offset of the first result(firstResult) and the size of the result(maxResults) to retrieve, this way: ...

Read More »

Database Encryption Using JPA Listeners

java-interview-questions-answers

I recently had to add database encryption to a few fields and discovered a lot of bad advice out there. Architectural Issues The biggest problem is architectural. If your persistence manager quietly handles your encryption then, by definition, your architecture demands a tight and unnecessary binding between your persistence and security designs. You can’t touch one without also touching the ...

Read More »

JPA/Hibernate: Version-Based Optimistic Concurrency Control

jboss-hibernate-logo

This article is an introduction to version-based optimistic concurrency control in Hibernate and JPA. The concept is fairly old and much has been written on it, but anyway I have seen it reinvented, misunderstood and misused. I’m writing it just to spread knowledge and hopefully spark interest in the subject of concurrency control and locking. Use Cases Let’s say we ...

Read More »

Grails: Autodiscovery of JPA-annotated domain classes

groovy-logo

There are some issues to be fixed with the support for adding JPA annotations (for example @Entity) to Groovy classes in grails-app/domain in 2.0. This is due to the changes made to adding most GORM methods to the domain class bytecode with AST transformations instead of adding them to the metaclass at runtime with metaprogramming. There is a workaround – ...

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