Hibernate provides multilevel caching framework : First Level Cache (Also called L1 cache or Session cache) Second Level Cache (L2 Cache) Query Cache First Level Cache / L1 Cache / Session Cache The First level cache(L1 cache) is the Session cache through which all the db requests must pass. The L1 cache ensures that …
Continue reading Hibernate Caching : First Level CacheWelcome to 2017 !! Wish you a very happy and promising new year 2017. We published many articles last year and received a lot of valuable comments. So, this is the time to review the best ones. You can click on each individual link to read more on it. Best Featured articles …
Continue reading Best 25 Articles of TopJavaTutorial in 2016 (Worth Reading !!!)HQL Hibernate has its own query language called HQL(Hibernate Query Language). HQL is object oriented. In HQL, we use the class name in place of table name and property name in place of column name. HQL queries are internally converted to SQL by Hibernate. FROM clause Using just the From clause fetches all the …
Continue reading Selecting data from database using HQLNamed Queries help in removing queries from the code and add in the mapping file or the entity. @NamedQuery For creating a named query, we can use the @NamedQuery annotation. The @NamedQuery annotation accepts a name and the query. Named Query Example This example creates a Named query called “getEmployees” that fetches Employee details. …
Continue reading Hibernate Named QueriesHibernate @Formula We can use the @Formula annotation to get a calculated column value in Hibernate. In the below Employee Entity class, we have a column called “name”. We have added another column “upperName” using the @Formula annotation to get the name always in uppercase. Here is the corresponding Employee table : package com.topjavatutorial; import …
Continue reading How to use a calculated column or formula in Hibernate