Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Collapse

Kakakuona Forum

  1. Home
  2. Blogs
  3. Creating DAOs in Spring Boot without using Database

Creating DAOs in Spring Boot without using Database

Scheduled Pinned Locked Moved Blogs
3 Posts 3 Posters 97 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    deleter01
    wrote on last edited by
    #1

    Step One : Create Package to make your work standard

    Screenshot from 2024-08-07 10-16-35.png

    Just right click on com.demo.demo then click new -> package

    Step Two: Create Entity or Object
    Into Entity package right click -> new -> Java Class

    Screenshot from 2024-08-07 10-15-53.png
    Note: You will define your attribute based on need as shown bellow,you can also provide get and set method

    Step Three: Create Interface

    Interface, is abstracts the operations on data without knowing the details of the underlying data source.
    Here we will have two method save() and findAll().
    Screenshot from 2024-08-07 10-10-42.png

    Step Four: Create Implementation of Interface

    private List<User> users = new ArrayList<>();
    This line ensures that when the UserImplement class is instantiated, the users variable will be a new, empty ArrayList that can be used to store User objects. This ArrayList will dynamically grow as User objects are added to it.

    Screenshot from 2024-08-07 10-10-20.png

    Step Five: create Service Class for logic implementation

    Screenshot from 2024-08-07 10-43-17.png

    Step Six: Create Controller for end-point implementation

    Screenshot from 2024-08-07 10-09-00.png

    Step Seven: Here is how Function main look like
    Screenshot from 2024-08-07 10-48-13.png

    Testing Our Program I will use postman

    1. Creating User
      Screenshot from 2024-08-07 10-51-28.png

    2. Get Users
      Screenshot from 2024-08-07 10-52-07.png

    1 Reply Last reply
    1
    • darwinD Offline
      darwinD Offline
      Darwin Kingáni
      wrote on last edited by
      #2

      Great post

      ICTO

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Allan Cole
        wrote on last edited by Allan Cole
        #3

        Thanks for sharing!

        1 Reply Last reply
        0

        • Login

        • Don't have an account? Register

        Powered by NodeBB Contributors
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups