There is a simple PostgreSQL database. The database has a ready-made table with filled data. It is necessary to read data from the database, and display it through a servlet. The problem is that in all the examples @Entity creates tables, but they are already ready.
Question:
Are there annotations to help implement the configuration of the Entity to read from the database?
If not, what method to read?
Here is my code for general understanding.
import org.hibernate.validator.constraints.NotEmpty; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import java.sql.Date; @Entity @Table(name = "rs_user") public final class UserEntity { @Id @GeneratedValue(strategy = GenerationType.AUTO) @NotEmpty @Column(name = "id_user") private long userId; @NotEmpty @Column(name = "user_name") private String userName; @NotEmpty @Column(name = "user_dismiss_date") private Date userDate; @NotEmpty @Column(name = "user_password_hash") private String passwordHash; @NotEmpty @Column(name = "user_password_salt") private String passwordSalt; @Column(name = "user_is_administrator") private boolean userAdmin; public long getUserId() { return userId; } public String getUserName() { return userName; } /** * This method returned of user data. * @return userDate of Date */ public Date getUserDate() { return userDate; } public String getPasswordHash() { return passwordHash; } public String getPasswordSalt() { return passwordSalt; } public boolean getUserAdmin() { return userAdmin; } }