Hi,

I am already struggling with an id problem for days. I have to write a program in java, using hibernate/jpa for the persistence layer and sqlserver as database (I know, java and sqlserver is not the usual combination). This program will later be externalised to other departments of the same company, who might use another database (like Oracle, MySQL,...).

What I want to accomplish is to get jpa/hibernate working on:

- databases like Oracle, using sequence

- databases like sqlServer, MySQL,... using auto-generate or identity. Between MySQL and SQLserver there is another important difference: the identity of SQLServer does not allow the id field to be filled in.

I already tried a sollution like the following example, using the table generationtype strategy, but to no avail

@Id
@Column(name = "Id", unique = true, nullable = false)
@TableGenerator(name = "appSeqStore", table = "APP_SEQ_STORE", pkColumnName = "APP_SEQ_NAME",
pkColumnValue = TableConstants.DERIVATION_TABLE + ".Id", valueColumnName = "APP_SEQ_VALUE",
initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "appSeqStore")

Any help is welcome,

Thanks