What is Criteria api? Criteria api in Hibernate is used to fetch data from database tables. Though Hibernate Query Language can also be used to perform the same task but…
In Hibernate or any ORM framework, a java class is mapped to a database table. This means the fields of the java class correspond to the columns of a database…
What does mapping an Entity to database table mean ? A Java class represents an Entity in ORM terminology. Mapping an Entity to a table means associating the java class(which…
Hibernate framework is used for interacting with database records as Java Objects and vice-versa. It saves/updates java objects as database records, fetches database records as java objects etc. Hibernate performs database interaction using its Session objects. Session objects are retrieved with the help of a SessionFactory. This SessionFactory is related to a particular database.
It’s a common method to use a configuration file where database connection details, mapped entity details are provided which we commonly call as hibernate.cfg.xml or hibernate.properties.
It is a common belief that to start using hibernate we have to use a configuration file. But let me tell you that it is also possible to completely omit this file and configure hibernate alongwith a particular database directly from the code. Let’s see how: (more…)
If you have come across the above error, chances are :
- You have two entities, a Parent and its Child.
- You are deleting (Or removing some old and adding new) Child records and updating the Parent.
Going through this post will help you resolve this error and provide you insight on the details of the solution (more…)
Two users are working on a project and they both are currently viewing a bug or an enhancement in a project management application. Let’s say one user knows that it is a duplicate bug while the other does not know and thinks that this needs to be done. Now one user changes its status as IN PROGRESS and the other user marks it as DUPLICATE at the same time but the request with status as DUPLICATE goes a bit early to the server and the request with status IN PROGRESS arrives later. What will be the current status?
When using Hibernate in your application, there are bright chances that you have encountered the error org.hibernate.HibernateException: No CurrentSessionContext configured!. Stack trace of the error would have been :
Exception in thread "main" org.hibernate.HibernateException: No CurrentSessionContext configured! org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:690) at com.codippa.Main.main(Main.java:16)