[hibernate-issues] [Hibernate-JIRA] Created: (ANN-838) Can't override @GenericGenerator annotation from @MappedSuperclass

Aliaksej Memelau (JIRA) noreply at atlassian.com
Mon Jun 1 10:27:13 EDT 2009


Can't override @GenericGenerator annotation from @MappedSuperclass
------------------------------------------------------------------

                 Key: ANN-838
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-838
             Project: Hibernate Annotations
          Issue Type: Bug
    Affects Versions: 3.4.0.GA
         Environment: JVM 1.6, Hibernate core 3.3.1.GA
            Reporter: Aliaksej Memelau
            Priority: Critical


I want to override @GenericGenerator in a subclass,
@MappedSuperclass
public class Entity {
    @Id
    @Column(name="ID")
    @GeneratedValue(generator = "a_generator")
    @GenericGenerator(
        name = "a_generator",
        strategy = "a_strategy"
    )
    private Long id;
    ...
}

but, the following code doesn't work
@Entity
@Table("A_TABLE")
@GenericGenerator(
    name = "a_generator",
    strategy = "a_strategy_2"
)
public class SubEntity extends Entity {...}

When I try to pull out @GenericGenerator annotation from Entity's id to the class level hibernate throws:
org.hibernate.AnnotationException: Unknown Id.generator: a_generator

I suppose the following code should work:

@MappedSuperclass
@GenericGenerator(
    name = "a_generator",
    strategy = "a_strategy"
)
public class Entity {
    @Id
    @Column(name="ID")
    @GeneratedValue(generator = "a_generator")
    private Long id;
    ...
}

@Entity
@Table("A_TABLE")
@GenericGenerator(
    name = "a_generator",
    strategy = "a_strategy_2"
)
public class SubEntity extends Entity {...}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list