I'm trying to save an object into a database table but when the record is saved the name
value is empty. I'm using Spring and Hibernate.
When I log the object in the MovieController
:
@RequestMapping(value = "/", method = RequestMethod.POST)
public Movie createMovie(@RequestBody Movie movie){
System.out.println(movie.toString());
return movieService.createMovie(movie);
}
I see this value being logged.
com.movieseat.models.Movie@abee456
What I would expect is
id: 20, name: Star Wars
In my app.component.ts
I have:
createMovie(movie: Movie): void {
this._dataService.createMovie<Movie>({'id': 20, 'name': 'Star Wars'})
.subscribe((data) => this.movie = data,
error => () => {
'something went wrong';
},
() => {
console.log(this.movies);
});
}
The app.service.ts
public createMovie<T>(movie: Movie): Observable<T> {
console.log(movie);
return this.http.post<T>('/api/movies/', movie);
}
So why is the System out returning the object and not the values in the object? Or at least I think that's what it's doing.