Getting changes in one column of an historical table
- by Javi
Hello,
I have a table which stores historical data. It's mapped to an Entity with the following fields (I use JPA with Hibernate implementation):
@Entity
@Table(name="items_historical")
public class ItemHistory{
private Integer id;
private Date date;
@Enumerated(EnumType.ORDINAL)
private StatusEnum status
@ManyToOne(optional=false)
private User user;
@ManyToOne(optional=false)
private Item item;
}
public enum StatusEnum {
OK, BAD,...//my status
}
In every row I store historical data of another table. I need to get the list of the changes on "status" column: the status, the date and the previous status on a specified item (It would be good as well getting the status and date when status was changed). I don't know if this is possible by using HQL.
Thanks.