1. Is there any default cache mechanism? Suppose I dint set the "hibernate.cache.provider_class" in the config file.
2. Does hibernate loads the entire database into it, at the start of the application?
3. Suppose I inserted a record in a table, will it be updated with the hibernate copy which it loaded at the start of the application?
4. Suppose I issued a select query, from where will I get the records? Is it from hibernate or from database?
Suppose I closed the session object, will the records in cache be deleted?
Hemant Thard wrote:Can you please elaborate what you mean by inserted.
Hint Think about synchronization when same object is accessed my multiple thread.
Note : when we issue hibernate query, hibernate synchronize the modified object within session, with database(issue update for that object) .
Why? 2nd level cache implementations are required to be thread-safe (and can also be transactional).
No, it won't. You synchronize by flushing the session or updating an object (which will evict it from any second level cache). Issuing a query will not flush the session.
Lets assume that you make modification to persistence object before executing a query. there modification are only present in memory so hibernate flushes the persistence context and all changes to the database before executing your query. This guarantees that the query runs on the current data and that no conflict between the query result and in-memory object can occur.
What is meant by lazy loading?
Suppose when an object with primary key 25 is taken, then later I again asked the same object it is retrieved from the frst level cache. Suppose mean while the record with primary key 25 is updated, will the first level cache makes the update to the object?
Is session.clear() necessary?
Suppose I opened a database connection, then wrote some business logic, say about 100 lines of business logic which takes milli seconds to execute, then I am using the connection. At the first instance only I dint use the connection, when the business logic is being executed the connection will not be active. Am I right?
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter libraryhttps://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter