Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
460 views
in Technique[技术] by (71.8m points)

Spring-Boot JPA - Inserting into Two Table Relation Inheritance with single forms in angular

I'm attempting to save records to a database two table that includes a foreign key using Spring-Boot and angular but I don't know how to figure it :

by the way this is my entities classes with relation inheritance :

Entitie User

Entitie Patient

And For consuming data API I use this post method for register :

Register Post Controller Api

In Angular Projet I have Put This Register Method on services for user :

  const API_URL = 'http://localhost:8080/api/user/';
  register(user: User): Observable<any> {
    return this.http.post(API_URL + 'registration', JSON.stringify(user),
  {headers: {'Content-Type': 'application/json; charset=UTF-8'}});
  }

And For Register Component I Use this :

register() {
this.userService.register(this.user).subscribe(data => {
  this.router.navigate(['/login']);
}, err => {
  this.errorMessage = 'Username is already exist.';
});   }

so in this case I want when it files all form input and click on insert it will insert data for both table user and patient at the same.

any help can be appreciated thank uu


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...