Getting changes in one column of an historical table

Posted by Javi on Stack Overflow See other posts from Stack Overflow or by Javi
Published on 2010-06-15T10:18:32Z Indexed on 2010/06/15 10:22 UTC
Read the original article Hit count: 140

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about jpa