kostas trichas
kostas trichas

Reputation: 3013

JPA Entities - MySQL tables Mapping

Database tables:

  1. Tutor( {PK}tutorId, name )
  2. Module( {PK}moduleId, name, {FK}tutorId )

Relationship Tutor -> Module (OneToMany)

Questions:

  1. If you create the domain model classes with JPA annotations, the corresponding database tables are auto-created with the same columns as the annotated fields of the class?

  2. Do you create the database first and then the JPA classes with the same fields as the database table columns?

  3. How do you model foreign key constraints with JPA

Upvotes: 0

Views: 696

Answers (1)

Nathanphan
Nathanphan

Reputation: 957

(1) and (2) are depended on your situation. you can create domain model class first and it will generate table and columns which are the similar to the fields. In addition, you can establish a database first (it is easy to design and have better view of the whole database.), then map the tables to your domain class.

about (3) you can try this link

Upvotes: 1

Related Questions