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.

0
0
0
s2smodern

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

0
0
0
s2smodern

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;
}

0
0
0
s2smodern

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

0
0
0
s2smodern

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.

0
0
0
s2smodern