title: Migrate from Hibernate 4 to 5
body: <p>I have some problems with migration from hibernate 4.3 to hibernate 5.
  I'm working on a major project where we use SequenceHiLoGenerator to generate id which is deprecated now. How update this without major changes?</p>
  
  <p>This is my code with hibernate 4.3.</p>
  
  <pre><code>public class KSequenceGenerator extends SequenceHiLoGenerator {
  @Override
  public Serializable generate(SessionImplementor session, Object object) throws HibernateException {
      Serializable id = session.getEntityPersister(null, object).getClassMetadata().getIdentifier(object, session);
      return id != null ? id : super.generate(session, object);
  }
  </code></pre>
  
  <p>In EJB:</p>
  
  <pre><code>@GenericGenerator(name="id_gen", strategy="com.or.nk.ob.base.KSequenceGenerator", parameters = {@org.hibernate.annotations.Parameter(name = KSequenceGenerator.SEQUENCE, value = "building_id_seq")})
  </code></pre>
  
  <p>now i have:</p>
  
  <pre><code>public class KSequenceGenerator extends SequenceStyleGenerator { 
  public static final String SEQUENCE = "sequence";
  
  @Override public Serializable generate(SharedSessionContractImplementor session, Object object) throws HibernateException { 
      Serializable id = session.getEntityPersister(null, object).getClassMetadata().getIdentifier(object, session); 
      return id != null ? id : super.generate(session, object); 
  } 
  </code></pre>
  
  <p>}</p>
  
  <p>id:</p>
  
  <pre><code>@Id
  @Column(name = "ID")
  @GeneratedValue(generator = "id_gen", strategy = GenerationType.SEQUENCE)
  public Long getId() {
      return id;
  }
  </code></pre>