Skip to main content

Posts

Showing posts from June, 2025

How to increase performance with fixed thread pools when retrieving bulk relational data

So, here my suggestion is to retrieve bulk data using multiple threads asynchronously and bind them together after complete the retrieval mechanism. I will show you how can we achieve this using Java. For this first you have to define number of thread we need to use. We can use a executor to adjust the thread pool size. ExecutorService executor = Executors.newFixedThreadPool(2); Now we can do the further implementation. I have two collections user and profile. I need to retrieve both user and profile details using two separate threads. In the above I passed 2 as thread pool size. So these are the two collection retrievals I used for getting user and profile details. private CompletableFuture<User> retrieveUser(ExecutorService executor) {     return CompletableFuture.supplyAsync(() -> userRepository.findById(id).orElseThrow(() -> new RuntimeException()), executor); } private CompletableFuture<Profile> retrieveProfile(ExecutorService executor) {     r...

Better Way to Make a Shared Data Grid Using Material UI and React

Sometime ago I have a requirement to make a shared data grid that can use inside different components in the react. I tried with different scenarios but couldn’t figure out a better way to make a shared data grid with different options. My requirement is also gather with Typescript and Material UI version 5.0. So I used their latest Material data grid free release(version 6). When we plan to use v6 data grid, It is bit different than version 5. So I like to show how I fulfill my requirements and how I made my components in a better way. Ok let’s go. First we need to have latest react version and Material UI version up to 5. Then in here I’m planning to work on Material UI x-data-grid version 6. In here I’m using Typescript to show the coding examples. Ok, Let’s create our shared data grid components like below. I will explain about some properties I have used inside this data grid Material UI component. This is my basic setup of data grid component. import React from 'react'...

How to create cloned object using Java

I have an experience with updating a user profile with checking unique email and phone number. In that case I want to get my previous profile details and want to set new updated object details. But after I set the new object details to my retrieved previous object, my previous object setting with new data. So I have a way to again recall the previous data object using a database call.  But if you prefer to maintain a performance based app, you can reduce the database call using cloning the objects. Here actually we create the same object as old and new two objects.  First I will show how we can achieve using Java 8 version. Think if you have two classes Profile and DomainEntity. Here actually DomainEntity used for extend generic objects like created date, updated date etc. @Getter @Setter public class DomainEntity {     private Date createdDate;     private Date updatedDate;     private boolean deleted; } @Getter @Setter public class Profile exten...