What does the load () method of Java – hibernate do for non-existent IDS?

I'm interested in session JavaDocs on load is a little confused:

I understand that I should use get, but what I don't understand is what it means to initialize a non identifier method as needed

For me, if I have a class and use load (MyClass. Class, nonexistingid), and then print the output of getid () on the returned instance, it seems that it will automatically generate a new instance with nonexistingid every time Why?

I just want to know, is getid () a non recognition method?

Solution

"Non identifier method" means a method that returns an identifier other than the object (such as in the primary key ID) Load provides you with a proxy server. The proxy server will query the database only when you ask for anything other than the database So getid is an identifier method. Hibernate won't query its value in the database (it doesn't, because you passed it to the load method call)

Find this code snippet in the hibernate Forums:

So it sounds like you've used load to get a proxy for a nonexistent object, but since you didn't call any 'nonidentifier method' on it, you didn't force the proxy to hit the database and there were no errors

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>