- Developing Middleware in Java EE 8
- Abdalla Mahmoud
- 166字
- 2021-07-23 19:24:36
Step 3: Creating an entity class
An entity class is the main player in a JPA application. It's a class that represents a table in the database, whose instances, in turn, represent rows inside this table. An entity class is no more than a POJO, annotated with @Entity, with a field elected as a primary key and annotated with @Id, as in the following example:
Movie.java @Entity public class Movie { @Id @GeneratedValue private long id; private String title; public Movie() { } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } }
Note that you do not have to create a corresponding table in the database yourself, as the persistence unit is declared with the javax.persistence.schema-generation.database.action property set to create, which means that the persistence provider is responsible for creating the table in the database, if it does not exist.
推薦閱讀
- Learning ROS for Robotics Programming(Second Edition)
- Building Modern Web Applications Using Angular
- Dynamics 365 Application Development
- 從程序員到架構(gòu)師:大數(shù)據(jù)量、緩存、高并發(fā)、微服務(wù)、多團(tuán)隊(duì)協(xié)同等核心場(chǎng)景實(shí)戰(zhàn)
- Functional Programming in JavaScript
- 微信小程序開(kāi)發(fā)解析
- H5頁(yè)面設(shè)計(jì):Mugeda版(微課版)
- INSTANT Passbook App Development for iOS How-to
- 時(shí)空數(shù)據(jù)建模及其應(yīng)用
- .NET Standard 2.0 Cookbook
- QGIS 2 Cookbook
- Delphi開(kāi)發(fā)典型模塊大全(修訂版)
- Julia High Performance(Second Edition)
- 從零開(kāi)始學(xué)算法:基于Python
- Java面向?qū)ο蟪绦蛟O(shè)計(jì)教程