[FIX] Entity間の関係を修正しました。
This commit is contained in:
@@ -26,7 +26,8 @@ public class AllocationEntity {
|
|||||||
private CategoryEntity categoryEntity;
|
private CategoryEntity categoryEntity;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@OneToOne(mappedBy = "courseId", fetch = FetchType.LAZY)
|
@OneToOne(fetch = FetchType.LAZY)
|
||||||
|
@JoinColumn(name = "course_id")
|
||||||
private CourseEntity courseEntity;
|
private CourseEntity courseEntity;
|
||||||
|
|
||||||
@Column(name = "allocation_ratio", nullable = false)
|
@Column(name = "allocation_ratio", nullable = false)
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package com.example.demo.app.infra.entity;
|
package com.example.demo.app.infra.entity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.OneToMany;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -28,4 +31,10 @@ public class CategoryEntity {
|
|||||||
|
|
||||||
@Column(name = "transaction_type", nullable = false)
|
@Column(name = "transaction_type", nullable = false)
|
||||||
private Integer transactionType;
|
private Integer transactionType;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "categoryEntity")
|
||||||
|
private List<TransactionEntity> transactionEntity;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "categoryEntity")
|
||||||
|
private List<AllocationEntity> allocationEntity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package com.example.demo.app.infra.entity;
|
package com.example.demo.app.infra.entity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.OneToMany;
|
||||||
|
import jakarta.persistence.OneToOne;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
@@ -31,4 +35,10 @@ public class CourseEntity {
|
|||||||
@Column(name = "description", nullable = false)
|
@Column(name = "description", nullable = false)
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "courseEntity")
|
||||||
|
private List<UserEntity> userEntity;
|
||||||
|
|
||||||
|
@OneToOne(mappedBy = "courseEntity")
|
||||||
|
private List<AllocationEntity> allocationEntity;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import jakarta.persistence.Entity;
|
|||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.OneToOne;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -40,4 +41,7 @@ public class GoalEntity {
|
|||||||
@Column(name = "goal_complete", nullable = false)
|
@Column(name = "goal_complete", nullable = false)
|
||||||
private Integer goalComplete;
|
private Integer goalComplete;
|
||||||
|
|
||||||
|
@OneToOne(mappedBy = "goalEntity")
|
||||||
|
private UserEntity userEntity;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package com.example.demo.app.infra.entity;
|
package com.example.demo.app.infra.entity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.OneToMany;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -26,4 +29,7 @@ public class QuestionEntity {
|
|||||||
@Column(name = "question_text", nullable = false)
|
@Column(name = "question_text", nullable = false)
|
||||||
private String questionText;
|
private String questionText;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "QuestionEntity")
|
||||||
|
private List<UserEntity> userEntity;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,11 +35,11 @@ public class TransactionEntity {
|
|||||||
private LocalDate transactionDate;
|
private LocalDate transactionDate;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "userId")
|
@JoinColumn(name = "user_id")
|
||||||
private UserEntity userEntity;
|
private UserEntity userEntity;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "categoryId")
|
@JoinColumn(name = "category_id")
|
||||||
private CategoryEntity categoryEntity;
|
private CategoryEntity categoryEntity;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.example.demo.app.infra.entity;
|
package com.example.demo.app.infra.entity;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
@@ -10,6 +11,7 @@ import jakarta.persistence.GenerationType;
|
|||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.JoinColumn;
|
import jakarta.persistence.JoinColumn;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.OneToMany;
|
||||||
import jakarta.persistence.OneToOne;
|
import jakarta.persistence.OneToOne;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
@@ -56,11 +58,14 @@ public class UserEntity {
|
|||||||
@Column(name = "delete_flag", nullable = false)
|
@Column(name = "delete_flag", nullable = false)
|
||||||
private Integer deleteFlag;
|
private Integer deleteFlag;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "userEntity")
|
||||||
|
private List<TransactionEntity> transactionEntity;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "question_id")
|
@JoinColumn(name = "question_id")
|
||||||
private QuestionEntity questionEntity;
|
private QuestionEntity questionEntity;
|
||||||
|
|
||||||
@OneToOne(mappedBy = "goalId", fetch = FetchType.LAZY)
|
@OneToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "goal_id")
|
@JoinColumn(name = "goal_id")
|
||||||
private GoalEntity goalEntity;
|
private GoalEntity goalEntity;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user