Category Archives: Java

Use SpringBoot to Deploy ActiveMQ Broker to Tomcat 1/3

This topic has three parts. Also See part2 in next post and part3. ActiveMQ can be installed as a standalone server, or it can run within other containers, such as Spring or web containers. When deploying in Tomcat, you have the options of … Continue reading

Posted in Java | Tagged , , , , | 2 Comments

Cleanup Stale Hibernate Session in Tomcat

Problem: When Hibernate is configured to use thread based session management, a thread may get stuck (unable to unbind) with a closed session under certain condition, therefore all subsequent incoming HTTP calls assigned to such a thread would fail until … Continue reading

Posted in Database, Java | Tagged , , , , | Leave a comment

Gradle Task to Validate Clover On OFF Comment

One way to tell Clover to skip instrumentation of a chunk of code is to enclose the code with “/// CLOVER:OFF” and “/// CLOVER:ON”. For example, you may want to skip the JMockit expectation and verifications chunks. /// CLOVER:OFF new … Continue reading

Posted in Build, Java, Tool and Debug | Tagged , , , , , | Leave a comment

Yukes! The Space in @WebParam

Today I really got a bite after so many years in web application coding. It is the extra space character in the @WebParam. Problem I had a working soap based webservice API then decided to add a new parameter to … Continue reading

Posted in Java | Tagged , , , , | Leave a comment

Open H2 UI When Debugging in Eclipse

This time it is about debugging the H2 embedded database, which is very similar to procedure used with the HSQLDB I posted earlier. Assuming that the hibernate.connection.url is set to jdbc:h2:mem:myDb, you can following similar steps as in my previous … Continue reading

Posted in Database, Java, Tool and Debug | Tagged , , , , | Leave a comment

Hibernate Formula Annotated Field Behaviors

When the @Formula annotation is used to create a virtual column (in object model but not in database), developers should be aware of some behaviors to avoid of any pitfalls. This post uses the source code here to demonstrate these … Continue reading

Posted in Database, Java | Tagged , , , | Leave a comment

Use Hibernate Query Language to Join Tables and Map Column Values to Java Objects

The following example creates a HQL statement with named parameters, executes the query then maps the query result back to Java objects. The two named parameters in the example are accountNumber and trackingId. The three selected columns are unitPrice, qty … Continue reading

Posted in Database, Java | Tagged , | Leave a comment