import jakarta.persistence.*;
时间: 2023-10-06 14:14:10 浏览: 141
jakarta.persistence-api-2.2.3-javadoc.jar
As an AI language model, I cannot execute code. However, I can provide you with some information on Jakarta Persistence.
Jakarta Persistence is a set of APIs for accessing relational databases from Java applications. It provides a standard way to work with the Java Persistence API (JPA) and is used for ORM (Object-Relational Mapping) in Java.
The @Entity annotation is used to identify a class as an entity. An entity represents a table in a relational database. The @Id annotation is used to specify the primary key of the entity.
Here is an example of a simple entity class using Jakarta Persistence:
```
@Entity
public class Customer {
@Id
private Long id;
private String firstName;
private String lastName;
// getters and setters
}
```
This entity class represents a table called "Customer" with three columns: "id", "firstName" and "lastName". The "id" column is the primary key.
Jakarta Persistence also provides other annotations like @Table, @Column, and @GeneratedValue for defining the table and column names and specifying how primary keys are generated.
阅读全文