Generating JPA annotations from SQL Server identity columns

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

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
             version="2.0">
  <persistence-unit name="Blaze">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>java:/DefaultDS</jta-data-source>
    <class>com.vatit.blaze.services.connections.entity.ConcurConnection</class>
    <class>com.vatit.blaze.services.connections.entity.Connection</class>
    <class>com.vatit.blaze.services.connections.entity.ConnectionType</class>
    <properties>
      <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"/>
    </properties>
  </persistence-unit>
</persistence>



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

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


but i want

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


The DB column is:

Id     int     identity      NOT NULL


How can i achieve this?


 
1 comment
Comment actions Permalink

Hello.

Unfortunately, this is not yet supported. Please follow: http://youtrack.jetbrains.com/issue/IDEA-97873

Regards,
Alexander.

0

Please sign in to leave a comment.