where to place the hibernate.cfg.xml when developing with hibernate in java.

The hibernate.cfg.xml file is the configuration file for hibernate and as such it is vital for the use of hibernate. Like any other configuration file, you need to make it available within the classpath for the code to be able to use it.

This can be accomplished in different ways, depending on your project.

  • For a web-app WAR project (you are running the program in a Servlet container): placing it in WEB-INF/classes will work as files in WEB-INF/classes are visible on the classpath when app is running in container.
  • For a Maven-style project (not running the program in a Servlet container): placing it in /src/main/resources/ will work
  • For otherwise, try in the src/ directory.

How to map integers to doubles using Java stream

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class HelloWorld{

     public static void main(String []args){
        List numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        List doubles = numbers.stream().mapToDouble(Integer::doubleValue).boxed().collect(Collectors.toList());
        List doubleSquares = numbers.stream().mapToDouble(i->i.doubleValue() * 2).boxed().collect(Collectors.toList());