Chapter 2

Answer 1: ORM is a technique that allows you to fetch and manipulate from a database using an object-oriented programming paradigm. JPA provides object-relational mapping for Java developers. Hibernate is Java-based JPA implementation.

Answer 2: Entity class is just standard java class that is annotated with the @Entity annotation. Inside the class you have to implement constructors, fields, getters and setters. The field(s) that will be the unique id is annotated with the @Id annotation. 

Answer 3: You have to create a new interface that extends Spring Data CrudRepository interface. In the type arguments you define the entity and the type of the id field, for example, <Car, Long>.

Answer 4: CrudRepository provides all CRUD operations to your entity. You can create, read, update, and delete your entities using the CrudRepository.

Answer 5: You have to create entity classes and link the entities using the @OneToMany and the @ManyToOne annotations.

Answer 6: You can add demo data in your main application class using CommandLineRunner.

Answer 7: Define the endpoint for the H2 console in your application.properties file and enable it. Then you can access the H2 console by navigating to the defined endpoint with a web browser.

Answer 8: You have to add MariaDB dependency to the pom.xml file and define the database connection settings in the application.properties file. Remove the H2 database dependency from the pom.xml file, if you have used that.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.89.18