我有以下数据库模型
create table Diary (id bigint NOT NULL AUTO_INCREMENT,
creationDate TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
name varchar(255) not null,
description text,
viewtype varchar(255) not null,
member bigint,
primary key (id),
foreign key (member) references Member(id));
create table Page (id bigint NOT NULL AUTO_INCREMENT,
creationDate TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
viewtype varchar(255) not null,
diary bigint,
member bigint,
primary key (id),
foreign key (diary) references Diary(id),
foreign key (member) references Member(id));
create table Comment (id bigint NOT NULL AUTO_INCREMENT,
postingDate TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
comment text not null,
page bigint,
member bigint,
primary key (id),
foreign key (page) references Page(id)
foreign key (member) references Member(id));
我正在使用 spring JDBC 模板。
My interface looks like follows: accountid is the memeberid in the database.
Collection<Diary> getDiaries(Long accountId);
我的日记如下:
public class Diary {
private Collection<Page> pages;
private Long id;
private LocalTime creationDate;
private String name;
private String description;
private ViewType type;
}
如果我想使用 jdbc 模板准备一个日记对象,我想知道查询现在的样子。也可以只触发一个查询并准备这个 Diary 对象,因为我将避免针对同一请求多次触发查询。对于上面的接口,我很可能会使用 s 连接查询,或者是否有更简单的方法可以使用 spring JDBC 模板框架。