Two-point experience from Hibernate2 to 3 transplantation

xiaoxiao2021-03-06  15

H3 provides a lot of exciting characteristics, from RC1 to provide new H3Test Project on the machine, due to time problems, H3 E-text DOC only sees Chapter 5 (all print A4 paper reading , The sun is bitter in the bathroom ~), and it has always been formal code transplant before getting up ...

These two days have not much feelings, I didn't want to send to Javaeye, but about the Lazy mechanism of H3, I think it is still awareness, it is not a mechanism itself, but it is the purpose of such a big change.

From H2 to H3, only two points in the current contact is important (the package change is relatively easy, batch replace it): 1. Dance Interface API Change Find / Iterate and other Method no longer support in H3 but in ORG .Hibernate.classic.Session provides the user with the above Method, but I want Classic is not a long-lasting policy, huh, huh, with Gavin's point of view, all Query operations, CreateQuery () is king

2.Lazy mechanism, this is more confused ... Take a look at the test code first Java code:

HBM file:

Code Userpo U = (Userpo) op.getations () (). Load (userpo.class, new long (3)); op.close (); system.Out.println (u.getname ());

The above code will get the LazyInitializationException error, that is, in H3, session.close () before (), if the PO is not operated, then the PO is actually only proxy, it's so intending, because there is no deep H3 Understand, it took a long time, and finally found the above answers in Hibernate forum. Why using this new Lazy mechanism for H3, it is still not daring to conclusion, but seeing GAVIN said that when it is doubtful to the user:

Stop Arguing with me, And Obey The Migration Guide!

I want to have a certain truth (or less, time ah time - -!)

Maybe you still miss the one-time LOAD out of H2 instead of proxy, then declare lazy = "false" in the class in the HBM file, please note that this is a new property setting in H3, and its default value is "Lazy =" true "; or uses the method of controlling the session lifecycle, hand it over to the filter to control, both methods are only personal, I hope everyone is correct

Well, about lazy problem at Hibernate official forum's post http://forum.hibs=rnate.org/viewtopic.php?t=939532&postdays=0&postorder=asc&start=0Hibernate3 Migration Guide continuously updated, H2-> H3 users must see why why I have found the answer to find this page? Sigh http://www.hibernate.org/documentation/Hibernate3migrationGuide#a7

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

New Post(0)