Bo Andersen
I am a back-end web developer with a passion for open source technologies. I have been a PHP developer for many years, and also have experience with Java and Spring Framework. I currently work full time as a lead developer. Apart from that, I also spend time on making online courses, so be sure to check those out!
Posts by Bo Andersen
Mapping Smallint, Tinyint or Int Column to Boolean in Hibernate
If you have a column in your database which may only contain the value 0 or 1 (i.e. a bit value), you probably want to map it to the boolean static type in your entity, rather than an integer. This could be the case for smallint, tinyint(1), int(1), boolean columns, etc. I found two suggestions… read more
Return Boolean Value from Spring Data JPA Query
Did you know that you can return a boolean value from a Spring Data JPA query? For instance, you may want to know whether or not an entity (i.e. database row) exists with a given value for a field. Surely one could simply return the row count and check if it is larger than zero, but… read more
Updating Entities with Update Query in Spring Data JPA
With object-relational mapping (ORM) tools such as Hibernate, one usually modifies entities by first fetching them from the database, modifying some fields, and then persisting the entities again. This is a good approach in many cases, but in some scenarios this may not be desirable. For instance, if you want to update a collection of entities (i.e.… read more
Fetch Query not working in Spring Data JPA with Pageable
I recently had a problem with one of my Spring Data JPA queries; for some reason, I was getting the following exception. query specified join fetching, but the owner of the fetched association was not present in the select list This seemed strange, because I had written a standard JPQL/HQL query that I knew worked.… read more
Convert Byte Array to String in C#
Converting a byte array to a string in C# is easy. In fact, it can be done in a single line. Below is an example that converts a string into a byte array. In the example that follows, we will then convert that byte array back to a string, effectively showing you how to do the… read more
Share Session Cookies between Subdomains with Tomcat
In order to share session cookies between subdomains in your Java web application hosted with Apache Tomcat, you need to make a simple configuration change. What you simply need to do is to make a small change to your web application’s context. You might have more than one context if you have more than one… read more
Installing Tomcat 8 on OS X Yosemite
Installing Tomcat 8 on OS X Yosemite is actually quite easy. One can do it with the help of Homebrew or MacPorts, but I prefer to do it “by hand”. All you have to do is to follow the steps below. First, head over to the Apache Tomcat download page and download the core binary distribution… read more
Enabling Spring Bean for Multiple Profiles
This is going to be a quick one. I just want to show you how one can define a bean in Spring Framework for multiple profiles. That is, the bean will be “active” if the active profile is one in a given list. This is for example useful if you want different beans to be available at… read more
Ignoring Unrecognized JSON Fields With Spring & Jackson
If you try to bind JSON to an object in Spring MVC with Jackson, then you might have seen the below error before. Could not read JSON: Unrecognized field \”something\” (class com.codingexplained.user.dto.account), not marked as ignorable […] This error occurs whenever an unknown field is encountered in the JSON; that is, a field specified in the JSON is not… read more
Moving .ebextensions to root in .war file
If you wish to deploy your application to Amazon’s Elastic Beanstalk, then you can customize your server setup by placing configuration files within a .ebextensions directory within the root of your .war file (for web applications). These files can then contain various kinds of instructions. One can install packages with package managers such as yum or… read more