14.主键连接列
www.suntodo.com
?
Base is a JOINED Table?

?
- Add a primary key join column
name
desc
default
name
The name of the primary key column of the current table.
Defaults to the same name as the primary key column of the primary table of the superclass (JOINED mapping strategy);
""
referencedColumnName
(Optional) The name of the primary key column of the table being joined to.Defaults to the same name as the primary key column of the primary table of the superclass (JOINED mapping strategy);
""
columnDefinition
(Optional) The SQL fragment that is used when generating the DDL for the column. This should not be specified for a OneToOne primary key association.Defaults to the generated SQL to create a column of the inferred type.
""
Derived1 has a Primary Key.
- Generate Java Entity Code
Derived1
@Entity( name="Derived1" )
@PrimaryKeyJoinColumns({@PrimaryKeyJoinColumn( name="newPrimaryKey" )} )
@Table( name="Derived1" )
public
class Derived1 extends Base implements Serializable {
……
}
- Generate SQL Script
create table Base (id bigint not null auto_increment, baseName varchar(255), primary key (id));
create table Derived1 (derived1Name varchar(255), newPrimaryKey bigint not null, primary key (newPrimaryKey));
alter table Derived1 add index FK3F2C91D4ED087A31 (newPrimaryKey), add constraint FK3F2C91D4ED087A31 foreign key (newPrimaryKey) references Base (id);
?