Close

JPA - Using @Table

By default database table is mapped by the @Entity name e.g. @Entity(name = "myEntity").
If element 'name' of @Entity is not specified then the entity name and the table name will be the unqualified class name. If table name needs to be different than entity name, then we can use @Table annotation as shown in this example.

Example Project

Dependencies and Technologies Used:

  • h2 1.4.193: H2 Database Engine.
  • eclipselink 2.6.4: EclipseLink build based upon Git transaction 44060b6.
    Related JPA version: org.eclipse.persistence:javax.persistence version 2.1.1
  • javax.persistence 2.1.1: javax.persistence build based upon git transaction 40384f5.
  • JDK 1.8
  • Maven 3.3.9

jpa-table-annotation Select All Download
  • jpa-table-annotation
    • src
      • main
        • java
          • com
            • logicbig
              • example
                • MyEntity.java
          • resources
            • META-INF

    See also

    JPA Entities