My Articles:
1. Reason we might face this exception if we are trying to execute stored procedure using JPA 2.1 and hibernate’s entity manager, and we are not using the entity manager’s registerStoredProcedureParameter() correctly. Incorrect usage may look like below OR the one you have written. The exception will look like this: …
We might face this exception if we are trying to execute any query OR stored procedure, and parameters are not set in the correct datatype.
Learn to execute SQL stored procedures with the help of @NamedStoredProcedureQuery annotation from Jakarta persistence API that helps in specifying the name of a stored procedure, its parameters, and its result type. 1. Project Setup The support for executing stored procedures using @NamedStoredProcedureQuery has been added in JPA 2.1. So …
Using custom SQL scripts in spring to initialize the database at startup of application with appropriate tables and data populated inside it.
JPA delete query example. Learn to use native SQL DELETE query in JPA using EntityManager’s executeUpdate() method.
You may get NotYetImplementedException exception when you are trying to include some native SQL queries in your project as named native queries, and you do not expect any result after execution of those sql queries. e.g. SQL UPDATE queries which does not return any result. Problem Let’s say you want …
JPA named query update example. Learn to use @NamedNativeQuery annotation to execute SQL update queries using EntityManager.cexecuteUpdate().
Learn to define and execute a named native SQL query using Hibernate @NamedNativeQuery annotation with examples.
The static import statements import the static fields and methods from a class and allow them to be used without the class reference.
Java provides four access modifiers to set access levels for fields, methods and constructors i.e. public, private, protected, and default.
Classes are the basic units of programming in the object-oriented paradigm. In this tutorial, learn to write Java class and how to create object in Java.
The Java continue statement skips the current iteration of a for loop, while loop, or do-while loop and moves to the next iteration.
The break keyword in Java is used to terminate for, while, or do-while loops. It may also be used to terminate a switch statement as well.
Java do-while loop executes the statements in do block, and then evaluates a condition in the while block to check whether to repeat the execution.
The while loop in Java continually executes a block of statements until a particular condition evaluates to true, else the loop terminates.
Since Java 1.5, the for-each loop or enhanced for loop is a concise way to iterate over the elements of an array and a Collection.
Java for-loop statement is used to iterate over the arrays or collections using a counter variable that is incremented after each iteration.
Java switch statements help in providing multiple possible execution paths for a program. Java switch statements can be used in place of if-else statements to write more cleaner and concise code. Java switch statements have evolved over time. In this tutorial, we will learn about basic switch statement features and …
Java if-else statements help the program execute the blocks of code only if the specified test condition evaluates to either true or false.
A block statement is a sequence of zero or more statements enclosed in braces. A block statement is generally used to group together several statements, so they can be used in a situation that requires you to use a single statement. 1. What is a Block Statement? Generally, a java …
A statement specifies an action in a Java program. For example, a statement may tell the add of values of x and y and assign their sum to the variable z. It then prints a message to the standard output or writes data to a file, etc. Java statements can …
Learn about available Java operators, and precedence order and understand their usages with examples. We will also try to understand when to use which operator and what to expect in the result. 1. Java Operators An operator is a symbol that performs a specific operation on one, two, or three …
We must have heard the terms Little-Endian and Big-Endian many times in your engineering course. Let’s quickly recap the concept behind these words. 1. Little-Endian vs Big-Endian These two terms are related to the direction of bytes in a word within CPU architecture. Computer memory is referenced by addresses that …
Learn about various data types in Java. Learn the differences between primitive datatypes and non-primitive datatypes (or reference datatypes). We will also learn about the data types sizes and best practices for using datatypes in Java. 1. How to Declare a Variable in Java? In Java, typically datatypes are associated …
Java is concurrent, object-oriented, and intended to let application developers “write once, run anywhere” (WORA). Java is considered a fast language, almost as fast as languages like C and Rust, but it uses a lot of memory in comparison to these languages. 1. What is Java Programming Language Java is …
All the values in Java are divided into two categories: reference types and primitive types. Learn about eight Java primitive data types.
In JPA, mapping information of an entity must be accessible to the ORM provider at runtime, so that when it is writing the data to storage, mapping information can be obtained from the entity instance. Similarly, when the entity state is loaded from the storage, the provider runtime must be …
Learn to find JPA entities by ID or name using EntityManager.find(), JPQL queries, named queries, Criteria API, and Spring Data repository methods.
In JPA, use merge when dealing with detached entities; and use persist to explicitly add a new entity to the database without checking if it already exists.
JPA delete entity example. Learn to delete JPA entity by id. Also learn to delete multple jpa entities using Java Persistence Query Language.
Learn to configure the JPA in Spring application without the persistence.xml. We will see the XML and Java configuration examples.
When unit testing the DAO / Repository interfaces, it is very important to know what we are testing and what assumptions we are asserting.
The eclipse quick search plugin is part of Spring Tools Suite (STS). So if you have STS installed in eclipse, then chances are you have it already.
One of the benefits of the Java executor framework is that we can run concurrent tasks that may return a single result after processing the tasks. The Java Concurrency API achieves this with the following two interfaces Callable and Future. In this tutorial, we will learn to execute Callable tasks …
In previous tutorial, we learned about basic thread pool executor with unlimited possible number of threads into the pool and it’s example usage. Now lets look example of fixed size thread pool executor which will help in improved performance and better system resource utilization by limiting the maximum number of …
Why do we need a thread pool in Java? The answer is when we develop a simple, concurrent application in Java, we create some Runnable objects and then create the corresponding Thread objects to execute them. Creating a thread in Java is an expensive operation. And if you start creating …
Secure Socket Layer (SSL) is a secure transfer protocol used for communication on the Internet using cryptographic methods. The main purpose of the SSL protocol is to guarantee that no one can tamper with the communication between a browser and the server where the web application is deployed. Another purpose …
By default, Tomcat is configured to run on port 8080. That’s why all the deployed web applications are accessible though URLs like http://localhost:8080/yourapp. If you want to run an application on URL like http://localhost/yourapp, then you will need to change the default port 8080 to 80, which is default port …
We already learnt how webservers work in general when you deploy your web application on server and access from a browser. Now let’s learn the stuffs inside server which may not be used in day to day job, but they will certainly help you when you are configuring your application …
Spring MVC Interview Questions and answers. These have been written to help beginners as well as experienced developers to prepare for their next interview.
After going through spring core interview questions, let’s cover the top Spring AOP interview questions we may expect in our next technical interview. Again, please feel free to suggest new questions that are not part of this post to include them to benefit a larger audience. 1. Describe Spring AOP? …
This page lists the most asked and important Spring framework interview questions that we may face in our next job interview. 1. What is Spring Framework? What are it’s Main Modules? Spring is probably the most used Java framework for developing simple web applications to enterprise-class cloud applications and microservices. …
In java, most used data structure is probably a list. A list has an undetermined number of elements and you can add, read, or remove the element of any position. Additionally, concurrent lists allow the various threads to add or remove elements in the list at a time without producing …
Learn to create Spring REST client using Spring RestTemplate class and it’s template methods to access HTTP GET, POST, PUT and DELETE requests in easy step.
In this spring rest json example, we will learn to write RESTFul webservices capable of returning JSON for resources using MappingJackson2JsonView.
In this Spring REST XML example, I am writing hello world example for REST APIs using Spring REST features. In this example, I will be creating two APIs which will return XML representation of resources. 1. Maven Dependencies Let’s start with runtime dependencies which you will need to write these …
If you are working on any customer facing web application which is developed using Spring MVC, then your will probably need to use dropdown box as well somewhere in application UI. This tutorial will help you in displaying a pre-populated dropdown and then validating whether user selected any value while …
If you are working on spring MVC web application and you are trying to use JSR-303 validation annotations then you might face this exception. Exception stack trace looks like this. Solution This problem is due to incorrect version of “hibernate-validator” dependency. You need to try other versions of this dependency …
JSR-303 bean validation is an specification whose objective is to standardize the validation of Java beans through annotations. The objective of the JSR-303 standard is to use annotations directly in a Java bean class. JSR 303 specification allows the validation rules to be specified directly into the fields inside any …
In spring mvc form submit tutorial, we learned about displaying displaying a form and submitting form data, including validating inputs using BindingResult.rejectValue(). In this example, we will learn to build a more robust validator for EmployeeVO model object. This validator is custom implementation of Validator interface. In this example, I …