kopf.lastig | Alles mögliche zu Themen wie Familie, Beruf, Medien etc. …

Nov/05

4

“Hibernate – A Developers Notebook” – migrating to Hibernate 3.0, Chapter 7

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:
  1.  
  2. public Object replace(Object original, Object target, Object owner)
  3.     throws HibernateException {
  4.  
  5.         return original;
  6.    }
  7.  
  8. public Serializable disassemble(Object value) {
  9.        return (Serializable) deepCopy(value);
  10.  }
  11.  
  12. public Object assemble(Serializable cached,
  13.                            Object owner)
  14.     {
  15.         // Our value type happens to be serializable, so we have an easy out.
  16.         return deepCopy(cached);
  17.     }
  18.  
  19. public int hashCode(Object o) { return o.hashCode(); }
  20.  

For StereoVolumeType.java:

JAVA:
  1.  
  2. public Object replace(Object original, Object target,SessionImplementor session,
  3.                       Object owner)
  4.     throws HibernateException {
  5.                    
  6.                    return deepCopy((StereoVolumeType)original);
  7.   }
  8.                
  9. public int hashCode(Object o) { return o.hashCode(); }
  10.  
  11. public Object replace(Object original, Object target, Object owner)
  12.                throws HibernateException {
  13.                    
  14.                    return original;
  15.  }
  16.  

That's it.

Im Web 2.0 mit anderen teilen:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • Add to favorites
  • DZone
  • email
  • FriendFeed
  • MisterWong.DE
  • MySpace
  • PDF
  • Reddit
  • RSS
  • Tumblr
  • Twitter

· ·

No comments yet.

Leave a Reply

<<

>>

Theme Design by devolux.nh2.me