When using Hibernate targeting an SQL Server database could happen to have the error "Cannot insert explicit value for identity column in table 'MYTABLE' when IDENTITY_INSERT is set to OFF".
Here is how to deal with that.
Sometimes you have to write a long running time procedure and you want to log to file what is happening during the execution, in order to check the status, or just for event logging purpose. Here I propose a simple stored procedure for Sql Server that allows you to do that, using it instead of the classic "print" to dbms console.