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:Read More →

Scenario It is always advisable not to use configuration values inside your application code directly. Rather, supply them through configuration files which are external to the code. For Example, almost all applications involve database interaction wherein they connect to a database. Obviously there are database connection parameters such as database server url, database port etc. If they are hard-coded inside the code, then for every change in those parameters (suppose for a change in database server URL), the code will have to be touched. If they are supplied through an external properties file, then changing them would only require a restart of application or notRead More →

Practical Scenario 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?Read More →

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)Read More →

JDBC is an acronym for Java DataBase Connectivity and is a technology for interaction of java application and its objects with a database. Hibernate on the other hand is a java based framework which also facilitates the interaction of application objects with a database but in a completely different approach. Below are listed some differences between the two. The points do not intend to indicate which is better, they just compare the various aspects of the method of operation of both. The headers before each row indicate the area of comparison.Read More →

Soft Delete !!! What the heck ? Soft delete means that the record is not removed from the database table but a flag is set to a value which indicates that this record should not be fetched while fetching the records from this table. The flag shall be a value of a column in the table itself. For example, there is a deleted column in a table which has a value of false for a record which is newly inserted in the table but when a record is deleted, it is not removed from the table but the value of deleted column for this recordRead More →