One to One Hibernate/JPA Example

User Rating: 1 / 5

Star ActiveStar InactiveStar InactiveStar InactiveStar Inactive

In this tutorial we will demonstrate how to set up a One-to-One Mapping using annotations and MySQL as database. We will use a Worker table which is mapped one-to-one with an Info table which contains the info about the workers.

Read more: One to One Hibernate/JPA Example

One to Many Hibernate/JPA example

User Rating: 3 / 5

Star ActiveStar ActiveStar ActiveStar InactiveStar Inactive

Here's an example which uses a One-to-Many mapping between the Table Customer (ONE) and Request (MANY).

Read more: One to Many Hibernate/JPA example

How to map MySQL auto increment field

User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive

MySQL does not have the concept of sequence but uses AUTO_INCREMENT fields to emulate sequence behaviour. Supposing that you have just created this table:

mysql> create table customer (id integer auto_increment, name varchar(25));
Query OK, 0 rows affected (0.03 sec)

Then you can map the id field using a Generation type IDENTITY:


@Entity
@Table
public class Customer  {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;

    @NotNull
    private String name;
}

How to map an Oracle Sequence

User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive

This tutorial describes how to map an Oracle Sequence with JPA.

Read more: How to map an Oracle Sequence

Hibernate Data Filters

User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive

Filtering data is one of the most common Task of an application. This is usually achieved by adding WHERE clauses to your queries. In case the filters are defined dynamically by the user it becomes a more complex issue. A very powerful option for creating dynamic conditions to your applications are Criteria API, however it's likely that when conditions change, you will need to apply changes in your Criteria queries as well.

Read more: Hibernate Data Filters

Follow us on Twitter