Chapter 6. Advanced Concepts
In the previous chapters, you learned about the basics of Hibernate. Hibernate is a feature-rich ORM framework, so a discussion of all its offerings would take reams of paper. However, there are a few features that are important for any developer working with Hibernate to understand. This chapter describes the features that are particularly useful if you are looking to get more out of your framework. The concepts discussed here will enable you to extend the framework to suit your application needs.
Hibernate Types
In our mapping files, we declared the mapping of an objectâs property to a table column as property column="COLOR" name="color"
. However, how does Hibernate know the COLOR
column is a VARCHAR and the color property is a String
type?
Well, Hibernate uses Javaâs reflection to find out the type of the property. Although this option of omitting the types works out fine, the preferred and recommended option is to set the types on the properties implicitly. Setting property column="COLOR" name="color" type="string"
explicitly will easily give Hibernate the propertyâs type.
Did you notice that we declared the type of the color property as string
but not String
? The string
type is neither a Java type nor a SQL type; in fact, it is Hibernateâs own type. Hibernate has extensive support for types, including built-in types such as string, boolean, and integer, as well as our own predefined custom types.
Entity and Value Types
Types are essentially ...
Get Just Hibernate now with the O’Reilly learning platform.
O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.