You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use this https://start.spring.io/#!type=maven-project&language=java&platformVersion=3.1.5&packaging=jar&jvmVersion=17&groupId=com.example&artifactId=accessing-data-jpa&name=accessing-data-jpa&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.accessing-data-jpa&dependencies=data-jpa,h2[pre-initialized project] and click Generate to download a ZIP file. This project is configured to fit the examples in this tutorial.
22
+
You can use this https://start.spring.io/#!type=maven-project&platformVersion=3.5.5&packaging=jar&jvmVersion=17&groupId=com.example&artifactId=accessing-data-jpa&name=accessing-data-jpa&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.accessingdatajpa&dependencies=data-jpa,h2[pre-initialized project] and click Generate to download a ZIP file. This project is configured to fit the examples in this tutorial.
23
23
24
24
To manually initialize the project:
25
25
26
26
. Navigate to https://start.spring.io.
27
27
This service pulls in all the dependencies you need for an application and does most of the setup for you.
28
-
. Choose either Gradle or Maven and the language you want to use. This guide assumes that you chose Java.
28
+
. Choose either Gradle or Maven and the language you want to use.
29
29
. Click *Dependencies* and select *Spring Data JPA* and then *H2 Database*.
30
30
. Click *Generate*.
31
31
. Download the resulting ZIP file, which is an archive of a web application that is configured with your choices.
32
32
33
33
NOTE: If your IDE has the Spring Initializr integration, you can complete this process from your IDE.
34
34
35
-
NOTE: You can also fork the project from Github and open it in your IDE or other editor.
35
+
NOTE: You can also fork the project from GitHub and open it in your IDE or other editor.
36
36
37
37
[[initial]]
38
38
== Define a Simple Entity
39
39
40
40
In this example, you store `Customer` objects, each annotated as a JPA entity. The
The `AccessingDataJpaApplication` class includes a `demo()` method that puts the `CustomerRepository` through a few tests. First, it fetches the `CustomerRepository` from the Spring application context. Then it saves a handful of `Customer` objects, demonstrating the `save()` method and setting up some data to work with. Next, it calls `findAll()` to fetch all `Customer` objects from the database. Then it calls `findById()` to fetch a single `Customer` by its ID. Finally, it calls `findByLastName()` to find all customers whose last name is "Bauer". The `demo()` method returns a `CommandLineRunner` bean that automatically runs the code when the application launches.
0 commit comments