Blog Insights
Getting Started with Camel, Java, and Spring
At home and at work, I find that the things that I have to do over and over are the most painful. At home, it’s the dishes; at work, it reading data out of a file or doing Hibernate mappings. No matter what I do, I can’t seem to escape...Iterators, Functors and Predicates
In this post I am sharing different ways to create 'Custom Iterators' and how to control the behavior of that Iterator. Also part of this article focuses on how to apply different operations on a selected elements within a custom iterator. The way to do this is to implement a...Multi-Step Forms in Django
Forms in Django seem to be a relatively advanced topic if you want to do anything outside of models. Case in point: I had to develop a multi-step form in django that would spit out a certain result. There were only two forms that the user needed to fill out,...Code Quality Metrics with Sonar, Part I
I was fortunate to be able to attend the 2011 edition of No Fluff Just Stuff. One of my favorite presentations was by Matthew McCullough on Sonar. Hence, when the issue of code metrics was raised at a partner, Sonar seemed like the right tool to use. Our partner wanted to explore ways...Parallel Programming With Barrier Synchronization
Parallel Programming is an emerging computer science field that studies the opportunity of splitting data into small chucks and process them on multiple processors simultaneously which provides a faster execution time. Parallel programming is useful in sorting, image processing, network processing and may other memory intensive tasks. For parallel program execution...Injecting Spring Beans into Java Servlets
If you are working in a Java Web Application and you are using Spring IoC Container in your application, there is a chance that you might have to inject Spring Beans into a Java Servlet. Since there is not a direct way to inject Spring Beans into a Java Servlet, you...Static Caching in Drupal
If you’re a PHP veteran, then you know static caching is a relatively simple thing to do in PHP, but it can result in inconsistent behavior and sloppy code, such as adding an extra parameter to a function for the sole purpose of resetting that function’s internal cache. Drupal’s static caching...Hibernate Date vs Timestamp
I encountered a subtle hibernate mapping issue involving Dates and Timestamps. The following test recreates this issue. package com.sourceallies.logging; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.sql.Timestamp; import java.util.Calendar; import java.util.Date; import java.util.List; import javax.annotation.Resource; import org.apache.commons.lang.time.DateUtils; import org.hibernate.Criteria; import org.hibernate.SessionFactory; import org.hibernate.classic.Session; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.transaction.annotation.Transactional; import com.sourceallies.Person; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration @TransactionConfiguration(defaultRollback=false) public class HibernateDateTimeTest { @Resource ...Hibernate Logging
Through the years I've encountered a recurring requirement. Partners need to log changes to the database for auditing and legal purposes. To satisfy this requirement you could add logging to every save/update/delete call in your code. Or better yet, you could create an aspect that wraps these...Back to Basics: hashCode() & equals()
So we all know that if we implement equals() we must override hashCode() too. But why? The best explanation of this commandment can be found in Effective Java (2nd Edition) starting on page 45. If you're like me, you like to see a problem in running code....