Research on Hibernate-based das Implementation (2)

Source: Internet
Author: User

Recently implemented SDO's Das implementation and used the scrollableresult function of Hibernate to record the code analysis results:

1) Paging

Query q = session. createquery ("from cat as C ");
Q. setfirstresult (200 );
Q. setmaxresults (100 );
List L = Q. List ();

Paging has nothing to do with scrollableresult and is fully reflected in the API. Line 1,543rd of org. hbigoal. loader. loader is as follows:

If (uselimit ){
SQL = dialect. getlimitstring (
SQL. Trim (), // use of trim () Here is uugly?
Useoffset? Getfirstrow (selection): 0,
Getmaxorlimit (selection, dialect)
);
}

That is, use different dialect for paging. This is a normal consideration. It is rare that the hibenrate setting varies with the max values of different databases. For example, maxresults of a database indicates the maximum number of records, while another database may indicate the maximum number of records.

2) scrollableresult

In jdbc2.0, it is defined as follows:

Statement stmt = con. getstatement ("cursor type", "Record Update permission ");
Cursor type:
Resultset. type_forword_only: can only move forward
Resultset. type_scroll_insensitive: Scroll. However, it is not affected by changes made to the database by other users.
Resultset. type_scroll_sensitive: Roll. This record also changes when other users change the database.
Record Update permission:
Resultset. concur_read_only, read-only
Resultset. concur_updatable, updatable

For scrollmode, Hibernate uses resultset. type_scroll_insensitive by default. Of course, you can specify yourself in the API

The desired mode.

For update priv, Hibernate uses resultset. concur_read_only, read-only.

If you are using an external connection, you must specify
<Property name = "hibernate. JDBC. use_scrollable_resultset"> true </property>

Of course, this configuration does not matter if you do not need an external connection.

 

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.