learning

Showing posts with label learning. Show all posts
Showing posts with label learning. Show all posts

The best way to map @OneToOne


@OneToOneThe best approach to bidirectional @OneToOne is to use @MapsIdStudent entity@Entity@Data@Table(name = "students")public class Student implements Serializable {     @Id     @GeneratedValue     private Integer id;     private...

Thread pool in Java


The Thread poolIntroductionExecutor implementations use thread pools.The thread pool is a collection of worker threads that are ready to serve.Creating new threads and manage them uses a big amount of data.Worker threads in the thread pool will help to reduce this overhead of creating threads.Tasks...

Java ExecutorService


Java ExecutorServiceIntroductionIf an application has few threads, it can be used threads very easily using the above methods.But if an application has many threads, it will be not easy to handle this.Executors can be used to avoid this complexity.The executor framework is a framework that can be...

Thread priority


Thread priorityEach thread has a priority.It starts from 1 to 10 and the highest priority is 10 while the lowest is 1.The default priority of the main thread is 5.If you set the thread priority out of 10, it will give a compile-time errorException in thread "main" java.lang.IllegalArgumentExcepti...

List vs Queue vs Set vs Map


 List vs Queue vs Set vs MapListQueueSetMapDuplicatesYesYesNoNo(Allow duplicate values not keys)OrderYesYesNoNoNull valuesYesPriority queue doesn't allow, but queue using LinkedList allows nullSingle nullSingle null key and many null valu...

What is REST


RESTIntroductionStands for Representational State Transfer.REST is a web standards-based architecture that uses the HTTP protocol (port 80) for data communication.Uses HTTP methods for data communication REST server simply provides access to resources and client access and presents the resource.REST...

Directives in Angular 11


 DirectivesDirectives are instructions in the DOMIt adds additional behaviors to the elementsUsing inbuilt directives we can manage forms, lists, styles, and what users see.There are a few typesComponent directivesAttribute directivesStructural directivesComponent directivesThese directives are...

Access token vs refresh token


Access token vs refresh tokenAccess tokenThis is short-livedSend API request, with the access tokenIf the access token is invalid, fail and ask the user to re-authenticateThere are few types of access tokensBearer tokensJWT tokensOpaque tokenRefresh tokenThese tokens are long-livedRefresh tokens are...

States of an object in Hibernate


Hibernate object statesThere are three statesTransient If the object just created, no primary key and not associate with a session, then the object is in the transient statePersistent If a session is open, the object is in the persistent stateDetached If a session is closed, the object...

Streams vs Collections in Java


 Streams vs CollectionsCollectionsStreamsThe collections are used to store & group data in data structures like List, Set, Map...etc.Streams are used to perform complex operations like filtering, matching, mapping, etc... on stored dataData modification can be done. You can add or remove data...

Throw vs throws in exception handling


Throw vs throwsThrowThrowsUses inside a method when it is required to throw an exceptionThis is used in the method signature in which methods that exceptions can occur. Only one exception can be thrownThrows can be used to declare multiple exceptionsUsed to handle unchecked exceptionsUsed to handle...

Bean scopes in Spring Framework


Spring Bean scopesSet up the scopeThe @Scope annotation can be used@Scope("singleton")There are 6 scopes are available in the application contextsingleton This is the default scope.The same object is...

Dependency injection in Spring Boot


Dependency injection What is Dependency injection?Dependency injection is a form of the IoC containerIt is just passing dependencies to other objects or frameworks.Dependency injection allows you to...

jar vs war in Spring Boot


 Use jar not warIf you run mvn clean install in Spring Boot, you will get a fat jar file.It contains everything like dependencies, embedded web server... etc.You can just run java -jar jarFile in a JVM, the default is Tomcat embedded server or you can use Jetty.You don't need any web server or...