ฉันมีคำถามด่วน ฉันกำลังพยายามทำให้ข้อมูลที่ติดตาม: Auth(อีเมลล์ส่ง)->ลูกค้าของ(ชื่อ,นามสกุล,...) Auth(อีเมลล์ส่ง)->RepairShop(nip สถานที่...)
Auth
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Auth {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long authid;
ลูกค้า
@Entity
public class Client extends Auth{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long idClient;
...
@ManyToOne
private RepairShop repairShop;
RepairShop
@Entity
public class RepairShop extends Auth{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long idRepairShop;
...
@OneToMany(cascade = CascadeType.ALL, mappedBy = "repairShop")
private Set<Client> clients;
กับ repositories ดูเหมือน AuthRepository
public interface AuthRepository extends JpaRepository<Long, Auth>{
}
ClientRepository
public interface ClientRepository extends JpaRepository<Client,Long> {
}
RepairShopRepository
public interface RepairShopRepository extends JpaRepository<RepairShop, Long> {
}
Auth ไม่สามารถเป็นแบบนามปธรรมนักเรียน,นี่คือเดียวบนโต๊ะที่มี auth อยู่ในโครงการของฉัน (ค่าที่ใช้ในปัจจุบันฉันเพิ่งด้วยตนเองถูกเพิ่มโต๊ะกับบางอย่าให้ต้องเขียนข้อมูลจากลูกค้าและ RepairShop จะ Auth แต่ฉันกำลังมองหาดีกว่าทางออก)
เป้าหมายของฉันต้องมีฐานข้อมูลเหมือน Auth idauth อีเมล ขอผ่าน บทบาท
ลูกค้า idclient ชื่อ นามสกุล idauth
RepairShop idrepairShop nip ตำแหน่ง idauth
มันเป็นไปได้ที่จะทำมันเหมือนติดตาม? หรือมันเป็นเพียงแค่ความคิดที่แย่มากและฉันควรจะใช้ onetoone ความสัมพันธ์และไม่แม้แต่จะเล่นแบบนี้ หรือบางทีอาจจะมีบางอย่าดีกว่าทางออกในฐานข้อมูลโครงสร้างของ. ยังมันคือสิ่งสำคัญสำหรับปล่อยให้มันง่ายทำงานกับแอ๊ปสี่เหลี่ยมไปอย่างง่ายดายต้องการเข้าถึงจากการทำปูมบันทึกกับข้อมูลจาก auth ต้องจัดการกันคุณสมบัติของจากลูกค้า/RepairShop ตารางข้อมูลเรียบร้อยแล้ว
ฉันคิดว่าปัญหาที่ต้องโกหกของฉันเก็บ config แต่ข้อความด่วนทันใจไม่แน่ใจ
เธอคิดยังไงเกี่ยวกับมัน?