gpt4 book ai didi

java - 关键字 'statistics' 附近的语法不正确。 Spring.IO

转载 作者:行者123 更新时间:2023-12-01 11:10:20 26 4
gpt4 key购买 nike

我正在编写此 API 来获取 YoutubeAPI v3 的一些详细信息并将其发布到数据库。

目前我在创建表时遇到此错误:

2015-09-08 11:22:40.795 ERROR 11384 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000389: Unsuccessful: create table ccccVideoDetailsItems (dbid numeric(19,0) identity not null, etag varchar(255), id varchar(255), kind varchar(255), statistics numeric(19,0), primary key (dbid))
2015-09-08 11:22:40.795 ERROR 11384 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : Incorrect syntax near the keyword 'statistics'.

我的头上几乎没有头发了,因为我找不到问题所在。

我有这三个类来检索每个对象。视频详细内容:

@Entity
@Table(name="ccccVideoDetailsContent")
public class VideoDetailsContent {
@Id
private String kind;
private String etag;


@OneToOne
@Transient
private List<DetailsContentItem> items;

public VideoDetailsContent() {
}

public String getKind() {
return kind;
}

public void setKind(String kind) {
this.kind = kind;
}

public String getEtag() {
return etag;
}

public void setEtag(String etag) {
this.etag = etag;
}

public List<DetailsContentItem> getItems() {
return items;
}

public void setItems(List<DetailsContentItem> items) {
this.items = items;
}
}

详细内容内容:

@Entity
@Table(name="ccccVideoDetailsItems")
public class DetailsContentItem {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "dbid")
private Long dbId;

private String kind;
private String etag;
@Column(name = "id")
private String id;

// @OneToOne(cascade = CascadeType.ALL,orphanRemoval = true)
// @JoinColumn(name = "sID")
@OneToOne
VideoStatistics statistics;

public DetailsContentItem() {
}

public Long getDbId() {
return dbId;
}

public void setDbId(Long dbId) {
this.dbId = dbId;
}

public String getKind() {
return kind;
}

public void setKind(String kind) {
this.kind = kind;
}

public String getEtag() {
return etag;
}

public void setEtag(String etag) {
this.etag = etag;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public VideoStatistics getStatistics() {
return statistics;
}

public void setStatistics(VideoStatistics statistics) {
this.statistics = statistics;
}
}

视频统计:

@Entity
@Table(name = "ccccVideoStatistics")
public class VideoStatistics {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private long id;

private long viewCount;
private long likeCount;
private long dislikeCount;
private long favoriteCount;
private long commentCount;

public VideoStatistics() {
}

public VideoStatistics(long id, long viewCount, long likeCount, long dislikeCount, long favoriteCount, long commentCount) {
this.id = id;
this.viewCount = viewCount;
this.likeCount = likeCount;
this.dislikeCount = dislikeCount;
this.favoriteCount = favoriteCount;
this.commentCount = commentCount;
}

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public long getViewCount() {
return viewCount;
}

public void setViewCount(long viewCount) {
this.viewCount = viewCount;
}

public long getLikeCount() {
return likeCount;
}

public void setLikeCount(long likeCount) {
this.likeCount = likeCount;
}

public long getDislikeCount() {
return dislikeCount;
}

public void setDislikeCount(long dislikeCount) {
this.dislikeCount = dislikeCount;
}

public long getFavoriteCount() {
return favoriteCount;
}

public void setFavoriteCount(long favoriteCount) {
this.favoriteCount = favoriteCount;
}

public long getCommentCount() {
return commentCount;
}

public void setCommentCount(long commentCount) {
this.commentCount = commentCount;
}
}

API 输出为:

{
kind: "youtube#videoListResponse",
etag: ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/15jlenwUohs80IG8APFsDfw7xb8"",
pageInfo: {
totalResults: 1,
resultsPerPage: 1
},
items: [
{
kind: "youtube#video",
etag: ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/sCA7RDne1nKYHc3Fiqawl_oS3sk"",
id: "g_AT2djYGmA",
statistics: {
viewCount: "149353",
likeCount: "2369",
dislikeCount: "21",
favoriteCount: "0",
commentCount: "251"
}
}
]
}

为什么我会收到这个错误?

最佳答案

我写代码的时候脑子有问题。

所以我通过重构 VideoStatistics 类解决了这个问题。

将所有输入设置为 String 而不是 Long,因为我从 Youtube api 获取了一个字符串。

关于java - 关键字 'statistics' 附近的语法不正确。 Spring.IO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32454098/

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