Category: Programming Language
-
Neo4j: Playing with Cypher Query Language
PROBLEM Every week, my shitty coworkers struggle to reach consensus on where to go for lunches and what beverages to order in the morning. SOLUTION To further understand the phenomenon of this first world problem, here’s a shitty graph database powered by Neo4j to visualize the love/hate relationship between my shitty coworkers and the shitty Read More…
-
Spring Data Neo4J: Requested a entity of type ‘X’, but the entity is of type ‘Y’
PROBLEM Let’s assume we have a node entity like this:- When saving this entity, we get this exception:- SOLUTION This problem occurs because relationship likes is being used by both Restaurant entity and Beverage entity. To fix it, we need to enforce the target type. Read More…
-
Maven Archetype Plugin: Velocity Variable Substitutions Not Resolving
PROBLEM Let’s assume we have the following package.json in our archetype:- When creating a project from this archetype, the Velocity variable substitution for ${rootArtifactId} doesn’t resolve at all. SOLUTION After reading Maven Archetype Plugin’s source code here and here, the Velocity variable substitutions are only performed on the following file extensions:- In another word, if Read More…
-
Maven Archetype Plugin: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.3:create-from-project
PROBLEM When running mvn archetype:create-from-project with Maven Ear Plugin defined under <pluginManagement>…. … the following exception occurs… SOLUTION It appears this problem happens when using Maven Archetype Plugin 2.3, but works fine when using 2.2. To fix this, define an empty <modules> under <configuration> to prevent NullPointerException. Read More…
-
Maven: Skinning Generated Site
PROBLEM The default Maven generated site looks like web pages created in the 80s:- SOLUTION The good news is Maven allows us to change the skin. To use one of these pre-defined skins, create site.xml at this location:- In site.xml, enter the following:- In the above example, we use Maven Fluido Skin. In Maven 3, Read More…
-
Java: Builder for Immutable POJO
PROBLEM Let’s assume we have an immutable Person object:- … and an immutable Car object:- To create the Person object, we need to write something like this:- If the POJO has a lot of properties, it becomes very difficult to keep track all the constructor argument positions. SOLUTION @mkarneim wrote a POJO Builder that creates Read More…