I am unable to understand what @ElementCollection does in this code. I need to write its Python equivalent.
package project.models;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import java.util.List;
@Getter
@Setter
@Entity
public class Movie extends BaseModel {
private String name;
@ManyToMany
private List<Actor> actors;
@ElementCollection
@Enumerated(EnumType.ORDINAL)
private List<Feature> movieFeatures;
@ElementCollection
@Enumerated(EnumType.ORDINAL)
private List<Genre> genre;
}
I have to write this class. Can someone verify if this is correct?
class Movie(BaseModel):
def __init__(self, name, actors, movieFeatures, genre):
self.name = name
self.actors = actors
self.movieFeatures = movieFeatures
self.genre = genre
That is an Annotation, here is the Java tutorial.
Lesson: Annotations (The Java™ Tutorials > Learning the Java Language).
More specifically, it appears this code is mapping the fields to a database.
So far it looks correct.
Please post the code for BaseModel, Actor, Feature, and Genre, as the annotations in these classes will help determine the correct Python code.