Last active
August 30, 2015 05:10
-
-
Save dungdm93/fa37f60c3b9cf7f421d4 to your computer and use it in GitHub Desktop.
[Java][JPA] LOB example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A
LOB
is a Large OBject, such as aBLOB
(Binary LOB), or aCLOB
(Character LOB). It is a database type that can store a large binary or string value, as the normalVARCHAR
orVARBINARY
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 aCLOB
will normally map to aString
, and aBLOB
will normally map to abyte[]
, although aBLOB
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 aBLOB
field.String
byte[]
Serializable