Hibernate / Hibernate 7 Basics Interview Questions
What is an entity in Hibernate 7 and how do you define one?
An entity is a Java class mapped to a database table. Each instance corresponds to a row. In Hibernate 7, entity classes follow Jakarta Persistence 3.2 rules.
import jakarta.persistence.*; @Entity @Table(name = "products") public class Product { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(name = "product_name", nullable = false, length = 200) private String name; @Column(precision = 10, scale = 2) private BigDecimal price; @Enumerated(EnumType.STRING) // store as 'ACTIVE' not 0/1 private ProductStatus status; protected Product() {} // JPA proxy constructor public Product(String name, BigDecimal price) { this.name = name; this.price = price; this.status = ProductStatus.ACTIVE; } }
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
