第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

jpa 引用外部表而不是 JoinColumn 中的外部列

jpa 引用外部表而不是 JoinColumn 中的外部列

瀟湘沐 2021-12-30 17:17:47
應用程序和歷史有OneToMany:@Entity@Table(name = "app")@SuppressWarnings("serial")public class App implements Serializable {    @Id     @Column(name = "app_id")    @GeneratedValue(strategy = GenerationType.AUTO)    private Long appId;    private String name;    @OneToMany(fetch = FetchType.LAZY, mappedBy = "app", cascade = CascadeType.PERSIST)    private Set<History> history = new HashSet<>();    //get.set}@Entity@Table(name = "app_history")@SuppressWarnings("serial")public class History implements Serializable {    @Id    @Column(name = "history_id")    @GeneratedValue(strategy = GenerationType.AUTO)    private Long historyId;    @JoinColumn(name = "appId")    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)    private App app;    //get.set}在日志中看到:create table app (app_id int8 not null, name varchar(255), primary key (app_id))create table app_history (history_id int8 not null, app_id int8, primary key (history_id))alter table app_history add constraint FKeuk3km6r7oklj5xc1ecwvxmkm foreign key (app_id) references app期望上面的行是alter table app_history add constraint FKeuk3km6r7oklj5xc1ecwvxmkm foreign key (app_id) references app (app_id)那么,(app_id)當 jpa 嘗試創(chuàng)建表時為什么會丟失?
查看完整描述

2 回答

?
慕容708150

TA貢獻1831條經(jīng)驗 獲得超4個贊

改變你的

@JoinColumn(name = "appId")

@JoinColumn(name = "app_id")

這應該有效。


查看完整回答
反對 回復 2021-12-30
?
明月笑刀無情

TA貢獻1828條經(jīng)驗 獲得超4個贊

問題是:您使用的是 MySQL 數(shù)據(jù)庫,但 JPA 使用的方言是針對 PostgreSQL 的:


spring: 

  main: 

    banner-mode: "off"

  datasource: 

    url: jdbc:mysql://localhost:3306/cifi3?useSSL=false&allowPublicKeyRetrieval=true

    username: tester

    password: tester

  jpa: 

    database-platform: org.hibernate.dialect.PostgreSQLDialect

    show_sql: true

    hibernate:

      ddl-auto: create-drop

      format_sql: true

  data:

    rest:

      basePath: /repo

我建議你改變database-platform: org.hibernate.dialect.PostgreSQLDialect的database-platform: org.hibernate.dialect.MySQLDialect


查看完整回答
反對 回復 2021-12-30
  • 2 回答
  • 0 關注
  • 155 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號