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)publicint getId() { return id;}publicvoid setId(int id) { this.id = id;}
but i want
@Id @Column(name = "Id", nullable = false, insertable = false, updatable = true) @GeneratedValue(strategy = GenerationType.AUTO)publicint getId() { return id;}publicvoid setId(int id) { this.id = id;}
The DB column is:
Id int identity NOTNULL
How can i achieve this?