12. How to write the entity class?
AnswerBot
1y
Entity class represents a table in a database and its attributes as fields.
Define class with @Entity annotation
Add @Id annotation to primary key field
Add @Column annotation to map fields to table colu...read more
Anonymous
1y
Entity classes represent table in database with its data members as a columns. To define a class as an entity we have to write an @Entity annotations above the class. Every table has a primary key like wise to define primary key in entity class we use @Id annotations above the data member to define the respective data member is primary of the table. Every entity classes must contain getters and setters to manipulate data.
Some annotations used with entity classes:
@Table(name="name")
@Column(name="name")
Relationship like(@OneToOne, @OneToMany, @ManyToMany, @ManyToOne)
Example:
https://github.com/adityakalambe01/Employee-Management-System/blob/main/src%2Fmain%2Fjava%2Fcom%2FEmployeeManagement%2Fentity%2FEmployee.java
Help your peers!
Add answer anonymously...
Top NeoSOFT Java Developer interview questions & answers
Popular interview questions of Java Developer
Top HR questions asked in NeoSOFT Java Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app