This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Second level cache stores the object in a map, having primary key as Map's key and Object as map value. Second level cache is used only while accessing the object by primary key ie by using session.get(), session.load().
Query cache store the query result in map, having query and its parameters as Map's key and result as map value. Query cache can be used to cache & reuse the result of any query irrespective of primary key usage in it.