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:
- public Object replace(Object original, Object target, Object owner)
- throws HibernateException {
- return original;
- }
- public Serializable disassemble(Object value) {
- return (Serializable) deepCopy(value);
- }
- public Object assemble(Serializable cached,
- Object owner)
- {
- // Our value type happens to be serializable, so we have an easy out.
- return deepCopy(cached);
- }
- public int hashCode(Object o) { return o.hashCode(); }
For StereoVolumeType.java:
- public Object replace(Object original, Object target,SessionImplementor session,
- Object owner)
- throws HibernateException {
- return deepCopy((StereoVolumeType)original);
- }
- public int hashCode(Object o) { return o.hashCode(); }
- public Object replace(Object original, Object target, Object owner)
- throws HibernateException {
- return original;
- }
That’s it.