JPA – How to use @Embeddable and @Embedded

In Java Persistence API (JPA), a class can either be an @Entity or a value type. If a class is an @Entity, it is a persistent class. It represents a database table (or set of tables). If a class is a value type, it is not a persistent class. It may not represent a database table or a set of database tables. It may be used as a reusable component whose properties are used across multiple tables.

Kotlin Enum examples

When we have a fixed set of predefined constants, it is considered a good practice grouping them in an enum type.

Should you use Mockito thenReturn or thenAnswer?

Should you use Mockito thenReturn or thenAnswer? It depends! The thenReturn returns the same value in every method run; while the thenAnswer does not. We use the former to return hard-coded values; while we use the latter for derived values.

Kotlin – Read file line by line from Classpath

This post shows how to leverage Java libraries (from our underlying JVM) to read file line by line from classpath using Kotlin. Also, IntelliJ IDE is used for this post but can easily be replicated in Eclipse.

Mock methods that return void

Previously, I posted Void methods and Mockito in Java that verifies if any of the methods of a object passed as a argument were invoked. This time we want to alter the behavior of a method that returns void.