Hi,
I would need a bit support for my MIT licensed Spring REST project where I already successfully
can persist books.
I have a problem with movies. The difference to the books? The depth of the data tree +1
I'll explain it here:
- A movie is an entity (like the book)
- A movie has a list of roles (I've tried @OneToMany, @Embedded and @ElementList)
- A role is a performer (I've tried inside that class @Entity and @Embeddable) and a roleName (String)
- There are other data like list of directors, list of composers, list of tags and each of them are entity with @OneToMany and are working fine (when I comment out the role part)
- One intention is that performer finally results in a separate table so I can query the list over all performers.
When I'm trying to persist the movie the objectdb complains that It cannot "find" the performer or - depending on the annotations - it complains that one object is not an entity.
How do I have to organize the "role" thing that I get persisted correctly?
kind regards,
Thomas
APPENDIX:
I'm using lombok ...
@Entity
@Data
@NoArgsConstructor
@RequiredArgsConstructor
public class Performer implements Serializable {
/** version of class. */
private static final long serialVersionUID = 1L;
/** full name of movie performer. */
@Id
@NonNull
private String fullName;
}
@Embeddable
@Data
@NoArgsConstructor
@RequiredArgsConstructor
@Builder public class Role implements Serializable {
/** version of class. */
private static final long serialVersionUID = 1L;
/** real name of person in life. */
@NonNull
@ManyToOne(cascade = CascadeType.MERGE)
private Performer performer;
/** rolen name of person in movie. */
@NonNull
private String roleName;
}