Wednesday, August 23, 2023

Accessing Data with JPA with memory-based h2 database

 

What You need

Java and OOP concepts (if not you can see my videos on java)

A favorite text editor or IDE : Intellj , Eclipse, VS code

Java 8 or later

Gradle 7.5+ or Maven 3.5+

Postman

 

Overview:

In this tutorial  will walk you through the process of building Springboot application that uses Spring Data JPA to store and retrieve data using in memory h2 relation database. Spring Data JPA make it easier to integrated data access technologies i.e. relational and non-relational databases, map-reduce frameworks, and cloud-based data services through java code.

 

Features

• Powerful repository and custom object-mapping abstractions

• Dynamic query derivation from repository method names

• Implementation domain base classes providing basic properties

• Support for transparent auditing (created, last changed)

• Possibility to integrate custom repository code

• Easy Spring integration via JavaConfig and custom XML namespaces

• Advanced integration with Spring MVC controllers

• Experimental support for cross-store persistence

 

Architecture:

Draw a diagram

 

How to  Accessing Data with JPA with New project or existing project?

  1. navigate to https://start.spring.io to create a project.

  2. Choose either Gradle or Maven and the language you want to use and language as java.

  3. Click Dependencies and select Spring Data JPA and then H2 Database.

  4. Click Generate. This will download a your project as Zip file.

  5. Extract the project created in you desired folder.

  6. Open the project in your favorite IDE

  7. Create an Entity Class Customer and add desired fields with JPA annotation

  8. Create CustomerRepository that extends CurdRepository which will provide the ability to perform CRUD operation into database.

  9. Add findByLastName, findById custom methods to fetch records based on lastName and id

  10. Create a CustomerController class that will accepts request from client to create, read, update and delete records.

  11.  Run the application

  12. Using Postman send request to server and verify its working as expected

 

Summary

Congratulations! You have written a simple application that uses Spring Data JPA to save objects to and fetch them from a database, all without writing a concrete repository implementation.

 

 

Sunday, August 6, 2023

How to format code block in blogger? [Blogger Code Formatter]

 

 

  1. Open the code formatter from the link http://codeformatter.blogspot.com/ 
  2. Paste your source code block on the text area 
  3. Customized the source code formatter option. (Default options worked for me )
  4. Click format source code button
  5. Copy paste the code and switch to html view in your blogger post and paste the html copied  to your blogger.

 Image Reference


 

Source Code Formatter for Blogger, Blogspot , Blog & Blogging, Format Formatting Tool
Source Code Beautifier And Formatter For Blogger and Websites, Format Source Code , Format Source code for blog or blogging & website, Online line source code formatter tool, blogger code format tool, Format source code for blogspot,Insert formatted source code


SQL INTERVIEW QUESTIONS AND ANSWERS