Spring Batch - Imperfect Yet Worthwhile

Continue Reading January 23rd, 2012 Jeff Zapotoczny

A lot of folks have used the Spring framework to build applications - and what’s not to love? It’s allowed us to solve enterprise problems with a minimum of tedium. And the framework has evolved to address criticisms, for example the continued reduction in need for lengthy XML configuration in application contexts in favor of ever more terse syntax and support for code annotations.

The framework as-packaged includes facilities to help with many common aspects of contemporary application development, from a Model-View-Controller (MVC) framework to  integration with persistence managers and elegant transaction management. But it doesn’t necessarily cover every need. One example of a gap is batch processing.

Continue Reading 6 comments

Four Java Surprises!

Continue Reading December 5th, 2011 Prem Nagrath

Here are four things in Java that might surprise you:

Polymorphism doesn’t work the way you might expect. For example, consider subtype polymorphism with Generics. To elaborate, even though B is a subtype of A, and it is perfectly valid to say:

Continue Reading 6 comments

Using Page Objects with Selenium and Web Driver 2.0

Continue Reading October 10th, 2011 James Cox

The Page Objects design pattern is outlined in the Selenium wiki, but to summarize, Page Objects are meant to encapsulate the messy internal state of a page. Changes in the presentation code should only require changes only to the Page Objects, not to the actual test code. Using a Page Object promotes consistency; there may be five different ways to legitimately determine that you are on the login page, but adhering to the one definition in the Page Object will prevent you from having to maintain the other variants.

Page Objects should be ignorant of an application’s business logic, they should only be aware of page state and how to interact with it. By clearly delineating the test code from the page objects, you will be able to use the same page objects in a variety of tests cases and achieve code re-use.

Continue Reading 3 comments

Setting Up Sequential IDs using JPA @TableGenerator

Continue Reading July 29th, 2011 Mitch Goldstein

When using the Java Persistence Architecture (JPA) to perform object-relational mapping, it can become difficult to manage entities with complex keys.  Having a unique identifier is a keystone of the mapping approach, and complex keys can make coding awkward and difficult.  An alternative is to create entities with sequential unique numeric keys, and use the capabilities of the query facility to identify unique entities within the relational store.

JPA has several techniques to generate unique keys for entity objects.  This article focuses on one technique: using a database table to keep track of an incremental ID.  The @TableGenerator annotation is used to facilitate this feature.

Continue Reading Add comment

Modeling Reference Data in the Application Tier

Continue Reading July 25th, 2011 Ben Northrop

In every enterprise application, there exists reference data - those simple entities that live on the periphery of your data model, and are used to classify your master data. We often know these entities by other names (depending on our point of view), for instance “lookup tables”, “configuration data”, etc. - examples being “State”, “CustomerType”, or “ProductType”.

Now there are some strong reasons to model these entities in separate tables in your relational database, and there is generally not much debate here. Where things get a little tricky is when this reference data propagates up into the application tier. In my experience, developers employ a number of different strategies to solve this problem, and so in this post I’ll define some of the more popular approaches and describe the pros and cons of each. As always, I’d love to hear your thoughts, so please share. Here goes…

Continue Reading 6 comments

Tweaking Persistence with @PrePersist

Continue Reading June 13th, 2011 Mitch Goldstein

It is an interesting problem: even though the Java primitive double type has plenty of precision, math operations using this type can prove problematic when it comes to using them for precision calculations.  Due to the nature of how floating point numbers are stored, they are by definition inaccurate.  This is a consequence of trying to store decimals - especially fractional decimals - in a binary format.

To address some of these issues, the Java development team released the java.math.BigDecimal class.  This is an immutable class that extends the abstract class java.lang.Number, which serves as the superclass of  the primitive wrapper classes such as java.lang.Double and java.lang.Integer.  The primary purpose of this base class is to provide methods that allow conversion among different number types.

Continue Reading 5 comments

Dr. Mindbender, Or How I Learned To Stop Worrying And Love Hibernate

Continue Reading June 7th, 2011 Steve Ayers

I’ll admit I was wrong.

For years, I have been beating the drum about town, proselytizing my distaste for Hibernate. I told everyone that would listen what my opinions were. ‘It only gets in the way’, I said. ‘Its too much of a black box’.

And while some of those notions still hold true, I am here today to admit I was wrong in that Hibernate is not a total obstacle of a framework. In the right situations and circumstances, it actually is very nice to have on your side. In the wrong situations, however, it is a nightmare. It is not something that can be forcefed into every situation and while it has its benefits, using it in the wrong project will provide nothing but heartache. Trust me, I know from experience. It is the Dr. Mindbender of frameworks: use it where it should be and it’s a peace-loving orthodontist. Misuse it and you have a hateful, deceitful villain with a proclivity for cybernetics and brain-scrambling.

Continue Reading 10 comments

12 things I learned about consulting in 12 months (Part 2)

Continue Reading May 27th, 2011 Zack Mance

I am back again to finish my top 12 list! I know, I know, Part 1 only had 5 items; but hey I saved the best 7 for last! Just to summarize, I am trying to give others out there who are new to the consulting world a view of my experiences from the first 12 months of being a consultant.

In my previous post my main focus was on camaraderie, and unexpected processes involved in development. In this part, I will focus on technology and work culture!

Continue Reading Add comment

Conundrum Solved: Odd Linkage Error in A4J

Continue Reading June 29th, 2010 Via Tsuji

Problem: Application began spewing out the following error when clicking on our Ajax-ified radio buttons:

java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "org.ajax4jsf.org.w3c.tidy.DOMNodeImpl.setUserData(Ljava/lang/String;Ljava/lang/Object; Lorg/w3c/dom/UserDataHandler;)Ljava/lang/Object;" the class loader (instance of com/ibm/ws/classloader/CompoundClassLoader) of the current class, org/ajax4jsf/org/w3c/tidy/DOMNodeImpl, and the class loader (instance of ) for interface org/w3c/dom/Node have different Class objects for the type

Continue Reading 2 comments

Conundrum Solved: Spring, JPA/Hibernate and WebSphere 7

Continue Reading May 12th, 2010 Via Tsuji

We have all been in projects where we use a combination of open source libraries, for different components of our architecture. We know theoretically that it should work, but alas, something blows up at runtime. If we’re lucky, we experience this on a weekly basis, but we don’t get lucky that often. The “Conundrum Solved” series will tackle some of these hair-pulling, sleep-depriving, grouch-inducing problems some of us at Summa have encountered in our projects. We hope that by sharing them with you, you’ll keep your hair, get enough sleep, and maintain a smile on your face!

Problem: Invalidly getting an InvalidStateObjectStateException thrown upon calling  merge(), even if there were no updates to the entity.

Continue Reading 9 comments

What’s the deal with Java equals() and hashcode()?

Continue Reading January 26th, 2010 Jeff Howell

I came across this issue a couple years ago. It was surprisingly not-so-obvious to the developer, a good developer, who was sorting out a very elusive bug in a large Java application.

The symptom was that a Map of objects sometimes returned null when queried. The developer ran the code in a debugger and could see that the object was put into the Map. Yet, when the map was asked to retrieve the object, it was not found (even though it could be seen by inspection in the debugger).

Other objects were successfully stored and retrieved from the same Map.

Continue Reading 1 comment

My Changes Don’t Happen! — A Java Puzzler

Continue Reading December 9th, 2009 Jim Kiley

A few weeks ago I ran into a Java problem that took me an embarrassingly long time to solve — I won’t even tell you how long it took me to notice the source of the bug. It’s a relatively common mistake for starting developers — and clearly it even happens once in a while to experienced guys who aren’t paying attention. I figured I would detail my problem in the hopes that someone else out there might run across this post and save themselves half an hour or more of combing through their code.

Continue Reading 4 comments

Using Code Metrics with Purpose

Continue Reading November 30th, 2009 Ben Northrop

I know plenty of developers who, at a tactical level, have had success with static source code analysis tools, using them to help find and root out bad code smells. When PMD tells us there’s an empty catch block at line 207, for instance, we know exactly what to do.

At an aggregate level, however, code metrics are seldom so helpful or straight-forward. When seeing that a source tree has 160,000 lines of code or an average cyclomatic complexity of 4.12, our first thought is usually “interesting!”…followed shortly by “well, now what?”.

The problem is, in my experience, we often look at our code metrics in isolation, without good comparison points, leaving us to wonder whether the numbers we see are big or small, typical or abnormal, good or bad. In the end, it’s not clear what to do, if anything.

Continue Reading Add comment

Handling JSF and Facelets exceptions

Continue Reading October 5th, 2009 Javier Ochoa

Say you need to hide internal application errors to your users in a friendly way and also notify the support staff of this exceptional condition. In this post you’ll find a way to do that in a JSF web app. The JSF flavor I’m using is Apache MyFaces 1.1 JSF implementation with the Tomahawk component which provides some extra functionality on top of JSF.

Continue Reading 2 comments

My Foray into Something Groovy

Continue Reading July 9th, 2009 Krister Schwertfuehrer

As is often the beginning of most anything we do, this story starts with necessity! Unfortunately for me, the necessity was caused by my own screw-up: I had to restore my wife’s computer from a backup and instead of giving files their original modified timestamp, I accidentally chose to set the timestamp to the current time! Well, now she lets me know how difficult it is to arrange our digital pictures into their appropriate months when the files are misdated!

Continue Reading Add comment

Previous Posts


Pages

Categories

Most Recent Posts

Feeds

  Subscribe in a reader

Calendar

February 2012
M T W T F S S
« Jan    
 12345
6789101112
13141516171819
20212223242526
272829  

Tags

Calendar

February 2012
M T W T F S S
« Jan    
 12345
6789101112
13141516171819
20212223242526
272829  

Posts by Month

Posts by Category