ok, I have managed to do it by:
Code:
HibernateSession.currentSession().connection().createStatement().executeUpdate("SET IDENTITY_INSERT Hotel ON");
But when I assign the code of the hotel,
hotel.setCode(new Long(rs.getInt("code"))) and afterwards I save the hotel with hibernate:
Code:
HibernateSession.currentSession().connection().createStatement().executeUpdate("SET IDENTITY_INSERT Hotel ON");
HibernateSession.currentSession().save(hotel);
HibernateSession.currentSession().connection().createStatement().executeUpdate("SET IDENTITY_INSERT Hotel OFF");
I have an SqlException, which says:
Code:
java.sql.SQLException: Explicit value must be specified for identity column in table 'Hotel' when IDENTITY_INSERT is set to ON.
How this can be? I already have setted the hotel's code...
can anyone help me please?