Tutorial describes One to One Mappings in JPA with examples.
What are One to One Mappings: One to One mappings between entities refers to those relationships where one record of an entity(say entity-1) is mapped exactly to one record of another entity(say entity-2). Then entity-1 and entity-2 are said to be in a One to One relationship with each other. Or, it can be said that a One to One mapping exists between the two entities.
Example Database Table Structure with a One to One Mapping: … Continue reading One To One Mapping in JPA with Examples
Null constraints in JPA reflect the nullability of a column as defined in the database schema. As such in all database definitions a column is nullable by default. I.e. if a column is not defined as primary key or unique then it is by default nullable. It is to make a column mandatory, i.e. to stop it from accepting null values, that we make it non-nullable. The same logic is reflected in JPA as well.
Null constraint can be defined on either an @Column or an @JoinColumn.
Lets say we have an Employee table … Continue reading JPA Not Null Constraint/ Not Nullable column
How to resolve javax.persistence.NoResultException OR javax.persistence.NonUniqueResultException in JPA
In case you are getting the following exception in JPA –
javax.persistence.NoResultException: No entity found for query OR javax.persistence.NonUniqueResultException: result returns more than one elements
Then it is most likely that your database does not have even a single record matching your query OR you have too many results being returned.
Normally this happens when the method … Continue reading How to resolve javax.persistence.NoResultException OR javax.persistence.NonUniqueResultException in JPA
The tutorial below details how to do reverse engineering of Hibernate/JPA POJO entities from database tables.
The database tables\entities which are used for this tutorial are Course, Department and Student. The way these 3 tables are related are Courses have a many-to-many relationship with Students and Students have a many-to-many relationship with Departments. This means … Continue reading Reverse Engineering of JPA Entities with JBoss Tools Eclipse Plugin.
The tutorial below details how to setup a JPA Project in Eclipse. As part of the JPA Project creation a Data Connection to a local MySQL database instance will also be configured.
Note – This tutorial has been created using Eclipse Juno.
Step 1: Click in … Continue reading How to setup a JPA Project with a Data Connection for MySQL in Eclipse.
The tutorial below details the steps to install JBoss Tools Eclipse Plugin.
Note-Hibernate Tools Plugin, which is now a part of JBoss Tools, gets installed along with JBoss Tools with no extra setup required.
Note 2– This tutorial is created using Eclipse Juno.
Step 1 – Click on … Continue reading How to Install JBoss Tools Eclipse Plugin