Hibernate Tutorials
These tutorials have been published to help you start with persistence with Hibernate and JPA. These are updated to version Hibernate 6.x.
These tutorials have been published to help you start with persistence with Hibernate and JPA. These are updated to version Hibernate 6.x.
Learn to create and inject an in-memory DataSource that can be used to mock J2EE container provided JNDI DataSource without running a server.
Learn to execute bulk SQL INSERT and UPDATE statements using Hibernate / JPA batch processing, and to configure session-specific batch sizes.
Hibernate provides support for executing the stored procedures and capturing their outputs using StoredProcedureQuery and ProcedureCall APIs.
Learn to use the Hibernate aggregate functions used to query a calculated value for a field among all entities matching the given criteria.
Learn to configure full text and query index-based searches in Hibernate using backends like Lucene, Elasticsearch or OpenSearch.
Learn to use Hibernate Interceptor for getting callbacks for persistence events and register it with Session and SessionFactory interfaces.
Learn to implement and test the pagination functionality in hibernate using the HQL setFirstResult(), setMaxResults() and ScrollableResults.
Learn to sort the entities fetched from the database using hibernate HQL, native SQL, Criteria queries and Comparator interface.
Learn to delete a single entity or a list of entities matching some criteria using hibernate native APIs and Jakarta persistence APIs.
Learn to use the Hibernate’s native event callback mechanism and annotation based callback events from the new Jakarta persistence API.
Learn to initialize the EnitytManager using the XML configuration and the programmatic configuration in hibernate 6 and Jakarta persistence.
Learn to map Java 8 classes (LocalDate, LocalTime or LocalDateTime etc) to SQL types while storing the time-based values in the database.
Learn to setup and configure the L2 (second-level cache) in Hibernate 6 using Ehcache 3 using its JCache API and EhcacheCachingProvider.
Learn to solve the IllegalArgumentException: Unable to locate persister error while migrating from hibernate 5 to hibernate 6.
Learn to copy or pipe the byte[] data from InputStream to OutputStream for small streams and also for large streams over 2 GB.
Learn to convert a Reader to InputStream and also convert InputStream to Reader in this short Java IO tutorial.
This JUnit tutorial series lists down the articles written for the creation and execution of JUnit 4 and JUnit 5 tests.
Learn to create a new single directory or nested directory along with parent directories in a specified path using Java IO and NIO classes.
Learn to count all the lines in file with the efficient solutions like Stream of lines, List and LineNumberReader classes.
Learn to a few performance-proven methods to check if a given directory is empty or not using the Java NIO Files and DirectoryStream classes.
Learn to get the creation date and time of a file in Java using Java NIO Files class in different time units since epoch and to Instant.
Learn to create, detect and find targets of the symbolic links (also known as symlinks or soft links) using examples in Java.
Learn to make the file empty by deleting all the content in it. This makes the file size zero without deleting the file itself.
Learn to write the given byte[] into a file using different solutions. We will be using the Java NIO, Commons IO and Guava APIs that provide simple APIs for this usecase.
Learn to read all the lines from a file into ArrayList using Java IO and NIO APIs, Stream API, Commons IO and Guava classes.
This Java tutorial lists down the published tutorials on this blog related to Stream API, methods and its related concepts with examples.
Learn to read a specific line from a text file in Java. We will learn to write the solution for small files as well as large files as well.
Learn to read all lines from a large file (size in GB) in Java and avoid any performance pitfalls such as very high usage of memory or even OutOfMemoryError if the File is large enough.
Learn to delete a specified file or directory in Java. Note that different methods behave differently for deleting non-empty directories.
Learn to rename a file or directory at a specified path or move to a new directory in Java. We will learn to use the classes from Standard IO, New IO, Guava and Commons IO.
Learn the difference between path, absolute and canonical paths. Also, learn to get the path of a file in Java using standard IO and New IO classes.
Learn to get the size of a file or a directory in Java using IO classes File, Files and Common IO’s FileUtils class.
After the legacy Java finalization has been deprecated (JEP-421) in Java 18, learn the basics of Cleaner API and how to use it.
Learn to create and operate on the streams of primitive types (IntStream, LongStream and DoubleStream) in Java with examples.
The legacy Java API had been a big pain point for Java developers for quite a long time. With the release of Java 8 release (JSR-310), package java.time introduced the new immutable classes that solved the issue with the original classes. Following articles have been published to help you start with some very common …
Learn to add or subtract hours, minutes or seconds from a given date and time in Java using various date-time classes and their plus methods.
Learn to get the year, month and day from a given date in Java using the new LocalDate classes as well as legacy Date and Calendar classes.
Learn to set the default time zone used by the JVM using an environment variable, JVM argument and TimeZone class.
Learn to find the day of the week for a given date using the legacy Date and Calendar classes as well as the new Java 8 Date API. 1. Overview There may be a requirement to show the day of the week (Monday to Sunday) in the UI, and then …
Learn to get the start and the end of a date using Java date API, e.g., LocalDateTime and ZonedDateTime. We may require to get this information in many cases. For example, we have to filter the events that occurred at different times in a single day based on event timestamps. …
For any application supporting multiple locales and timezones, it is often the requirement to show the date and timestamp adjusted to the user’s local timezone offset.
Learn about ZonedDateTime and OffsetDateTime classes in Java, and what are the main differences between both classes in depth. 1. Understanding Zone Id and Zone Offsets Before jumping to the internals of the classes, let’s make sure we understand the difference between the zone identifier and zone offsets. Most programming …
Learn to convert a given duration in milliseconds to hours, minutes and seconds; and format to to HH:mm:ss and any other custom pattern.
Starting with JDK 8, we have a comprehensive date-time API containing classes such as LocalDate, LocalTime, LocalDateTime, ZonedDateTime, OffsetDateTime, and OffsetTime. These classes allow easy formatting of the date-time output via DateTimeFormatter.ofPattern(). The API also allows further customize the output based on specified Locale information to support localization and internationalization features. In …
Java supports creating and modifying the date and time using primarily two packages java.time and java.util. The package java.time was part of Java 8 release (JSR-310) that introduced the new immutable classes solving the shortcomings of the legacy java.util.Date and java.util.Calendar classes. 1. Legacy Date Time API (Prior to Java …
Arrays in Java, conceptually, are no different than in other programming languages. The java.util.Arrays class provides many useful static methods to work with arrays and perform common operations on them. 1. Array Basics 2. Array Operations 3. Searching and Sorting 4. Conversions 5. Advance Topics Happy Learning !! Sourcecode on …
Learn why we get the ArrayStoreException while working with arrays in Java and how to identify the root cause and fix this error. 1. Root Cause of ArrayStoreException Java arrays are covariant and support the subtyping rules of Java, an array of type T[] may contain elements of type T …
Learn to find the sum and average of the numbers stored in an array. We will be using the Java Stream API and simple for loop to find these values. Note that the numbers in Java are represented with 8 primitives i.e. short, char, byte, boolean, int, float, long and …
Learn to convert a list to an array in Java and also convert a given array to a list. We will learn the conversions using the core Java APIs. 1. Converting List to Array We can use the following two approaches to convert a given list to an array. 1.1. …
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.