Skip to content

Instantly share code, notes, and snippets.

@dungdm93
Last active August 30, 2015 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dungdm93/fa37f60c3b9cf7f421d4 to your computer and use it in GitHub Desktop.
Save dungdm93/fa37f60c3b9cf7f421d4 to your computer and use it in GitHub Desktop.
[Java][JPA] LOB example
import javax.persistence.*;
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String name;
@Lob
private String avatar;
...
@Override
public String toString() {
return String.format("Employee #%d: %s", id, name);
}
}
@dungdm93
Copy link
Author

A LOB is a Large OBject, such as a BLOB (Binary LOB), or a CLOB (Character LOB). It is a database type that can store a large binary or string value, as the normal VARCHAR or VARBINARY types typically have size limitations. A LOB is often stored as a locator in the database table, with the actual data stored outside of the table. In Java a CLOB will normally map to a String, and a BLOB will normally map to a byte[], although a BLOB may also represent some serialized object.

By default in JPA any Serializable attribute that is not a relationship or a basic type (String, Number, temporal, primitive), will be serialized to a BLOB field.

Source Wikibooks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment