Hibernate Reading Notes

Source: Internet
Author: User

Great Information Management and Information System majors, all evil Information Management and Information System majors. I have a reason to say this: this major is ambitious and wants to train its children into all-round development talents, but the result is not. Two reasons: some are students, but some are students in this major. What makes me very depressed is that we have set up the course "finance" this semester, which is a huge waste (For Me, it cannot be said with any purpose ). Simply because I was so determined that I didn't want to learn this course. With the sweet voice of my teacher, I became familiar with hibernate again. I would like to talk about the gains of this afternoon without talking nonsense.

1. the unsaved-Value Attribute of Hibernate

Unsaved-value is related to the configuration attributes of the Save or update object of hibernate. It has three optional values: NULL, none, and any.

A) null means: if the primary key of the object is null, the SAVE () method is used for the object. If the primary key of the object is not null, update () is used for the object ().

B) None means: In either case, the primary key of the object cannot be set to none. In this case, Hibernate always saves ().

C) Any indicates any value. Of course, the primary key of the object will not take any value other than the value. In this case, Hibernate always uses Update ().

2. As a result, I think of three State objects of hibernate:

A) transient --- object in the water state: the object has just been created and has no persistence. it naturally does not correspond to any primary key in the database.

B) Persistent --- Persistent Object. After the object is created, it is persisted, and the database has corresponding primary keys. However, it should be noted that the status of this object is kept before the session is closed. This is a place that is easy to mix with the following object states.

C) detached --- the managed object. The managed object here is managed by the disconnected session. The state of this object is that the session has been closed, but the Java Garbage Collector has not recycled this object.

I understand the three object states of hibernate. In fact, I am also ignorant. Hope someone else can give me some advice ....

3. choose a hibernate primary key: use non-business-related fields as much as possible for the hibernate primary key type, and use the object type (integer, string...) as much as possible for the selection of the hibernate primary key type ....), instead of using the basic type (INT, long ....).

4. hibernate cache mechanism:

Level-1 cache: The level-1 cache is session-level cache. This cache does not need to be configured and is automatically provided by hibernate.

Level-2 Cache: The level-2 cache is a global cache at the sessionfactory level, which needs to be configured. The cache mechanism is very important for a system, which involves a new capability of the system. Cache Technology is alsoProgramIf the cache processing is good, the system performance will be greatly improved. On the contrary, the system performance will be reduced. (Limited level)

In fact, I read a lot of things this afternoon, but they are all configuration items. Because my own level is not enough to say much, Hibernate is not used to use, but to comprehend !! Study hard ....

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.