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

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

舊實(shí)體版本的 Spring Boot 參考

舊實(shí)體版本的 Spring Boot 參考

蝴蝶刀刀 2023-06-04 10:25:04
我對 Spring Boot 有疑問。我在資源文件夾和一個實(shí)體中有一個 Schema.sql。在第一次運(yùn)行應(yīng)用程序時,一切都按預(yù)期工作。但是當(dāng)我更改 schema.sql 中的列名、更新我的實(shí)體、刪除數(shù)據(jù)庫表并重新運(yùn)行應(yīng)用程序時,Spring 始終創(chuàng)建舊的實(shí)體列名。在我的 application.properties 中,我有以下條目:spring.datasource.name                   = mydatasourcespring.datasource.url               = jdbc:mysql://localhost:3306/dbname?serverTimezone=UTC&createDatabaseIfNotExist=truespring.datasource.driver-class-name      = com.mysql.cj.jdbc.Driverspring.datasource.password               = passwordspring.datasource.username               = usernamespring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialectspring.jpa.show-sql=falsespring.jpa.hibernate.ddl-auto=updatesecurity.oauth2.client.clientId= my_clientsecurity.oauth2.resource.id= myidsecurity.oauth2.client.clientSecret= my_srcretsecurity.oauth2.client.accessTokenUri= http://localhost:8080/api/oauth/tokensecurity.oauth2.client.userAuthorizationUri= http://localhost:8080/api/oauth/authorizesecurity.oauth2.resource.token-info-uri=http://localhost:8080/api/oauth/check_tokenlogging.level.org.springframework.web=DEBUG我的新實(shí)體:@Entity@Table(name = "organizers")public class Organizer implements Serializable {    private static final long serialVersionUID = 1L;    @Id    @GeneratedValue(strategy = GenerationType.IDENTITY)    @Column(name = "id")    private Long id;    @Column(name = "commercialName")    private String commercialName;    @Column(name = "org_description")    private String description;    @Column(name = "verified")    private boolean verified;    @Column(name = "isOnline")    private boolean isOnline;    @Column(name = "org_type")    private OrganizerType type;    @Column(name = "alias")    private String alias;    @Column(name = "fone")    private String fone;    @OneToOne(fetch = FetchType.EAGER)    @JoinColumn(name = "userId")    private User user;}
查看完整描述

2 回答

?
守候你守候我

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超10個贊

它沒有引用舊的實(shí)體版本,它只是看起來像那樣。在應(yīng)用程序?qū)傩灾性O(shè)置 spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.EJB3NamingStrategy。

默認(rèn)情況下,spring 使用 org.springframework.boot.orm.jpa.SpringNamingStrategy。這會將 commercialName(駝峰式)之類的任何內(nèi)容轉(zhuǎn)換為 commerical_name。設(shè)置上述屬性將覆蓋此行為。


查看完整回答
反對 回復(fù) 2023-06-04
?
萬千封印

TA貢獻(xiàn)1891條經(jīng)驗(yàn) 獲得超3個贊

spring.jpa.hibernate.ddl-auto=update

設(shè)置為update以便休眠更新您的模式,它應(yīng)該被完全刪除,以便 flyway 可以從創(chuàng)建模式schema.sql。

此外,您需要添加以下配置以啟用從 flyway 創(chuàng)建模式:

spring.datasource.initialization-mode=always

從文檔數(shù)據(jù)庫初始化

在基于 JPA 的應(yīng)用程序中,您可以選擇讓 Hibernate 創(chuàng)建架構(gòu)或使用 schema.sql,但您不能同時執(zhí)行這兩項(xiàng)操作。如果您使用 schema.sql,請確保禁用 spring.jpa.hibernate.ddl-auto。

此外,您的實(shí)體映射存在錯誤。新實(shí)體引用該列@Column(name = "org_description"),但在您的新模式定義中,該列被稱為 just?description,一旦您的模式創(chuàng)建工作,您需要更新您的列映射。


查看完整回答
反對 回復(fù) 2023-06-04
  • 2 回答
  • 0 關(guān)注
  • 172 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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