Easy Batch - logo

How I reduced my Java batch application’s code by 80% using Easy Batch!

In this post, I will show how can Easy Batch tremendously simplify your batch applications by reducing plumbing code considerably. This will make your applications code more readable, understandable and maintainable!

The use case is a typical production application that loads data from an input CSV flat file to a database. Continue reading

Hibernate logo

A beginner’s guide to JPA/Hibernate flush strategies

Introduction

In my previous post I introduced the entity state transitions Object-relational mapping paradigm.

All managed entity state transitions are translated to associated database statements when the current Persistence Context gets flushed. Hibernate’s flush behavior is not always as obvious as one might think. Continue reading

Hibernate logo

A beginner’s guide to JPA/Hibernate entity state transitions

Introduction

Hibernate shifts the developer mindset from SQL statements to entity state transitions. Once an entity is actively managed by Hibernate, all changes are going to be automatically propagated to the database.

Manipulating domain model entities (along with their associations) is much easier than writing and maintaining SQL statements. Without an ORM tool, adding a new column requires modifying all associated INSERT/UPDATE statements.  Continue reading

JS-logo

Javascript for Java Developers

This post will go over the Javascript language from the point of view of a Java developer, focusing on the differences between the two languages and the frequent pain points. We will go over the following:

  • Objects Only, No Classes
  • Functions are just Values
  • The ‘this’ Keyword
  • Classic vs Prototypal Inheritance
  • Constructors vs Constructor Functions
  • Closures vs Lambdas
  • Encapsulation and Modules
  • Block Scope and Hoisting

Continue reading

Spring Batch Logo

Spring Batch Tutorial with Spring Boot and Java Configuration

I’ve been working on migrating some batch jobs for Podcastpedia.org to Spring Batch. Before, these jobs were developed in my own kind of way, and I thought it was high time to use a more “standardized” approach. Because I had never used Spring with java configuration before, I thought this were a good opportunity to learn about it, by configuring the Spring Batch jobs in java. And since I am all into trying new things with Spring, why not also throw Spring Boot into the boat… Continue reading

Apache server logo

How to use the new Apache Http Client to make a HEAD request

If you’ve updated your Apache HTTP Client code to use the newest library (at the time of this writing it is version 4.3.5 for the httpclient and version 4.3.2 for httpcore) from the version 4.2.x you’ll notice that some classes, like org.apache.http.impl.client.DefaultHttpClient or org.apache.http.params.HttpParams have become deprecated. Well, I’ve been there, so in this post I’ll present how to get rid of the warnings by using the new classes. Continue reading

Find the bug

SMTPSendFailedException “Invalid HELO name” – Spring Batch with Spring Boot

If you find yourself getting the following errror, when trying to send an email in Java:

com.sun.mail.smtp.SMTPSendFailedException: 550 Access denied – Invalid HELO name (See RFC2821 4.1.1.1)

and cannot figure out why does it not work?!, EVEN THOUGH you can send emails via Telnet using the same configuration as the one set up for the Java client or you set the mail.smtp.localhost property to the  fully qualified domain name (FQDN) of the client host – that might be IP address of the client host -  as suggested in the JavaMail API FAQ… THEN it might be that you are using an old version of the java mail api. Continue reading

spring xml 2 java config

VelocityEngine Spring Java Config

This is a first post in a series of short code snippets that will present the configuration of Spring beans from XML to Java.

XML:

Java: Continue reading

Email with Spring and Velocity

How to compose html emails in Java with Spring and Velocity

In this post I will present how you can format and send automatic emails with Spring and Velocity. Spring offers alone the capability to create simple text emails, which is fine for simple cases, but in typical enterprise application you wouldn’t want to do that for a number of reasons:

  • creating HTML-based email content in Java code is tedious and error prone
  • there is no clear separation between display logic and business logic
  • changing the display structure of the email requires writing Java code, recompiling, redeploying etc

Typically the approach taken to address these issues is to use a template library such as FreeMarker or Velocity to define the display structure of email content. For Podcastpedia I chose Velocity, which is a free open source Java-based templating engine from Apache. In the end my only coding task will be to create the data that is to be rendered in the email template and sending the email.

Continue reading

wordpress logo

How to add Categories to menu in WordPress

In this post I will present how to quickly add a “Categories” entry to the menu of a WordPress standard theme. Because I am by no means an expert in WordPress and PHP yet, I wanted to avoid having to customize anything.

So here’s the trick:

In the Dashboard > Appearance > Menus section add a new entry under Links with the URL set to “#” and Link Text set to “Categories”. Once you’ve done click Add to Menu and then from Categeories pull and drop in the Menu Structure the ones you want displayed as sub-items under the newly created entry.

Continue reading