O'Reilly logo

Just Hibernate by Madhusudhan Konda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 categorized ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required