Chapter 8 introduces Criteria Queries. Only QueryTest.java is affected. Besides the usual net.sf.hibernate to org.hibernate package import renaming, net.sf.hibernate.expressions in Hibernate 2 is replaced by org.hibernate.criterion. Moreover, change the line [java] Example example = Example.create(new Artist(namePattern, null, null)); [/java] to [java] Artist artist = new Artist(); artist.setName(namePattern); Example example = Example.create(artist); [/java] because Hibernate 3…
Schlagwort: Bücher
Chapter 7 is working in Hibernate 3 (as opposed to chapter 6). The most challanging in this chapter migrationwise are StereoVolumeType.java and SourceMediaType.java . Change the import-package names. The Usertype-stuff is now under the package „org.hibernate.usertype“. It won’t compile, yet as there are some methods missing. For SourceMediaType.java: [java] public Object replace(Object original, Object target,…
You can skip the entire chapter 6 if you use Hibernate 3. It is based on the interface PersistenceEnum which already became deprecated in Hibernate 2 as the author points out in the errata. The interface has apparently removed in Hibernate 3.
As in chapter 4, copy the hbm.xml-files and change the DTD-reference. Leave CreateTest.java, QueryTest.java and QueryTest2.java alone – they will still compile. Copy the AlbumTest.java file, change the hibernate-imports and the constructor calls as well as int parameters to Integer. This should be easy as we have done that before.
In this chapter, we add an Entity called „Artist“ as well as an entity called „Comments“. Copy both Track.hbm.xml and Artist.hbm.xml from the examples-distribution and remember to change the DTD-reference if necessary. When using „ant schema“, SAX complained it couldn’t find ${src.root}/com/oreilly/hh/hibernate-mapping-2.0.dtd for Artist.hbm.xml. That’s strange because it didn’t complain about it in Track.hbm.xml before.…
In chapter 3 (you can read it online) we use the Track table to insert some data and to query data. We use CreateTest to create and QueryTest to query data. Some simple adaptions are necessary: change package name of hibernate classes to org.hibernate replace the use of the all-attributes-as-parameters-constructor with Java-Bean style use of…
This is chapter 2 of rewriting the examples of O’Reillys book „Hibernate – A Developers Notebook“ for using Hibernate 3.0 instead of Hibernate 2.x . To get the context, read chapter 1. The goal of chapter 2 is to write a hbm file for a single table, generating the corresponding java file and compile it.…
In this blog series I want to go through the examples in James Elliotts book „Hibernate – a developers notebook“ using object/relation mapping service Hibernate 3.0 instead of Hibernate 2.x that this book was written about and noting the differences, i.e. what I had to change to get them working. I enjoyed reading „Hibernate -…