Skip to content

Commit

Permalink
Merge pull request #38 from UdL-EPS-SoftArch/Feature-Room-Apartment-r…
Browse files Browse the repository at this point in the history
…elation

Room-apartment-relation added
  • Loading branch information
elskater98 authored Oct 9, 2024
2 parents 18ca6df + 47a0b46 commit 6363833
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main/java/cat/udl/eps/softarch/demo/domain/Apartment.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package cat.udl.eps.softarch.demo.domain;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.ZonedDateTime;
import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Entity
@Entity(name = "apartment")
@Data
public class Apartment extends UriEntity<Long> {
@Id
Expand All @@ -34,4 +30,8 @@ public class Apartment extends UriEntity<Long> {
@ManyToOne
@JoinColumn(name = "user_id")
private Owner owner;


@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
public List<Room> rooms;
}
8 changes: 8 additions & 0 deletions src/main/java/cat/udl/eps/softarch/demo/domain/Room.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package cat.udl.eps.softarch.demo.domain;

import cat.udl.eps.softarch.demo.domain.UriEntity;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import lombok.*;

@EqualsAndHashCode(callSuper = true)
Expand All @@ -22,4 +26,8 @@ public class Room extends UriEntity<Long> {
private boolean hasDesk;
private boolean hasBed;


@ManyToOne()
private Apartment apart;

}

0 comments on commit 6363833

Please sign in to comment.