Java Reference
In-Depth Information
Cooking entities
Now that we're done with the configuration part, we will add our entities to the project.
Some valuable options exist to autogenerate our entities, starting with the database schema.
For example, the Eclipse's File menu includes an option JPA Entities from Table that
(once a connection has been set up in the database) allows you to reverse your DB schema
(or a part of it) into Java entities.
If you are willing to try this option, remember that you need to activate the Eclipse JPA fa-
cet in your project, from Project Properties , as shown in the following screenshot:
One more option is mentioned in Appendix , Rapid Development Using JBoss Forge , which
discusses JBoss Forge, a powerful, rapid application development (aimed at Java EE) and
project comprehension tool.
In this chapter, we will focus on generating SQL scripts from Java classes. Whatever your
strategy is, the expected outcome needs to conform to the following entities. Here is the
first one, SeatType , which maps the table SEAT_TYPE :
@Entity [1]
@Table(name="seat_type") [2]
public class SeatType implements Serializable {
@Id [3]
private Long id;
private String description;
private int price;
Search WWH ::

Custom Search