Junior — Middle
What does the @Table annotation mean and what attributes does it include?
sobes.tech AI
Answer from AI
The @Table annotation in Java is typically used in the context of ORM (e.g., JPA) to specify that a class corresponds to a table in the database.
Main attributes of @Table:
name: the name of the table in the database.schema: the database schema, if used.catalog: the database catalog.uniqueConstraints: constraints on columns.
Example usage:
@Entity
@Table(name = "users", schema = "public")
public class User {
// fields and methods
}
This links the User class to the users table in the public schema of the database.