문제

I' ve got 2 tables... Challenge and ChallengeYear, ChallengeYear is only to create a list of years in challenge.

I only want to make Challenge an entity, containing a list of List years. Is this possible?

I've looked in to @SecondaryTable together with @JoinColumn and @OneToMany, but neither of those can do the trick, or i am overlooking something.

Can someone help me?

Greetings, Jan

도움이 되었습니까?

해결책

What is Year in your model, is it an Integer ?

if yes, you may annotate your Challenge.getYears method with @CollectionOfElements

like:

  @CollectionOfElements
  @JoinTable(
    table=@Table(name="ChallengeYear"),
    joinColumns = @JoinColumn(name="challengeId")
  )
  @Column(name="year", nullable=false)
  List<Integer> getYears() {
    ...
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top