I had the same problem. Fixed it this way:
Use Hibernate org.hibernate.annotations.GenericGenerator instead of persistance TableGenerator like this:
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import org.hibernate.annotations.GenericGenerator;
@Entity
@Table(name = "name")
public class Name implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "names")
@GenericGenerator(name = "names", strategy = "com.ourpackage.SybaseTableGenerator", parameters = {
@Parameter(name = "table_name", value = "new_key_numbers"),
@Parameter(name = "value_column_name", value = "key_number"),
@Parameter(name = "segment_column_name", value = "name"),
@Parameter(name = "segment_value", value = "names_key") })
@Column(name = "names_id")
private Long id;
And create your own generator (I used name com.ourpackage.SybaseTableGenerator):
import java.io.Serializable;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.id.enhanced.TableGenerator;
@SuppressWarnings("UnusedDeclaration")
public class SybaseTableGenerator extends TableGenerator {
@Override
public synchronized Serializable generate(SessionImplementor session, Object obj) {
return (Long) super.generate(session, obj) + 1;
}
}
A little bit tricky but it works ;)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…