I know this is old but nonetheless valid. I ran into the same problem. However, the @MappedSuperClass is not the same as a Single inheritance table. The MappedSuperClass will create separate tables for each of the subclasses (as I understand)
I'm not sure exactly why, but when I only have one inherited class I had no problems. However, once I added the second and third then I received the same error. When I specified @Id annotation in the child table it started working again.
My layout was simple, contact information for Companies, Agents, and Clients.
Parent Table:
...
@Entity
@Inheritance(strategy= InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="USER_TYPE", length=10, discriminatorType= DiscriminatorType.STRING)
@Table(name="CONTACTS")
public abstract class AbstractContact implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
protected Long id;
@Column (length=10, nullable=false)
protected String mapType;
@Column (length=120, nullable=false)
protected String mapValue;
...
Agent Contacts
@Entity
@DiscriminatorValue("Agent")
public class AgentContact extends AbstractContact implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
protected Long id;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="USER_ID")
protected Agents agent;
}
Company Contact:
@Entity
@DiscriminatorValue("Company")
public class CompanyContact extends AbstractContact implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
protected Long id;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="USER_ID")
protected Companies company;
}
Client Contacts:
@Entity
@DiscriminatorValue("Client")
public class ClientContact extends AbstractContact implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
protected Long id;
//Client table not built yet so... no mapping
}
The clients table isn't built yet so there's no mapping information, but you get the point.
I wanted to share the MySQL description but Windows Command Prompt is too worthless to cut/copy/paste! In essentially, its:
ID (int pri)
USER_TYPE (VARCHAR(10))
USER_ID (INT)
MAPTYPE (VARCHAR(10))
MAPVALUE (VARCHAR(120))
I still have to setup all the tests, but so far it looks good (I fear that if I wait until after I make all the tests I'll forget to post this)