alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Hibernate example source code file (Data_Categorizations.xml)

This example Hibernate source code file (Data_Categorizations.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Hibernate tags/keywords

a, a, book_entities, hibernate, hibernate, it, java, java, jdbc, the, the, they, types, y'/'y

The Hibernate Data_Categorizations.xml source code

<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "Hibernate_Development_Guide.ent">
%BOOK_ENTITIES;
]>
<chapter>
  <title>Data categorizations
  <para>
    Hibernate understands both the Java and JDBC representations of application data. The ability to read and write
    object data to a database is called <firstterm>marshalling, and is the function of a Hibernate
    <classname>type. A type is an implementation of the
    <interfacename>org.hibernate.type.Type interface. A Hibernate type describes
    various aspects of behavior of the Java type such as how to check for equality and how to clone values.
  </para>
  <note>
    <title>Usage of the word type
    <para>
      A Hibernate <classname>type is neither a Java type nor a SQL datatype. It provides information about
      both of these.
    </para>
    <para>
      When you encounter the term <firstterm>type in regards to Hibernate, it may refer to the Java type,
      the JDBC type, or the Hibernate type, depending on context.
    </para>
  </note>
  <para>
    Hibernate categorizes types into two high-level groups: <xref linkend="value-types" /> and 
    <para>
      A <firstterm>value type does not define its own lifecycle. It is, in effect, owned by an 
      <listitem>
      <listitem>
    </itemizedlist>

    <section id="value-basic-types">
      <title>Basic types
      <para>
        Basic value types usually map a single database value, or column, to a single, non-aggregated Java
        type. Hibernate provides a number of built-in basic types, which follow the natural mappings recommended in the
        JDBC specifications. You can override these mappings and provide and use alternative mappings. These topics are
        discussed further on.
      </para>
      <table>
        <title>Basic Type Mappings
        <tgroup cols="4">
          <thead>
            <row>
              <entry>Hibernate type
              <entry>Database type
              <entry>JDBC type
              <entry>Type registry
            </row>
          </thead>
          <tbody>
            <row>
              <entry>org.hibernate.type.StringType
              <entry>string
              <entry>VARCHAR
              <entry>string, java.lang.String
            </row>
            <row>
              <entry>org.hibernate.type.MaterializedClob
              <entry>string
              <entry>CLOB
              <entry>materialized_clob
            </row>
            <row>
              <entry>org.hibernate.type.TextType
              <entry>string
              <entry>LONGVARCHAR
              <entry>text
            </row>
            <row>
              <entry>org.hibernate.type.CharacterType
              <entry>char, java.lang.Character
              <entry>CHAR
              <entry>char, java.lang.Character
            </row>
            <row>
              <entry>org.hibernate.type.BooleanType
              <entry>boolean
              <entry>BIT
              <entry>boolean, java.lang.Boolean
            </row>
            <row>
              <entry>org.hibernate.type.NumericBooleanType
              <entry>boolean
              <entry>INTEGER, 0 is false, 1 is true
              <entry>numeric_boolean
            </row>
            <row>
              <entry>org.hibernate.type.YesNoType
              <entry>boolean
              <entry>CHAR, 'N'/'n' is false, 'Y'/'y' is true. The uppercase value is written to the database.
              <entry>yes_no
            </row>
            <row>
              <entry>org.hibernate.type.TrueFalseType
              <entry>boolean
              <entry>CHAR, 'F'/'f' is false, 'T'/'t' is true. The uppercase value is written to the database.
              <entry>true_false
            </row>
            <row>
              <entry>org.hibernate.type.ByteType
              <entry>byte, java.lang.Byte
              <entry>TINYINT
              <entry>byte, java.lang.Byte
            </row>
            <row>
              <entry>org.hibernate.type.ShortType
              <entry>short, java.lang.Short
              <entry>SMALLINT
              <entry>short, java.lang.Short
            </row>
            <row>
              <entry>org.hibernate.type.IntegerTypes
              <entry>int, java.lang.Integer
              <entry>INTEGER
              <entry>int, java.lang.Integer
            </row>
            <row>
              <entry>org.hibernate.type.LongType
              <entry>long, java.lang.Long
              <entry>BIGINT
              <entry>long, java.lang.Long
            </row>
            <row>
              <entry>org.hibernate.type.FloatType
              <entry>float, java.lang.Float
              <entry>FLOAT
              <entry>float, java.lang.Float
            </row>
            <row>
              <entry>org.hibernate.type.DoubleType
              <entry>double, java.lang.Double
              <entry>DOUBLE
              <entry>double, java.lang.Double
            </row>
            <row>
              <entry>org.hibernate.type.BigIntegerType
              <entry>java.math.BigInteger
              <entry>NUMERIC
              <entry>big_integer
            </row>
            <row>
              <entry>org.hibernate.type.BigDecimalType
              <entry>java.math.BigDecimal
              <entry>NUMERIC
              <entry>big_decimal, java.math.bigDecimal
            </row>
            <row>
              <entry>org.hibernate.type.TimestampType
              <entry>java.sql.Timestamp
              <entry>TIMESTAMP
              <entry>timestamp, java.sql.Timestamp
            </row>
            <row>
              <entry>org.hibernate.type.TimeType
              <entry>java.sql.Time
              <entry>TIME
              <entry>time, java.sql.Time
            </row>
            <row>
              <entry>org.hibernate.type.DateType
              <entry>java.sql.Date
              <entry>DATE
              <entry>date, java.sql.Date
            </row>
            <row>
              <entry>org.hibernate.type.CalendarType
              <entry>java.util.Calendar
              <entry>TIMESTAMP
              <entry>calendar, java.util.Calendar
            </row>
            <row>
              <entry>org.hibernate.type.CalendarDateType
              <entry>java.util.Calendar
              <entry>DATE
              <entry>calendar_date
            </row>
            <row>
              <entry>org.hibernate.type.CurrencyType
              <entry>java.util.Currency
              <entry>VARCHAR
              <entry>currency, java.util.Currency
            </row>
            <row>
              <entry>org.hibernate.type.LocaleType
              <entry>java.util.Locale
              <entry>VARCHAR
              <entry>locale, java.utility.locale
            </row>
            <row>
              <entry>org.hibernate.type.TimeZoneType
              <entry>java.util.TimeZone
              <entry>VARCHAR, using the TimeZone ID
              <entry>timezone, java.util.TimeZone
            </row>
            <row>
              <entry>org.hibernate.type.UrlType
              <entry>java.net.URL
              <entry>VARCHAR
              <entry>url, java.net.URL
            </row>
            <row>
              <entry>org.hibernate.type.ClassType
              <entry>java.lang.Class
              <entry>VARCHAR, using the class name
              <entry>class, java.lang.Class
            </row>
            <row>
              <entry>org.hibernate.type.BlobType
              <entry>java.sql.Blob
              <entry>BLOB
              <entry>blog, java.sql.Blob
            </row>
            <row>
              <entry>org.hibernate.type.ClobType
              <entry>java.sql.Clob
              <entry>CLOB
              <entry>clob, java.sql.Clob
            </row>
            <row>
              <entry>org.hibernate.type.BinaryType
              <entry>primitive byte[]
              <entry>VARBINARY
              <entry>binary, byte[]
            </row>
            <row>
              <entry>org.hibernate.type.MaterializedBlobType
              <entry>primitive byte[]
              <entry>BLOB
              <entry>materized_blob
            </row>
            <row>
              <entry>org.hibernate.type.ImageType
              <entry>primitive byte[]
              <entry>LONGVARBINARY
              <entry>image
            </row>
            <row>
              <entry>org.hibernate.type.BinaryType
              <entry>java.lang.Byte[]
              <entry>VARBINARY
              <entry>wrapper-binary
            </row>
            <row>
              <entry>org.hibernate.type.CharArrayType
              <entry>char[]
              <entry>VARCHAR
              <entry>characters, char[]
            </row>
            <row>
              <entry>org.hibernate.type.CharacterArrayType
              <entry>java.lang.Character[]
              <entry>VARCHAR
              <entry>wrapper-characters, Character[], java.lang.Character[]
            </row>
            <row>
              <entry>org.hibernate.type.UUIDBinaryType
              <entry>java.util.UUID
              <entry>BINARY
              <entry>uuid-binary, java.util.UUID
            </row>
            <row>
              <entry>org.hibernate.type.UUIDCharType
              <entry>java.util.UUID
              <entry>CHAR, can also read VARCHAR
              <entry>uuid-char
            </row>
            <row>
              <entry>org.hibernate.type.PostgresUUIDType
              <entry>java.util.UUID
              <entry>PostgreSQL UUID, through Types#OTHER, which complies to the PostgreSQL JDBC driver
              definition</entry>
              <entry>pg-uuid
            </row>
            <row>
              <entry>org.hibernate.type.SerializableType
              <entry>implementors of java.lang.Serializable
              <entry>VARBINARY
              <entry> Unlike the other value types, multiple instances of this type are registered. It is registered
              once under java.io.Serializable, and registered under the specific java.io.Serializable implementation
              class names.</entry>
            </row>
          </tbody>
        </tgroup>
      </table>
    </section>
    
    <section id="value-composite-types">
      <title>Composite types
      <para>
        <firstterm>Composite types, or embedded types, as they are called by the Java
        Persistence API, have traditionally been called <firstterm>components in Hibernate. All of these
        terms mean the same thing.
      </para>
      <para>
        Components represent aggregations of values into a single Java type. An example is an
        <classname>Address class, which aggregates street, city, state, and postal code.  A composite type
        behaves in a similar way to an entity. They are each classes written specifically for an application. They may
        both include references to other application-specific classes, as well as to collections and simple JDK
        types. The only distinguishing factors are that a component does not have its own lifecycle or define an
        identifier.
      </para>
      
    </section>
    
    <section id="value-collection-types">
      <title>Collection types
      <para>
        A <firstterm>collection type refers to the data type itself, not its contents.
      </para>
      <para>
        A Collection denotes a one-to-one or one-to-many relationship between tables of a database.
      </para>
      <para>
        Refer to the chapter on Collections for more information on collections.
      </para>
    </section>
  </section>
  <section id="entity-types">
    <title>Entity Types
    <para>
      Entities are application-specific classes which correlate to rows in a table, using a unique identifier. Because
      of the requirement for a unique identifier, ntities exist independently and define their own lifecycle. As an
      example, deleting a Membership should not delete the User or the Group. For more information, see the chapter on
      Persistent Classes.
    </para>
  </section>
  
  <section>
    <title>Implications of different data categorizations
    <para>
      NEEDS TO BE WRITTEN
    </para>
    
  </section>

</chapter>

Other Hibernate examples (source code examples)

Here is a short list of links related to this Hibernate Data_Categorizations.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.