Posts

πŸš€ Migrating from Spring Boot 2.x to 3.x: Handling @ManyToOne Relationships

Image
Are you planning to upgrade your Spring Boot application from version 2.x to 3.x? One area that requires careful attention during this transition is the handling of @ManyToOne relationships in your entity classes. Here are some key points to consider and best practices to follow: 1. Changes in Validation for Queries: Spring Boot 3.x introduces more validation for queries, especially those involving @ManyToOne relationships. Best Practice: * When writing custom queries using @Query or creat   ...

🚨 Addressing "Insufficient Data Written" Error in RestTemplate or WebClient

Image
Are you encountering the "Insufficient Data Written" error while using RestTemplate or WebClient in your Spring application? This error might occur due to various reasons, but one common root cause is passing incorrect or overridden headers, especially the Content-Length header. In the latest versions of Spring, specifically Spring 3.x and onwards, there's a change in behavior regarding how the Content-Length header is handled when making HTTP requests. Previously, in Spring 2.x, the library wo   ...

Ensuring Smooth Spring Boot Testing with Oracle-Style Queries in H2 Database

Image
Are you facing issues running Spring Boot tests due to Oracle-specific functions not being recognized in your H2 in-memory database? If so, you're not alone. Many developers encounter difficulties when testing Spring Boot applications that rely on Oracle-specific features like DUAL, SYSDATE, TO_DATE, or rownum. Fortunately, there's a straightforward solution that allows you to configure your H2 database to behave more like an Oracle database during testing. By setting the H2 mode to Oracle and   ...

Using H2 Memory Database to Test Applications with Oracle's 'SELECT sysdate FROM DUAL'

Image
Introduction: When developing applications that rely on Oracle databases, it's common to use the sysdate function along with the DUAL table to retrieve the current date and time. However, when writing tests for these applications, you may encounter challenges due to the Oracle-specific syntax. In this post, we'll discuss how to use H2 memory database to test applications that use SELECT sysdate FROM DUAL. Using H2 Memory Database for Testing: H2 is an in-memory database that provides compatib   ...

Handling Reserved Keywords in SQL Statements

Image
Introduction: When writing SQL statements, you may encounter situations where your identifiers clash with reserved keywords of the database system you're using. This can lead to errors when creating tables or executing queries. In this post, we'll explore how to handle reserved keywords in SQL statements for some of the most popular database systems: Oracle, MS SQL Server, MySQL, H2 and PostgreSQL. 1. Oracle: Oracle handles reserved keywords by enclosing identifiers that clash with keywords i   ...