in hibernate 5.x, you should add set hibernate.id.new_generator_mappings to false in hibernate.cfg.xml
<session-factory>
......
<property name="show_sql">1</property>
<property name="hibernate.id.new_generator_mappings">false</property>
......
</session-factory>