开发者

Getting changes in one column of an historical table

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;
}

publi开发者_开发问答c 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.


Why don't you use a solution like Hibernate Envers(formerly known as JBoss Envers) for the historical data instead of designing a custom solution? I think you'll find Envers's features quite compelling.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜