我有教师的父域和学生的子域(一对多)
学生具有“ student_certificate”实体,该实体是一个字节(准确地说是上传文件)
我在这里的关注点是我想分隔student_certificate并创建另一个Student_attachment域,但是我想做的一件事是将Student_attachment放在Student表上
有可能这样做吗?因为存在数据,所以创建另一个表是一种冒险的方式
答案 0 :(得分:1)
...但是我想做的一件事是将student_attachment放在 学生表
您可以使用embedded
属性,如下所示:
class Teacher {
String name
static hasMany = [students: Student]
}
class Student {
String name
StudentAttachment certificate
static embedded = ['certificate']
}
class StudentAttachment {
byte[] attachment
}
create table student (id bigint generated by default as identity, version bigint not null, name varchar(255) not null, certificate_attachment binary(255) not null, primary key (id));
create table teacher (id bigint generated by default as identity, version bigint not null, name varchar(255) not null, primary key (id));
create table teacher_student (teacher_students_id bigint not null, student_id bigint);