0

I have a base class:

@MappedSuperclass
public abstract class SuperClass{
    @Id
    protected Long id;

    public Long getId() {
        return id;
    }
}

The @GeneratedValue is not used since the id is generated using a BackendSession

There are a lot of inheritance from this class so one can't change it!

my sub class: I tried to override the getId method

@Entity
@Table(name = "FTC_DATA")
@SequenceGenerator(name="sequence", sequenceName = "FTC_DATA_SEQ")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class SubClass extends SuperClass {

    @Override
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "FTC_DATA_SEQ")
    public void getId(Long id) {
        this.id = id;
    }
}

But I fail on IdentifierGenerationException, what am I doing wrong?

Avital A.
  • 183
  • 1
  • 9
  • Maybe this answers your question: https://stackoverflow.com/questions/8589928/mappedsuperclass-change-sequencegenerator-in-subclass – R.Groote Feb 13 '20 at 06:50
  • I tried https://stackoverflow.com/questions/8589928/mappedsuperclass-change-sequencegenerator-in-subclass - but it is with changing the super class to have GeneratedValue. – Avital A. Feb 13 '20 at 06:57

1 Answers1

0

Here's what worked for me. Remove getId() from SuperClass, remove the @Override from SubClass getId() and move the @Id annotation to the SubClass getId().

JR Ector
  • 1
  • 1
  • 1