The return value of session.save() depends on your mapping. Most likely you have an ID type that is not long. Try to do this:
System.out.println(session.save(object).getClass().getName());
Then you will see the type name.
Martin algesten
source share