Posts

Showing posts with the label boot

Why @Embeddable and @Embedded provided by Hibernate

Image
Clash Royale CLAN TAG #URR8PPP Why @Embeddable and @Embedded provided by Hibernate Have Entity objects properly defined. Able to save data successfully. @Embeddable public class Address { private Integer houseNo; private String streetName; private String state, country; } @Entity public class College { @Id @GeneratedValue private Integer collegeId; private String cName; @Embedded Address address; } But, When I use @Embeddable and @Embedded in hibernate application the final result looks like below. mysql> select * from college; +-----------+---------+---------+----------+--------------+-------+ | collegeId | country | houseNo | state | streetName | cName | +-----------+---------+---------+----------+--------------+-------+ | 1 | Makkah | 121 | Al-Azeed | Bilaal Stree | SMust | +-----------+---------+---------+----------+--------------+-------+ My doubt is if Address fields have been saved in same table why we are using @Embeddabl...