Hibernate3 Learning Notes (14) |blob, Clob

Source: Internet
Author: User

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;
.}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.