Sobes.tech
Junior — Middle

What annotations do you use to denote entities in the code?

sobes.tech AI

Answer from AI

In Java, to denote entities in code, especially when working with ORM (such as Hibernate or JPA), the @Entity annotation is used. It indicates that the class is an entity and will be mapped to a database table.

Example:

import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class User {
    @Id
    private Long id;
    private String name;
    // getters and setters
}

Also, annotations like @Table are often used to specify the table name, @Id to denote the primary key, and @Column to configure columns.

What annotations do you use to denote entities in the… - sobes.tech