OR mapping performance

xiaoxiao2021-03-06  41

I don't know why you suspect that o / r mapping performance, O / R mapping performance is also better than CMP.

JDO is just a standard, and each manufacturer has different performances, and it is not good to evaluate.

How is the performance of Apache Ojb, a review above the Apache website.

Hibernate's performance I spent some time to study. Hibernate can output all SQL statements by modifying the configuration file, you write some test code to observe the output of SQL, you understand what you know.

Simply, Hibernate's performance is very much higher than the JDBC code written by a normal Java programmer. The reason is because hibernate is essentially a JDBC to perform database operation. Since Hibernate is very very rampant, the JDBC call is very rampant, and use optimized, most efficient JDBC calls, so performance Quite satisfactory.

Simply speaking, for Insert operation, ordinary JDBC programmers will write:

PSTMT = conn.preparestatement ("INSERT INTO TABLE1 VALUES (?,?)");

For (int i = 0; i

PSTMT.SetString (1, Names);

PSTMT.SetString (2, pass);

PSTMT.ExecuteUpdate ();

}

If the batch is inserted into N records, then the N times sends a SQL statement to the database. Hibernate is a BATCH feature of JDBC2.0.

For (int i = 0; i

PSTMT.SetString (1, Names);

PSTMT.SetString (2, pass);

PSTMT.Addbatch ();

}

Pstmt.executebatch ();

It is just 1 time to send SQL to the database, and the performance is unified. UPDATE operation is similar.

SELECT operation, you can use the JCS buffer query results. Repeat queries are definitely faster than JDBC, and the page operation can use the Patement SQL of the database, or use the JDBC2.0 scroll result.

In addition, Hibernate always allows you to send SQL to the data as much as possible. It will first buffer the SQL statement in the SESSION buffer, and finally send the database to the database at once in FLUSH.

Overall, when you use hibernate, it is equivalent to having a JDBC master to help you optimize the JDBC call, which encapsulates a layer of loss can be ignored.

If you don't think Hibernate encapsulate the JDBC will lose performance, then I ask you, the goal of Java design is that the components can be reused, is these not all package? It's hard to call the components to lose performance. If so, don't write what components are written, all rewrite the original implementation code!

But if a real JDBC master, completely optimize the JDBC code to write DAO implementation, I believe it will be higher than hibernate, but Hibernate is already optimized, you can do very limited. It is better than the program written in C language, although it is poor than the assembly language, but the difference is very limited. Hibernate VS JDBC is equivalent to C vs assemble unless special needs, Hibernate is already good enough.

转载请注明原文地址:https://www.9cbs.com/read-61165.html

New Post(0)