Skip to main content

Posts

Hibernate 5.4.4 - How to fix hibernate depreciation warnings?

Problem Recently we migrated Hibernate to the latest version i.e. 5.4.4. Multiple depreciation warnings appeared in our code i.e. The type Query<R> is deprecated The method setString(String, String) from the type Query is deprecated The method uniqueResult() from the type Query is deprecated The method setBoolean(String, boolean) from the type Query is deprecated The method setLong(String, long) from the type Query is deprecated Solution Existing Change To import org.hibernate.Query; import org.hibernate. query .Query; query . setLong ( "serviceId" , serviceId ) ; query . setParameter ( "serviceId" , serviceId ); query . setBoolean ( "isDelete" ,Boolean. FALSE ) ; query . setParameter ( "isDelete" ,Boolean. FALSE ) ; query . setString ( "serviceNo" , serviceNo ) ; query . setParameter ( "serviceNo"

Scala language implementation of Selection Sort

Introduction Selection sort is the simplest sorting algorithm in terms of implementation. Let's consider we have a list of elements i.e. {3, 9, 0, 5, 4 } a) Selection sort maintains two sublists, one sorted and initially empty and second unsorted sublist i.e. [ {}, {3, 9 , 0, 5 ,4 }] b) It searches for the minimum element (for ascending sort) OR for a maximum element( for descending sort) in the unsorted list in each step. Step 1 [ {0 }, {9,3,5,4}] Minimum element = 0 , swapped with 3 Step 2 Minimum element = 3 , swapped with 9 [{0,3) , {9,5,4} ] Step 3 Minimum element = 4 , swapped with 9 [{0,3,4} , {5,9}] Step 4 Minimum element = 5 , swapped with itself [{0,3,4,5}, {9}] Step 5 Minimum element = 9 , swapped with itself [{0,3,4,5,9}, {}] Worst Complexity: O(n*n) Best Complexity   : O(n * n) Implementation package main.scala object SelectionSort { val array = Array(0, 5, 2, 6, 3, 1) def main(args: Array[String]) { print(&quo

Java Example of Selection Sort

Introduction Selection sort is the simplest sorting algorithm in terms of implementation. Let's consider we have a list of elements i.e. {3, 9, 0, 5, 4 } a) Selection sort maintains two sublists, one sorted and initially empty and second unsorted sublist i.e. [ {}, {3, 9 , 0, 5 ,4 }] b) It searches for the minimum element (for ascending sort) OR for a maximum element( for descending sort) in the unsorted list in each step. Step 1 [ {0 }, {9,3,5,4}] Minimum element = 0 , swapped with 3 Step 2 Minimum element = 3 , swapped with 9 [{0,3) , {9,5,4} ] Step 3 Minimum element = 4 , swapped with 9 [{0,3,4} , {5,9}] Step 4 Minimum element = 5 , swapped with itself [{0,3,4,5}, {9}] Step 5 Minimum element = 9 , swapped with itself [{0,3,4,5,9}, {}] Worst Complexity: O(n*n) Best Complexity   : O(n * n) Imperative style implementation using Java 7 public class SelectionSortExample { private static int array[] = {3,9,0,5,4}; public static void mai

Scala Implementation of Insertion Sort

Introduction Insertion sort is the best sorting algorithm for small-sized list of elements as compared to selection sort and  bubble sort . This sorting algorithm always maintains a sorted sublist within an iteration i.e. it finds the correct position of a single element at a time and inserts it in its correct position within the currently sorted sublist. Worst Complexity     : O(n*n) Best Complexity        : O(n) Average Complexity : O(n*n) Implementation package main.scala object InsertionSort {   val array = Array(0, 5, 2, 6, 3, 1)   def main(args: Array[String]) {     print("Unsorted List ")     println(array.toList)     print("Asceding sorted List ")     insertionSortAscending;     println(array.toList)     insertionSortDescending     print("Desceding sorted List ")     println(array.toList)   }   def insertionSortAscending { //first element is considered as sorted sublist     for (outer <- 1 until array.length) {

Java code of Insertion sort

Introduction Insertion sort is the best sorting algorithm for small-sized list of elements as compared to selection sort and bubble sort . This sorting algorithm always maintains a sorted sublist within an iteration i.e. it finds the correct position of a single element at a time and inserts it in its correct position within the currently sorted sublist. Worst Complexity    : O(n*n) Best Complexity        : O(n) Average Complexity : O(n*n) Imperative style using Java 7 public class InsertionSortExample { private static int array[] = {0,5,2,6,3,1,-9}; public static void main(String[] args) { insertionSortAscending(); System.out.println("Ascending Sorted List"); for(int value : array) { System.out.print(value + " "); } insertionSortDescending(); System.out.println("\nDescending Sorted List"); for(int value : array) { System.out.print(value + " "); } } private static void insertionSortAscending() {

Scala language implementation of Bubble Sort

Introduction Bubble sort is the simplest sorting algorithm. It has the following steps a) Iterates through the list b) Compares the adjacent elements c) Swap the adjacent elements if they are in not in proper sorting order d) The list is traversed repeatedly unless the list is sorted Worst Complexity : O(n*n) Best Complexity    : O(n) Alternate name      : Sinking Sort Implementation package main.scala object BubbleSort { val array = Array(0,5,2,6,3,1) def main (args : Array[String] ) { print("Unsorted List ") println(array.toList) print("Ascending sorted List ") bubbleSortAscending; println(array.toList) bubbleSortDescending print("Descending sorted List ") println(array.toList) } def bubbleSortAscending { //in scala you can combine inner and outer loops, until does not include the last number for( i <- 0 until array.length; j <- 1 until array.le

Create New Scala sbt project for Eclipse

Introduction In this post, we will learn how to create a new Scala sbt project and convert it into the eclipse project. We will then import the project into eclipse Step 1 Open your user's home directory, on windows, it will be user directory\.sbt\1.0\ Step 2 Create a new directory by the name of plugins if one does not exist Step 3 Create a new file  plugins.sbt ( if one does not exist)   inside the plugins folder Step 4 Open the newly created file  plugins.sbt and add the following line addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4") Step 5 Open a Command prompt and create a new directory for your Scala project i.e. > mkdir FirstScalaEclipseProject Step 6 Move to the new directory > cd FirstScalaEclipseProject Step 7 Enter the following command > sbt reload (if the shell is not restarted) > sbt eclipse Step 8 Open the eclipse, Go to File -> Import -> Import Existing Proj

Java Bubble Sort Example

Introduction Bubble sort is the simplest sorting algorithm. It has the following steps a) Iterates through the list b) Compares the adjacent elements c) Swap the adjacent elements if they are in not in proper sorting order d) The list is traversed repeatedly unless the list is sorted Worst Complexity : O(n*n) Best Complexity    : O(n) Alternate name      : Sinking Sort Implementation using Simple Loops public class BubbleSortExample { private static int array[] = {0,5,2,6,3,1}; static int temp = 0; public static void main(String[] args) { bubbleSortAscending(); System.out.println("Ascending Sorted List"); for(int value : array) { System.out.print(value + " "); } bubbleSortDescending(); System.out.println("Descending Sorted List"); for(int value : array) { System.out.print(value + " "); } } private static void bubbleSortAscending() { for(int outer=0; outer<array.length; outer++) {

WARN orm.deprecation - HHH90000014: Found use of deprecated [org.hibernate.id.SequenceGenerator] sequence-based id generator

Introduction  I upgraded Hibernate from version 4 to 5.4.4. Following warning was thrown by Hibernate WARN  orm.deprecation - HHH90000014: Found use of deprecated [org.hibernate.id.SequenceGenerator] sequence-based id generator; use org.hibernate.id.enhanced.SequenceStyleGenerator instead.  See Hibernate Domain Model Mapping Guide for details. http-nio-8080-exec-10 WARN  orm.deprecation - HHH90000014: Found use of deprecated [org.hibernate.id.SequenceHiLoGenerator] sequence-based id generator; use org.hibernate.id.enhanced.SequenceStyleGenerator instead.  See Hibernate Domain Model Mapping Guide for details. Old Code     @Id     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PERSON")     @SequenceGenerator(name = "SEQ_PERSON", sequenceName = "SEQ_PERSON_ID",allocationSize=1)     private Long id; SequenceGenerator is deprecated by Hibernate and we have to use either SequenceStyleGenerator or GenericGenerator instea

Default Port numbers used by different software/protocols

The following table lists the default port numbers used by different software/protocols Software/Protocol Default Port Number http 80 https 443 Apache Server 80 IIS Server 80 Apache Tomcat 8080 MySQL server 3306 SQL Server 1433  MongoDB   27017 PostgreSQL 5432 Java No default port DynamoDB 8000 Cassandra 7000 neo4j http port 7474 neo4j https port 7473 Oracle SQL*Net Listener 1521 Oracle Data Guard 1521 Oracle Connection Manager 1630 Oracle Management Agent 3938 Oracle Enterprise Manager Database Console 1158 Oracle SQL*Plus RMI Port 5580 Oracle SQL*Plus JMS Port 5600