Well, this may turn a number of you off and make you think I’m some sort of Luddite or something, but I have come to a considered opinion: I don’t really like Hibernate.
Before you consider me an ignorant fool, here are some of my reasons for you to consider (and I may add to this list over time): Read the rest of this entry »
No Comments »
Those of you who have used Hibernate probably know that the connection pooling solution c3p0 comes with it.
Pity.
C3p0 has a number of default settings that Hibernate does not allow you to control directly that are downright dangerous in a production environment: Read the rest of this entry »
No Comments »
One of the things I have always liked doing when working with Hibernate is to use a JUnit test to run SchemaValidator against the hibernate configuration. In case you aren’t familiar, the SchemaValidator that comes with Hibernate compares the beans, the database metadata, and the Hibernate configuration and throws an exception if any discrepancies are found. By calling it from a JUnit test, you can know immediately if someone has changed any of the three pieces and broke it.
Well, today I was trying to do just that with a Microsoft SQL Server database that had tables with uniqueidentifier columns. This is a MSSQL datatype for GUIDs of the form {12345678-9ABC-DEF0-1234-56789ABCDEF0}. There is no built-in Hibernate mapping specifically for this type, although using a String in the Java object works just fine–except when using the SchemaValidator. The SchemaValidator notices that the java field is mapped to “varchar” and the database field is of type “uniqueidentifier”, which of course doesn’t match. When I modified the .hbm.xml file to specify the types on both sides explicitly, the JDBC driver threw SQLExceptions that the types could not be converted.
Anyone have success with this?
No Comments »
I ran into a “gotcha” with Hibernate this past week.
I was working with an Oracle database where there are tables with synthetic (aka surrogate) keys that get their values from sequences — a fairly common thing, and a situation that Hibernate normally handles well with identity generator class of “sequence” or “native”.
But in this case, the Oracle database was using a before-insert trigger to get nextval from the sequence and stuff it into the primary key field before inserting the row into the table. The rationale for this was to ensure consistent management of the sequence for other code than the Hibernate/Java system that might hit the database.
Read the rest of this entry »
No Comments »
I’ve started a new (mostly) greenfield project recently and after two years of having to code in an existing application with a restrictive framework, I was eager to stretch my legs a bit and break out some of the good ol’ tools that made me so productive in previous gigs - XDoclet being one of them.
For those who don’t know, XDoclet is an open-source tool that lets you put special tags in your javadoc, which XDoclet finds in a post- or pre-compile step, and uses to generate more code, or configuration files, or whatever else you want to generate. Most frequently, XDoclet is used to generate deployment descriptors and helper classes to go with the most important classes of a system. Hibernate promotes (or at least, promoted) XDoclet as part of its suite of tools for easing configuration. Almost any book on Hibernate includes at least one chapter on using XDoclet to build your Hibernate configurations.
Read the rest of this entry »
No Comments »