I've successfully defined a sequence generator via annotations in an inheritance relationship roughly like so:
@MappedSuperclass
public class DomainObject {
@Id
@Column( columnDefinition = "serial" )
@GeneratedValue( generator = "id_sequence", strategy = GenerationType.IDENTITY )
private long id = 0;
}
@Entity
@Table( name = "user" )
@SequenceGenerator( name = "id_sequence", sequenceName = "user_id_seq" )
public class User extends DomainObject {
}
In this example, the User class's sequence generator finds id_sequence from the Generated value annotation in DomainObject.
However, if I make DomainObject an abstract class and place it in another dependency (everything else about it remains the same), I get an exception:
org.hibernate.AnnotationException: Unknown Id.generator: id_sequence
In the changed version, the DomainObject dependency is in the @ComponentScan path, so I'm unsure as to why this isn't working. Any thoughts?