liveBook · Manning

Character large object

As explained in Java Persistence with Spring Data and Hibernate epub

A character large object is large character data stored separately from ordinary column storage and referenced by the table.

A character large object (CLOB) holds large character data separately from ordinary column storage; the table references it. It is an alternative to the usual String mapping, which defaults to VARCHAR(255) in Hibernate. section 6.3.1

Mapping a large description

For an Item entity, `@Lob private String description;` maps a Java String as a large object. Alternatively, `@Lob private java.sql.Clob description;` exposes the JDBC CLOB type in the entity. Choose the property type according to whether the domain model should hold a String or a Clob. section 6.3.1

Table 6.4 Binary and large value types (view table figure)

Name

Java type

ANSI SQL type

binary

byte[], java.lang.Byte[]

VARBINARY

text

java.lang.String

CLOB

clob

java.sql.Clob

CLOB

blob

java.sql.Blob

BLOB

serializable

java.io.Serializable

VARBINARY

The type table distinguishes a String mapped as text from a java.sql.Clob property; both correspond to the SQL CLOB type. section 6.3.1

For nationalized character data, Hibernate also supports NCLOB through `@Nationalized`. Character-set defaults and vendor-specific type selection depend on the DBMS and SQL dialect. section 6.3.1

How Java Persistence with Spring Data and Hibernate epub covers it

How deep it goes
Compares String and java.sql.Clob property mappings with examples, but does not work through CLOB access or transaction behavior.
Examples
Shows an Item description mapped first as an @Lob String and alternatively as an @Lob java.sql.Clob.
What it assumes
Assumes familiarity with Java entity properties and annotations; supplies the contrasting String and Clob declarations.
What you can do after
Apply it via JPA’s @Lob to map a large String or java.sql.Clob property.
How it connects
Connects CLOBs to JPA’s @Lob, Hibernate’s text type, VARCHAR mappings, and nationalized character data.

This explainer was generated by Manning's knowledge graph from the text of Java Persistence with Spring Data and Hibernate epub. The section links point to the parts of the book it draws on.