The Hibernate type system 5.2.3 Using mapping types All of the basic mapping types may appear almost anywhere in the Hibernate mapping document, on normal property, identifier property, and other mapping elements. The ,
, , , and elements all define an attribute named type. You can see how useful the built-in mapping types are in this mapping for the BillingDetails class:
…. The BillingDetails class is mapped as an entity. Its discriminator, identifier, and name properties are value typed, and we use the built-in Hibernate mapping types to specify the conversion strategy. It isn t often necessary to explicitly specify a built-in mapping type in the XML mapping document. For instance, if you have a property of Java type java.lang.String, Hibernate discovers this using reflection and selects string by default. We can easily simplify the previous mapping example:
…. Hibernate also understands type=”java.lang.String”; it doesn t have to use reflection then. The most important case where this approach doesn t work well is a java.util.Date property. By default, Hibernate interprets a java.util.Date as a timestamp mapping. You need to explicitly specify type=”time” or type=”date” if you don t wish to persist both date and time information. With JPA annotations, the mapping type of a property is automatically detected, just like in Hibernate. For a java.util.Date or java.util.Calendar property, the Java Persistence standard requires that you select the precision with a @Temporal annotation:
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.
This entry was posted
on Tuesday, January 1st, 2008 at 5:33 am and is filed under PHP5.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.