May 14, 2008

IBM - DB2 - Blobs - Hibernate - Truncating - Yikes!

Every project has its caveats but those that use DB2 have the omen!
Yes kids, it's rant time. Why do IBM must make developers lives through out the world so miserable? To the hell with bloated enterprise software.
After wasting time trying to figure out why Hibernate was having problems inserting blobs into DB2, our team realized the obviousness: blobs must have their size defined, no duh!

So imagine a domain object that reads:

@Entity
public class Image {
@Id @GeneratedValue(strategy = GenerationType.AUTO)
private Long id
@Lob
private byte[] image;
}

To work in IBM/DB2 land it must read:

@Entity
public class Image {
@Id @GeneratedValue(strategy = GenerationType.AUTO)
private Long id
@Lob @Column(length = 1000000)
private byte[] image;
}

And pray that your bytes don't get to big or you'll need to recompile your domain.

No comments:

Post a Comment