In Hibernate, the Blob and CLOB can be mapped directly.
The DDL is as follows:
1.CREATE TABLE User (
2. ID INT (one) not NULL auto_increment PRIMARY KEY,
3. name VARCHAR not NULL default ',
4. Age INT,
5. Photo BLOB,
6. Resume TEXT
7.);
Note: Because the size of the BLOB field is unpredictable, it is sometimes necessary to increase the size of the Blob field, instead of Mediumblob or even longblob in the database.
User.java
1.package Com.hb3.pack_07.model;
2.
3.import Java.sql.Blob;
4.import Java.sql.Clob;
5.6.public class User {
7. 8. Private Integer ID;
9. Private String name;
. Private Integer age;
One-private Blob photo;
Private Clob resume;
14.
Public User () {
15.
}
16. Public Integer getId () {
18. return ID;
.}
20. public void SetId (Integer id) {
21. This.id = ID;
.}
23. Public String GetName () {
24. return name;
26}
. public void SetName (String name) {
27. THIS.name = name;
.}
29. Public Integer Getage () {
30. return age;
32}
. public void Setage (Integer age) {
33. This.age = age;
N.}
35. Public Blob Getphoto () {
36. return photo;
38.}
. public void Setphoto (Blob photo) {
39. This.photo = photo;
.}
41. Public Clob GetrEsume () {
42. return resume;
$44}
. public void Setresume (Clob resume) {
45. This.resume = Resume;
.}