Generating JPA annotations from SQL Server identity columns

I'm generating entities from a MS SQL Server DB, using the following jpa file:

<persistence xmlns=""
  <persistence-unit name="Blaze">
      <property name="hibernate.connection.driver_class" value="net.sourceforge.jtds.jdbc.Driver"/>
      <property name="hibernate.connection.password" value="yyy"/>
      <property name="hibernate.connection.url" value="jdbc:jtds:sqlserver://server/db;instance=blah"/>
      <property name="hibernate.connection.username" value="xxx"/>
      <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
      <property name="hibernate.connection.pool_size" value="5"/>

It does not generate my identity columns correctly, it does:

@Column(name = "Id", nullable = false, insertable = true, updatable = true)
public int getId() {
     return id;
public void setId(int id) { = id;

but i want

@Column(name = "Id", nullable = false, insertable = false, updatable = true)
@GeneratedValue(strategy = GenerationType.AUTO)
public int getId() {
     return id;
public void setId(int id) { = id;

The DB column is:

Id     int     identity      NOT NULL

How can i achieve this?

1 comment
Comment actions Permalink


Unfortunately, this is not yet supported. Please follow:



Please sign in to leave a comment.