Posts

What is Encryption and Decryption?

                                        What is Encryption and Decryption ? Encryption is conversion of data from plain text to ciphered text so that it becomes unreadable if fallen into wrong hands.  Decryption is conversion of the same encrypted data back to plain text.  There are 2 types of encryption:  Symmetric Encryption : When we make use of the same key for both encryption and decryption. This is mostly used when data needs to be transferred between closed systems. AES256 algorithm is a common example of this type of encryption.  Asymmetric Encryption : In asymmetric encryption the sender will use the public key of the receiver to encrypt the data, and the receiver should use their private key to decrypt the data, this private key file should never be shared. This type of encryption should be used while trying to secure a connection with a client and a server....

Hibernate Logging by Log4j using properties file

Log4j and Logback frameworks are used to support logging in hibernate, there are two ways to perform logging using log4j: By log4j.xml file (or) By log4j.properties file Here, we are going to enable logging using log4j through properties file. Create log4j.properties file Now you need to create log4j.properties file. In this example, all the log details will be written in the D:\\logfilename.log file.( location where you want) if you want logs present inside log folder which are created inside the src folder then write  logs/logfilename.log # Direct log messages to a log file log4j.appender.file = org.apache.log4j.RollingFileAppender #log4j.appender.file.File=D:\\javatpointhibernate.log # Define the log folder path log4j.appender.file.File= logs/javatpointhibernate.log log4j.appender.file.MaxFileSize= 1MB log4j.appender.file.MaxBackupIndex= 1 log4j.appender.file.layout = org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern= %d{ABSOLUTE} %5p %c {1}...

Hibernate - Examples

  Create POJO Classes The first step in creating an application is to build the Java POJO class or classes, depending on the application that will be persisted to the database. Let us consider our  Employee  class with  getXXX  and  setXXX  methods to make it JavaBeans compliant class. A POJO (Plain Old Java Object) is a Java object that doesn't extend or implement some specialized classes and interfaces respectively required by the EJB framework. All normal Java objects are POJO. When you design a class to be persisted by Hibernate, it is important to provide JavaBeans compliant code as well as one attribute, which would work as index like  id  attribute in the Employee class. package hbm; public class Employee {    private int id;    private String firstName;     private String lastName;       private int salary;      public Employee() {}    pub...