Hibernate: A Developer's Notebook

Errata for Hibernate: A Developer's Notebook

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
Printed
Page 000
generic

To get the ant build to work with Hibernate 3 the codegen and schema targets need to be replaced. Here are the Hibernate 3 versions (the hbm2java and schemaexport tasks should be removed). <taskdef name="9780596006969tool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="project.class.path"/> <target name="codegen"> <9780596006969tool destdir="${source.root}"> <configuration> <fileset dir="${source.root}"> <include name="**/*.hbm.xml"/> </fileset> </configuration> <hbm2java/> </9780596006969tool> </target> <target name="schema" depends="compile"> <9780596006969tool destdir="${class.root}"> <configuration> <fileset dir="${class.root}"> <include name="**/*.hbm.xml"/> </fileset> </configuration> <hbm2ddl drop="false" delimiter=";"/> </9780596006969tool> </target> In addition doctypes should be changed to match the new Hibernate domain as follows: <!DOCTYPE 9780596006969-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://9780596006969.sourceforge.net/hibernate-mapping-3.0.dtd"> (and equivalent for other xml documents). Other changes are needed to the Java code, mostly related to transactions now being required for read operations as well as write operations and package moves from net.sf to org.9780596006969. ------------------ AUTHOR'S COMMENTS: ------------------ Yes, the book will not work with Hibernate 3, unfortunately. Hibernate has changed radically, and HSQLDB significantly, since the book was written. These fixes will help, but a new edition would be required to recapture the "type this in and it works" magic that was intended, and available at publication time. Alas, things would then change again. Printed books can't keep up with rapidly evolving projects like this.

Anonymous   
Printed
Page back cover

the URL for oreilly.com is incorrect! ww.oreilly.com should be: www.oreilly.com

Anonymous   
Printed
Page 11
top

Although this isn't a problem with the book itself, a couple of readers have written to me to report difficulty running the "quick test" example in the first chapter. When they invoke "ant db", they get the error "java.lang.NoClassDefFoundError: java/sql/Savepoint" instead of seeing the HSQLDB GUI. After some investigation, it appears that the problem is in version 1.7.2 of HSQLDB. The developers seem to have inadvertently introduced a dependency on version 1.4 of the Java SDK (the SavePoint class was only introduced in Java 1.4). If you are using version 1.3 of the Java SDK with current HSQLDB releases, you will run into this problem. If you need to use a current release of HSQLDB with Java 1.3, you will need to compile it from source yourself, as explained by the maintainer of the HSQLDB project: HSQLDB 1.7.2 jar is compiled with 1.4.2 and due to the use of the new SavePoint class, cannot be used as-is with JDK 1.3.x or earlier. However, if the sources are compiled and jar'ed with JDK 1.3.x, then the resulting jar will be compatible with JDK 1.x - JKD 1.4.x but will lack the newer JDBC methods that were introduced in JDK 1.4.x. See the HSQLDB Guide, Appendix A.

Anonymous   
Printed
Page 15
Example 2-1, Line 30

<property name="volume" type="short"> should be: <property name="volume" type="short" not-null="true"> AUTHOR NOTE: The code generation tool in the Hibernate extensions now respects the not-null property of mappings when generating code. Because of this, it won't generate properties with native (non-reference) types like short or integer if the property might be null, because only reference (object) types like Short and Integer can be null in Java. This change causes the code examples to fail to compile, because they expect the Track object to take a short value in the constructor rather than a Short object. (Java 5.0's autoboxing feature works around this problem, but people using older versions of Java will need to add the above attribute to the volume mapping.) The same problem comes up in a couple of other properties later in the book; the downloadable code examples have been updated to fix all these cases, as described in the included release notes.

Anonymous   
Printed
Page 22
Line 128, and second body paragraph

Hibernate version 2.1.4, which was released after printing, has changed its behavior so that by default the equals() and hashCode() methods are no longer generated. If you want these methods to be generated as shown in the book, you need to add another "meta" attribute to the class definition, setting the attribute "implement- equals" to the value "true". For example, in the mapping document Track.hbm.xml (on page 15), you could add a new line 12, with the following content: <meta attribute="implement-equals">true</meta> This would cause the generated code to revert to what it looked like in Hibernate 2.1.3, as printed in the book.

Anonymous   
Printed
Page 25
Example 2-4

Need to add: 9780596006969.connection.shutdown=true to the 9780596006969.properties for TRACK table to be successfully created with recent versions of hsqldb. From version 1.7.2, hsqldb does not shut down the database when there are no more connections to it. Without this shutdown, changes are not flushed and the DDL creating the track is not written to disk. See: http://forum.9780596006969.org/viewtopic.php?t=940532&sid=d2b5fdb069a0c574dbfd802727f568e5 ------------------ AUTHOR'S COMMENTS: ------------------ This isn't a technical mistake, it's a change in the way HSQLDB works. In fact, I was the one who posted the solution in the forum thread to which you linked. :) O'Reilly folks, we need a new kind of markup for situations like this, in which the technology has changed since the book was written.

Anonymous   
Printed
Page 61
Example 4-4

In the second section of the log output: ARTIST_ID is misspelled

Anonymous   
Printed
Page 68
in the notes on the left side

"...through a user interface, or as part of the process of importing the actual". NOW READS: "...through a user interface, or as part of the process of importing the actual music".

Anonymous    Aug 01, 2004
Printed
Page 76

people working with Oracle will want to use a column name other than COMMENT, since "COMMENT" is a reserved word for Oracle.

Anonymous   
Printed
Page 76
2nd paragraph

Sentence reads: "The new mapping in Tracks.hbm.xml looks a lot ..." and should read: "The new mapping in Track.hbm.xml looks a lot ..."

Anonymous   
Printed
Page 84
source code listing at the top of the page

position is not an allowed fieldname for a column in hsqldb When HSQLDB 1.7.2 is final, more people are likely to run into this issue. They should modify the mapping in Example 5-2 to use "POS" or some other variant instead of "POSITION" in order to avoid this problem.

Anonymous   
Printed
Page 100
All of Chapter 6

The PersistentEnum interface chapter 6 is based on has been deprecated in the latest versions of Hibernate. AUTHOR: Post-publication, the authors of Hibernate came to the same conclusions I did in this chapter, and have deprecated this approach in favor of better alternatives. You can still compile this code to see how it works (the deprecation warnings won't interfere with operation), but you may just want to skim through it and focus on the better approach I came up with at the start of Chapter 7.

Anonymous   
Printed
Page 118
What about.. section, first sentence

...More complicated custom type mappings, such as splitting single properties into multiple database columns, or single columns into multiple properties? should be: ...More complicated custom type mappings, such as splitting single columns into multiple properties?

Anonymous