Hibernate: Own ID-Generator Sequence for every entity

Viewed 434

I currently use this approach for generating ids:

@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

The effect is, when I save enity of type A it gets the id '1', then I save Enity B and it gets id '2' (instead of 1, because its another entity type), then I save an entity of type A again and it gets id '3' (instead of 2).

What I would like is, that Hibernate counts the ID sequence for every Entity-Type for its own. Is that possible?

1 Answers
Related