我正在某个包含很多复合键的数据库上工作。我需要插入此数据库文件中包含的一些数据。但是,当我尝试将数据插入表中时,出现以下错误:
java.sql.SQLException:字段“ sprachNr”没有默认值
以下是相关型号:
@Entity
@Table(name="010_country_table")
public class CountryTable {
@Id
String lKZ;
int dLNr;
int sA;
int bezNr;//Description Number -30
String verkehr;
int warNr;
String wKZ;
int warBezNr;//Currency Description Number -30
String vorwahl;
int istGruppe;
String isoCode2;
String isoCode3;
int isoCodeNr;
int loschFlage;
@MapsId("bezNr")
@ManyToOne
@JoinColumns({
@JoinColumn(
name = "bezNr",
referencedColumnName = "bezNr"),
@JoinColumn(
name = "sprachNr",
referencedColumnName = "sprachNr")
})
private LanguageDescriptions languageDescriptions;
语言描述模型
@Entity
@Table(name="030_language_descriptions")
public class LanguageDescriptions {
@EmbeddedId
LanguageDescriptionsID id;
int dlNr;
int sA;
String bez;
int loschFlag;
@OneToMany(
fetch=FetchType.EAGER,
cascade=CascadeType.ALL,
mappedBy = "languageDescriptions")
private List<CountryTable> countryTable;
embeddedID
@Embeddable
public class LanguageDescriptionsID implements Serializable {
@Column(name="bezNr")
int bezNr;
@Column(name="sprachNr")
int sprachNr;
语言模型
@Entity
@Table(name="020_language")
public class Language {
@Id
int sprachNr;
int dLNr;
int sA;
int bezNr;
String isoCode;
int codePage;
int loschFlag;
@OneToMany(
fetch=FetchType.LAZY,
cascade=CascadeType.ALL,
mappedBy = "language")
private List<LanguageDescriptions> languageDescriptions;
因此,问题在于LanguageDescriptions的组合键包含表Language的主键,而CountryTable引用了该组合键。我该如何解决这个问题?