We're updating the issue view to help you get more done. 

@IdClass with DefaultComponentSafeNamingStrategy results in duplicate id_ and _identifiermapper_ columns

Description

This entity:

1 2 3 4 5 6 7 8 @Entity @IdClass(TwitterCountKey.class) public class TwitterFriendCount { @Id long twitterUserId; @Id long fetchTime; }

The key class is obvious but I mention here for completeness:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 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:

1 2 3 4 5 6 7 8 9 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:

1 2 3 4 5 6 7 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:

1 2 3 4 5 6 7 @Id @Column(name="twitteruserid") private long twitterUserId; @Id @Column(name="fetchtime") private long fetchTime;

This bug was discovered while trying workarounds for HHH-9114.

Environment

PostgreSQL 9.3 using PostgreSQL9Dialect, DefaultComponentSafeNamingStrategy

Status

Assignee

Unassigned

Reporter

Hendy I.

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

4.3.6

Priority

Major