gpt4 book ai didi

java - DuplicateMappingException 由不同的逻辑列名表示

转载 作者:行者123 更新时间:2023-12-01 06:45:12 24 4
gpt4 key购买 nike

我正在对两个类 MasavNew 和 MasavRow 使用 OneToMany 映射:

@Entity
@Table(name = "ArgoCHFileHdr")
public class MasavNew {


@OneToMany(fetch = FetchType.LAZY, mappedBy = "msv",cascade = CascadeType.ALL)
@ElementCollection(targetClass=MasavRow.class)
private List<MasavRow> rows;

@Id
@Column(name = "[Arg.CH.F.Key]", nullable = false)
@GeneratedValue(strategy=GenerationType.IDENTITY)
protected Integer argCHFKey;

}


@Entity
@Table(name = "ArgoCHFileRow")
@DynamicUpdate
public class MasavRow extends IModel {


@ManyToOne(fetch = FetchType.LAZY,optional=true)
@JoinColumn(name="[Arg.CH.F.Key]")
private MasavNew msv;


@Id
@Column(name = "[Arg.CH.F.Key]", nullable = false)
private int argCHFKey;


@Id
@Column(name = "[Arg.CH.L.MNB]", nullable = false)
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer argCHLMNB;


@Column(name = "[Erp.Clnt]", nullable = true)
private String erpClnt;


}

然后在运行时我收到下一个异常:
Caused by: org.hibernate.DuplicateMappingException:  Table [ArgoCHFileRow] contains physical column name [`Arg.CH.F.Key`] represented by different logical column names: [`Arg.CH.F.Key`], [Arg.CH.F.Key]
at org.hibernate.cfg.Configuration$MappingsImpl$TableColumnNameBinding.bindPhysicalToLogical(Configuration.java:3185)
at org.hibernate.cfg.Configuration$MappingsImpl$TableColumnNameBinding.addBinding(Configuration.java:3158)
at org.hibernate.cfg.Configuration$MappingsImpl.addColumnBinding(Configuration.java:3202)
at org.hibernate.cfg.Ejb3JoinColumn.addColumnBinding(Ejb3JoinColumn.java:532)
at org.hibernate.cfg.Ejb3Column.linkWithValue(Ejb3Column.java:364)
at org.hibernate.cfg.annotations.TableBinder.linkJoinColumnWithValueOverridingNameIfImplicit(TableBinder.java:523)
at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:457)
at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:117)
at org.hibernate.cfg.Configuration.processEndOfQueue(Configuration.java:1596)
at org.hibernate.cfg.Configuration.processFkSecondPassInOrder(Configuration.java:1519)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1420)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:343)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:431)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:416)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)

我怎么能解决这个问题?

最佳答案

消除

@Id
@Column(name = "[Arg.CH.F.Key]", nullable = false)
private int argCHFKey;

因为您可以从 msv 对象中获取 key 。

关于java - DuplicateMappingException 由不同的逻辑列名表示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25018893/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com