Hello,
for tables with composite keys in join, the db sql script generated have duplicate columns.
In the following example, key tgn0401 is duplicated in the db script:
@MetaClass(name = "erp$Tgn04PK")
@Embeddable
public class Tgn04PK extends EmbeddableEntity
{
private static final long serialVersionUID = -6885992709391761414L;
@Column(name = "TGN0401", nullable = false, updatable = false, length = 4)
protected String tgn0401;
@Column(name = "TGN0402", nullable = false)
protected Integer tgn0402;
@Override
public boolean equals(Object o)
{
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Tgn04PK entity = (Tgn04PK) o;
return Objects.equals(this.tgn0401, entity.tgn0401) &&
Objects.equals(this.tgn0402, entity.tgn0402);
}
@Override
public int hashCode()
{
return Objects.hash(tgn0401, tgn0402);
}
public void setTgn0401(String tgn0401)
{
this.tgn0401 = tgn0401;
}
public String getTgn0401()
{
return tgn0401;
}
public void setTgn0402(Integer tgn0402)
{
this.tgn0402 = tgn0402;
}
public Integer getTgn0402()
{
return tgn0402;
}
}
@Table(name = "ERP_TGN04")
@Entity(name = "erp$Tgn04")
public class Tgn04 extends BaseGenericIdEntity<Tgn04PK> implements Updatable, Creatable
{
private static final long serialVersionUID = 269618245308009125L;
@Column(name = "TGN0411", nullable = false)
protected Integer tgn0411;
@Column(name = "TGN0412", nullable = false)
protected Integer tgn0412;
@JoinColumn(name = "TGN0401", insertable = false, updatable = false)
@ManyToOne(fetch = FetchType.LAZY, optional = false)
protected Tgn03 tgn03;
@JoinColumn(name = "TGN0410")
@ManyToOne(fetch = FetchType.LAZY, optional = false)
protected Tgn27 tgn0410;
@EmbeddedId
protected Tgn04PK id;
@Column(name = "UPDATE_TS")
protected Date updateTs;
@Column(name = "UPDATED_BY", length = 50)
protected String updatedBy;
@Column(name = "CREATE_TS")
protected Date createTs;
@Column(name = "CREATED_BY", length = 50)
protected String createdBy;
public Tgn27 getTgn0410()
{
return tgn0410;
}
public void setTgn0410(Tgn27 tgn0410)
{
this.tgn0410 = tgn0410;
}
public void setTgn03(Tgn03 tgn03)
{
this.tgn03 = tgn03;
}
public Tgn03 getTgn03()
{
return tgn03;
}
public void setTgn0412(CalcoloGiornoScadenza tgn0412)
{
this.tgn0412 = tgn0412 == null ? null : tgn0412.getId();
}
public CalcoloGiornoScadenza getTgn0412()
{
return tgn0412 == null ? null : CalcoloGiornoScadenza.fromId(tgn0412);
}
public void setTgn0411(Integer tgn0411)
{
this.tgn0411 = tgn0411;
}
public Integer getTgn0411()
{
return tgn0411;
}
@Override
public void setCreatedBy(String createdBy)
{
this.createdBy = createdBy;
}
@Override
public String getCreatedBy()
{
return createdBy;
}
@Override
public void setCreateTs(Date createTs)
{
this.createTs = createTs;
}
@Override
public Date getCreateTs()
{
return createTs;
}
@Override
public void setUpdatedBy(String updatedBy)
{
this.updatedBy = updatedBy;
}
@Override
public String getUpdatedBy()
{
return updatedBy;
}
@Override
public void setUpdateTs(Date updateTs)
{
this.updateTs = updateTs;
}
@Override
public Date getUpdateTs()
{
return updateTs;
}
@Override
public Tgn04PK getId()
{
return id;
}
@Override
public void setId(Tgn04PK id)
{
this.id = id;
}
}
create table ERP_TGN04 (
UPDATE_TS timestamp,
UPDATED_BY varchar2(50),
CREATE_TS timestamp,
CREATED_BY varchar2(50),
--
TGN0401 varchar2(4) not null,
TGN0402 number(10) not null,
--
TGN0411 number(10) not null,
TGN0412 integer not null,
TGN0401 varchar2(4) not null,
TGN0410 number(10) not null,
--
primary key (TGN0401, TGN0402)
)^
-- constraints
alter table ERP_TGN04 add constraint FK_ERP_TGN04_TGN0401 foreign key (TGN0401) references ERP_TGN03(TGN0301)^
alter table ERP_TGN04 add constraint FK_ERP_TGN04_TGN0410 foreign key (TGN0410) references ERP_TGN27(TGN2701)^
-- indexes
create index IDX_ERP_TGN04_TGN0401 on ERP_TGN04 (TGN0401)^
create index IDX_ERP_TGN04_TGN0410 on ERP_TGN04 (TGN0410)^