High-Performance Java Persistence Newsletter, Issue 21
Imagine having a tool that can automatically detect JPA and Hibernate performance issues. Hypersistence Optimizer is that tool!
Welcome to a new issue of the High-Performance Java Persistence Newsletter in which we share articles, videos, workshops, and StackOverflow answers that are very relevant to any developer who interacts with a database system using Java.
First of all, I want to show a very cool tool, PMM (Percona Monitoring and Management), which you can use to monitor the performance of your MySQL or PostgreSQL database and analyze both slow-running queries and N+1 query issues.
A very interesting article I read is this one, which provides various solutions for implementing a distributed lock solution using ZooKeeper, Cassandra, or Hazelcast.
If you are using a relational database system and want to implement a simple audit log mechanism, then you can store the CDC events in JSON columns and use a trigger to catch INSERT, UPDATE, and DELETE statements against the table records you need to audit. Check out the following articles for step-by-step solutions:
- How to implement a trigger-based audit log using MySQL
- How to implement a trigger-based audit log using PostgreSQL
- How to implement a trigger-based audit log using SQL Server
Java 14 added support for Records, which allows us to create very compact data structures. While Java Records are not suitable for JPA entities, you can use Records for entity attributes. If you are interested in this topic, then this article will show you how to Java Records to JSON column types.
If you’ve been using relational databases for a long time and think that a tool like
pg_dump is suitable for taking backups, then you should definitely read this article, which explains the proper way to take database backups.
A very interesting article I read on the Percona blog is this one, which explains that, unlike PostgreSQL, the MySQL
EXPLAIN command evaluates the stored procedures included in a given SQL query. If the stored procedure modifies data, then this can be a problem, so you are better off including the
EXPLAIN in a
BEGIN .. ROLLBACK or a read-only transaction.
If you enjoy using Twitter and want to build a vibrant community, then this article explains what it takes to achieve that goal.
There are many social media platforms, but for me, Twitter is the one I like best. Here are the best tweets I posted since the last newsletter:
Protip: If you want to become a better software developer, you should study the source code of the frameworks you are using.— Vlad Mihalcea (@vlad_mihalcea) November 23, 2020
Not only you'll get a better understanding of how they work, but you're going to learn how design patterns are applied in practice.
Pro tip: As an experienced software developer, investing time in learning about business, management, marketing and sales can be way more profitable than keeping up with all the hype in programming languages or frameworks.— Vlad Mihalcea (@vlad_mihalcea) November 3, 2020
Edvard Munch, "Developer handling time zones" pic.twitter.com/1Ag4tGJheH— Vlad Mihalcea (@vlad_mihalcea) November 24, 2020
Protip: You shouldn't hold back from blogging because you cannot think of something really innovative that no one ever wrote about.— Vlad Mihalcea (@vlad_mihalcea) November 27, 2020
Explaining something in a different way and having multiple perspectives over the same topic is very valuable for the community.
Knowledge is incremental. The more you learn, the easier it becomes to learn more.— Vlad Mihalcea (@vlad_mihalcea) November 11, 2020
MariaDB 10.5 has been released, and it provides a ColumnStore engine that is suitable for analytics and a new INET6 data type that can store both IPv6 and IPv4 addresses. There are also many improvements in the InnoDB engine, the Optimizer, and the replication mechanism. For more details about this new version, check out this article.
Hibernate ORM has released two new versions, 5.4.24 and 5.3.20, and it provides a fix for a security issue that’s affecting Criteria API queries, so you should definitely consider upgrading your Hibernate dependency.
If you like this newsletter,
you are going to love the next episodes!
The following StackOverflow answers have been trending over the past two weeks:
- The best way to implement an audit trail in SQL Server
- What is the difference between FetchType LAZY and EAGER in Java Persistence API?
- Does Java support structs
- What is the difference between
@Column(length=value)when using JPA and Hibernate
- Can I combine a @Query definition with a Specification in a Spring Data JPA repository method?
- What is the difference between
mappedBywhen using a JPA