> For the complete documentation index, see [llms.txt](https://olavo-moreira.gitbook.io/studies/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://olavo-moreira.gitbook.io/studies/estudo-definitivo-orm/resource.md).

# Resource

[Entidade](https://github.com/zenonxd/modelo-dominio-complexo/blob/main/src/main/java/com/devsuperior/educandoweb/dslearn/entities/Resource.java)

⬇️ Lembrar de criar Getters and Setters + equals\&hashcode com ID.

❗Nunca coloque um Set do relacionamento dentro do construtor.

```java
@Entity
@Table(name = "tb_resource")
public class Resource {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String title;
    private String description;
    private Integer position;
    private String imgUri;
    private ResourceType type;

    @ManyToOne
    @JoinColumn(name = "offer_id")
    private Offer offer;

    @OneToMany(mappedBy = "resource")
    private List<Section> sections = new ArrayList<>();
```
