hibernate framework study notes (3)

1. Entity creation rules in hibernate

1> The object must have an oid.
2> The properties in the object, try to use the packaging type
3> Do not use the final modified class
4> Provide get/set methods....

2. Hibernate primary key generation strategy (7 kinds)

Increment: query the maximum value. Add 1
identity: The primary key is incremented.
Sequence: Hilo used by Oracle
: hibernate implements its own self-increment algorithm
native: choose one of three according to the selected database
uuid: random string
assigned: natural primary key.

3. The three states of the object

The transient state
has no id and is not in the session cache.
The persistent state
has an id and is in the session cache.
Managed | Free state
has an id, not in the session cache. Persistence: The object in the persistent state will be automatically synchronized to the database when the transaction is committed. We use the principle of hibernate. It is to convert the object into a persistent state.



4. Level 1 Cache

Cache: To improve efficiency.
Level 1 cache: To improve efficiency. There is a collection of objects in the session object. When querying: When querying for the first time. The object will be placed in the cache. When querying again, it will return the data in the cache. .No more querying the database. When modifying: A snapshot will be used to compare the difference between the properties of the object before and after the modification. Only one modification is performed.




        



5. Transaction management

1> How to configure database isolation level
1 read uncommitted
2 read committed
4 repeatable read
8 serialization

2> The specified session is bound to the current thread

                Configured under hibernate.cfg.xml

                <property name="current_session_context_class">thread</property>


6. Batch query

HQL Object Oriented Statement Query
Criteria Object Oriented Statementless Query
SQL Native SQL

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325649323&siteId=291194637