Java

8 articles

Versioned Objects with Hibernate

Hibernate is a persistence framework for Java. Among the many perks it purports to bring to the table is automatic versioning for objects in the database. That is, when saving an object to the database, it increments a version number. Any process that attempts to store a different version of the... [More]

Sorting Generic Collections

One of the features we expect from a collections library is sorting. You should be able to use generic library mechanisms to sort a list of any kind of element. Most libraries include a generic sort function, to which a comparison functor (object or function pointer) is passed. This functor is... [More]

Wildcard Generics

As of version 1.5, Java has blessed its developers with generics, which increase expressiveness through improved static typing. With generics, Java programmers should be able to get away from the “casting orgy” to which Java programming heretofore typically devolved. The implementation in 1.5 does... [More]

Inherited Method Annotations

See Finding Conforming Methods for part one of this two-part article.

The problem we’re working on is as follows:

  1. Given an object, a method name and a list of parameters, execute the matching method on the given object.
  2. Determine from the object’s class whether the given method can be executed... [More]

Finding Conforming Methods

This is a two part post illustrating some tricks for working with the Java reflection API. Part two is available here.

Java reflection provides a wealth of information about your code. One interesting use of this information is to layer scriptability on top of an application, calling code... [More]

Immutable Collections

Java supports immutable collections of all kinds, but not in the way you would expect. A naive implementation would declare the immutable (unmodifiable in Java parlance) interface as follows[1]:

interface UnmodifiableList<T> {
  function T get();
  function int size();
}

There is no way to modify... [More]

Investigating Cayenne

Cayenne has nice-looking modeling tools and a decent API, but has other interesting limitations in their prefetching

Here are a few things I noticed about the framework:

  1. Their explanation of how many queries it takes to get a list of objects, each with 1-n sublink is confusing, at best. I expect... [More]

Drawbacks to Hibernate

The comment, Re: iBATIS vs Hibernate, offers some good advice for when to use iBATIS and when to use Hibernate. The damning sentence for Hibernate follows:

“If you try to shoehorn hibernate into a relational model created by a DBA who could care less about objects and thinks in terms of tables,... [More]”