## 📃 JPA Hibernate Annotations
@Entity :
- This annotation is used to mark a category as an entity class.
- This annotation is used to create a desk within the database.
@Entity
public class Model {
}
@Desk :
- @Desk annotation is used to specify the main points of the desk that will likely be created within the database.
- The identify attribute of the @Desk annotation is used to specify the identify of the desk.
@Entity
@Desk(identify = "manufacturers")
public class Model {
}
@Column :
- @Column annotation is used to specify the main points of the column that will likely be created within the database.
- The identify attribute of the @Column annotation is used to specify the identify of the column.
@Entity
@Desk(identify = "manufacturers")
public class Model {
@Column(identify = "brandName")
personal String brandName;
}
@id :
- @id annotation is used to specify the first key of an entity.
- The @id annotation is at all times used with the @GeneratedValue annotation.
@Entity
@Desk(identify = "manufacturers")
public class Model {
@Id
@Column(identify = "id")
personal int id;
}
@ManyToOne :
- @ManyToOne annotation is used to specify many to 1 relationship with one other entity.
@Entity
@Desk(identify = "manufacturers")
public class Model {
@ManyToOne
@JoinColumn(identify = "brandsDetails")
personal BrandDetail brandDetail;
}
@OneToMany :
- @OneToMany annotation is used to specify one to many relationship with one other entity.
- The mappedBy attribute of the @OneToMany annotation is used to specify the property of the entity that’s the proprietor of the connection.
@Entity
@Desk(identify = "manufacturers")
public class Model {
@OneToMany(mappedBy = "manufacturers", fetch = FetchType.EAGER)
personal BrandDetail brandDetail;
}
@PrimaryKeyJoinColumn :
- @PrimaryKeyJoinColumn annotation is used to specify the first key of the entity that’s the proprietor of the connection.
@Entity
@Desk(identify = "manufacturers")
public class Model {
@PrimaryKeyJoinColumn
personal int id;
}
@JoinColumn :
- @JoinColumn annotation is used to specify the column that will likely be created within the database as a overseas key.
@Entity
@Desk(identify = "manufacturers")
public class Model {
@JoinColumn(identify = "brandDetail")
personal BrandDetail brandDetail;
}
@JoinTable ve @MapsId:
- It’s used to specify the be part of desk that will likely be created within the database.
- @JoinTable annotation is used to specify the be part of desk that will likely be created within the database.
- @MapsId annotation is used to specify the first key of the entity that’s the proprietor of the connection.
@Entity
@Desk(identify = "manufacturers")
public class Model {
@JoinTable(identify = "manufacturers")
personal BrandDetail brandDetail;
}
@OneToOne:
- @OneToOne annotation is used to specify one to 1 relationship with one other entity.
- The mappedBy attribute of the @OneToOne annotation is used to specify the property of the entity that’s the proprietor of the connection.
@Entity
@Desk(identify = "manufacturers")
public class Model {
@OneToOne(mappedBy = "manufacturers")
personal BrandDetail brandDetail;
}
✅ Should you like this text, you can provide me a like on. 😎
Thanks for studying. 🙏
Spring Boot Information