首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

14.主键联接列

2012-10-07 
14.主键连接列www.suntodo.com?Base is a JOINED Table??Add a primary key join columnnamedescdefaultna

14.主键连接列

www.suntodo.com

?

Base is a JOINED Table

?

14.主键联接列

?

    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.

14.主键联接列

    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);

?

热点排行