This entity:
@Entity
@IdClass(TwitterCountKey.class)
public class TwitterFriendCount {
@Id
long twitterUserId;
@Id
long fetchTime;
}
The key class is obvious but I mention here for completeness:
public class TwitterCountKey implements Serializable {
private static final long serialVersionUID = 1L;
private long twitterUserId = 0;
private long fetchTime = null;
public long getTwitterUserId() {
return twitterUserId;
}
public void setTwitterUserId(long newTwitterUserId) {
twitterUserId = newTwitterUserId;
}
public long getFetchTime() {
return fetchTime;
}
public void setFetchTime(long newFetchTime) {
fetchTime = newFetchTime;
}
}
creates the following incorrect schema:
CREATE TABLE twitterfriendcount
(
id_fetchtime bigint NOT NULL,
id_twitteruserid bigint NOT NULL,
_identifiermapper_fetchtime bigint NOT NULL,
_identifiermapper_twitteruserid bigint NOT NULL,
listedcount integer NOT NULL,
CONSTRAINT twitterlistedcount_pkey PRIMARY KEY (id_fetchtime, id_twitteruserid)
)
(note the excessive identifiermapper columns)
expected table structure is:
CREATE TABLE twitterfriendcount
(
id_twitteruserid bigint NOT NULL,
id_fetchtime bigint NOT NULL,
friendcount integer NOT NULL,
CONSTRAINT twitterfriendcount_pkey PRIMARY KEY (twitteruserid, fetchtime)
)
Workaround involves adding @Column(name=) manually, which works well with schema generation:
@Id
@Column(name="twitteruserid")
private long twitterUserId;
@Id
@Column(name="fetchtime")
private long fetchTime;
This bug was discovered while trying workarounds for HHH-9114.
|