Ce contenu n'est pas disponible dans la langue sélectionnée.
5.2.2. Basic value types
The built-in basic mapping types can be roughly categorized into the following:
integer, long, short, float, double, character, byte, boolean, yes_no, true_false- Type mappings from Java primitives or wrapper classes to appropriate (vendor-specific) SQL column types.
boolean, yes_noandtrue_falseare all alternative encodings for a Javabooleanorjava.lang.Boolean. string- A type mapping from
java.lang.StringtoVARCHAR(or OracleVARCHAR2). date, time, timestamp- Type mappings from
java.util.Dateand its subclasses to SQL typesDATE,TIMEandTIMESTAMP(or equivalent). calendar, calendar_date- Type mappings from
java.util.Calendarto SQL typesTIMESTAMPandDATE(or equivalent). big_decimal, big_integer- Type mappings from
java.math.BigDecimalandjava.math.BigIntegertoNUMERIC(or OracleNUMBER). locale, timezone, currency- Type mappings from
java.util.Locale,java.util.TimeZoneandjava.util.CurrencytoVARCHAR(or OracleVARCHAR2). Instances ofLocaleandCurrencyare mapped to their ISO codes. Instances ofTimeZoneare mapped to theirID. class- A type mapping from
java.lang.ClasstoVARCHAR(or OracleVARCHAR2). AClassis mapped to its fully qualified name. binary- Maps byte arrays to an appropriate SQL binary type.
text- Maps long Java strings to a SQL
CLOBorTEXTtype. serializable- Maps serializable Java types to an appropriate SQL binary type. You can also indicate the Hibernate type
serializablewith the name of a serializable Java class or interface that does not default to a basic type. clob, blob- Type mappings for the JDBC classes
java.sql.Clobandjava.sql.Blob. These types can be inconvenient for some applications, since the blob or clob object cannot be reused outside of a transaction. Driver support is patchy and inconsistent. -
imm_date, imm_time, imm_timestamp, imm_calendar, imm_calendar_date, imm_serializable, imm_binary - Type mappings for what are considered mutable Java types. This is where Hibernate makes certain optimizations appropriate only for immutable Java types, and the application treats the object as immutable. For example, you should not call
Date.setTime()for an instance mapped asimm_timestamp. To change the value of the property, and have that change made persistent, the application must assign a new, nonidentical, object to the property.
Unique identifiers of entities and collections can be of any basic type except
binary, blob and clob. Composite identifiers are also allowed. See below for more information.
The basic value types have corresponding
Type constants defined on org.hibernate.Hibernate. For example, Hibernate.STRING represents the string type.