I’m having difficulty with JPA and BIGSERIAL id’s under PostgreSQL.
I’m using Eclipse Version: 6.0.1 GA over PostgreSQL 8.3.1 on MacOS/X 10.5.4.
I’m applying JPA Reverse Engineering to a database containing table definitions like this:
CREATE TABLE address
(
addressId BIGSERIAL NOT NULL,
accountId BIGINT NOT NULL,
street1 VARCHAR(256) NULL,
… other fields…
PRIMARY KEY (addressId),
FOREIGN KEY (accountId) REFERENCES account(accountId)
);
I’m generating abstract classes.
My jpa.reveng.xml contains:
<table name=”address” catalog=”public”>
<primary-key>
<generator class=”native” />
<column name=”addressId” />
</primary-key>
</table>
However, the id getter in AbstractAddress.java only contains the following annotations:
@Id
@Column(name = “addressid”, unique = true, nullable = false, insertable = true, updatable = true)
public Long getAddressid() {
return this.addressid;
}
I think it ought to contain a @GeneratedValue like this:
@Id
@GeneratedValue
@Column(name = “addressId”, unique = true, nullable = false, insertable = true, updatable = true)
public Long getAddressId() {
return this.addressId;
}
What am I missing here?
Thanks in advance,
Ken Bowen