concept @Table in category ejb

appears as: @Table
EJB 3 in Action, Second Edition

This is an excerpt from Manning's book EJB 3 in Action, Second Edition.

The true magic of the code in this listing lies in the EntityManager interface. One interesting way to think about the EntityManager interface is as an interpreter between the object-oriented and relational worlds. The manager reads the O/R mapping annotations like @Table and @Column on the Bid entity and figures out how to save the entity into the database. The EntityManager is injected into the DefaultBidDao bean through the @PersistenceContext annotation .

@Table specifies the table containing the columns to which the entity is mapped. The name parameter is most important. By default all the persistent data for the entity is mapped to the table specified by the annotation’s name parameter. As you can see from the annotation’s definition, it contains a few other parameters:

@Target(TYPE)
@Retention(RUNTIME)
public @interface Table {
    String name() default "";
    String catalog() default "";
    String schema() default "";
    Index[] indexes() default {};
    UniqueConstraint[] uniqueConstraints() default {};
}

The @Table annotation is optional. By default, JPA will assume the name of the table is the name of the @Entity class itself. In the case of the Category class in listing 9.1, JPA will assume the name of the database table is Category. The @Table annotation allows you to override this conventional behavior. For example, if the database table is named ITEM_CATEGORY, use the @Table annotation to configure JPA: