I have a class with many fields of type List<> because I need to save a log history for every change. For example:
public class Student {
private int id;
private List<Log> name;
private List<Log> lastname;
private List<Log> phone;
}
public class Log {
private int id;
private Date date;
private User user;
private String content;
}
So, every time a user make an update, it will be saved on log table. The problem is I don't know how to make the relationship between them. I'm using hibernate. And that is only Student class, but I have about 10 more classes with the same scenario.
Is there a better way to do that? maybe a pattern design?
From a design standpoint, I would prefer to have a versioned Student table, with a timestamp for each version. Then you can easily determine what lastName and firstName were at a given point in time.
Hibernate supports a few different approaches to this as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.