gpt4 book ai didi

java.sql.SQLSyntaxErrorException : Unknown column 'column_name' in 'field list' - mappings in entity are the same in as database

转载 作者:行者123 更新时间:2023-11-29 15:59:31 25 4
gpt4 key购买 nike

我收到“accepted_at”列标题中的错误,但是我看不到我在哪里犯了错误,因为我检查了列的名称,并且实体似乎已正确注释。使用了 Lombok,所以不要'不要奇怪为什么没有 setter 和 getter

@Id
@GeneratedValue
private Long id;
private Long version;

@Column(name = "accepted_at")
private Date acceptedAt;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "accepted_by_id")
private Account acceptedBy;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "account_id")
private Account account;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "token_id")
private Token token;

@Column(name = "date_created")
private Date dateCreated;

@Column(name = "is_accepted")
private Boolean isAccepted;

@Column(name = "is_enabled")
private Boolean isEnabled;

@Column(name = "last_updated")
private Date lastUpdated;

@Column(name = "organization_id")
private String organizationId;

@Column(name = "pending_status")
private int pendingStatus;

@Column(name = "pending_status_date")
private Date pendingStatusDate;

@Column(name = "profile_type")
private int profileType;

@Column(name = "valid_from")
private Date validFrom;

@Column(name = "valid_to")
private Date validTo;

以下是我如何通过脚本创建配置文件表的方法。

create table profile
(
id bigint(20) not null auto_increment,
version bigint(20) not null,
accepted_at datetime,
accepted_by_id bigint(20),
account_id bigint(20) not null,
token_id bigint(20),
date_created datetime,
is_accepted bit(1) not null,
is_enabled bit(1) not null,
last_updated datetime,
organization_id national varchar(10) not null,
pending_status int(11),
pending_status_date datetime,
profile_type int(11) not null,
valid_from datetime,
valid_to datetime,
primary key (id),
key organization_id (organization_id)
);

我使用 application.yml 而不是 application.properites。我希望这有点用处

 spring:
datasource:
url: jdbc:mysql://localhost/*****?serverTimezone=GMT
username: root
password: ******
jpa:
open-in-view: false
flyway:
enabled: true
thymeleaf:
suffix: .html
cache: false

最佳答案

请将您的 yml 属性替换为以下内容:

spring:
datasource:
url: jdbc:mysql://localhost/focus3?serverTimezone=GMT
username: root
password: 123456
jpa:
open-in-view: false
hibernate:
naming:
physical-strategy : org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
flyway:
enabled: true
thymeleaf:
suffix: .html
cache: false

因为,您的 yml 属性应如下所示以使用您的字段名称,

spring:
jpa:
hibernate:
naming:
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

关于java.sql.SQLSyntaxErrorException : Unknown column 'column_name' in 'field list' - mappings in entity are the same in as database,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56291013/

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