5.4. Summary

In this chapter, you learned how inheritance hierarchies of entities can be mapped to the database with the four basic inheritance mapping strategies: table per concrete class with implicit polymorphism, table per concrete class with unions, table per class hierarchy, and the normalized table per subclass strategy. You've seen how these strategies can be mixed for a particular hierarchy and when each strategy is most appropriate.

We also elaborated on the Hibernate entity and value type distinction, and how the Hibernate mapping type system works. You used various built-in types and wrote your own custom types by utilizing the Hibernate extension points such as UserType and ParameterizedType.

Table 5.5 shows a summary you can use to compare native Hibernate features and Java Persistence.

Table 5-5. Hibernate and JPA comparison chart for chapter 5
Hibernate CoreJava Persistence and EJB 3.0
Supports four inheritance mapping strategies. Mixing of inheritance strategies is possible.Four inheritance mapping strategies are standardized; mixing strategies in one hierarchy isn't considered portable. Only table per class hierarchy and table per subclass are required for JPA-compliant providers.
A persistent supertype can be an abstract class or an interface (with property accessor methods only).A persistent supertype can be an abstract class; mapped interfaces aren't considered portable.
Provides flexible built-in mapping types and converters for value typed properties.There is automatic detection of mapping types, with standardized override for temporal and enum mapping types. Hibernate extension annotation is used for any custom mapping type declaration.
Powerful extendable type system.The standard requires built-in types for enumerations, LOBs, and many other value types for which you'd have to write or apply a custom mapping type in native Hibernate.

The next chapter introduces collection mappings and discusses how you can handle collections of value typed objects (for example, a collection of Strings) and collections that contain references to entity instances.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.151.126