I'm working through a tutorial on Spring MVC and I am getting an error in my StoreController that I cant seem to sort. The two code snippets I have added are StoreController.java and Genre.java which is an Entity class. I am getting an error @ line 76 of StoreController as follows: The method getName() is undefined for type Integer. I will add the code just below and I hope someone can help me understand my problem:
Thanks and regards
Album class is not being modelled the right way. Make it related to Genre and Artist entities directly by having them as members, instead of their IDs.
The ID management is supposed to be handled transparently by the ORM.
Then album.getGenre().getName().equals(genreName) makes sense because getGenre() is returning an actual Genre object, instead of its Integer ID.
Thanks for your helpful replies,
Do you mean that I need to add imports statements for each entity class and model class I refer to in the StoreController class.
Apologies for my newbie fumblings
I meant model the relationships between Album and Genre, and Album and Artist, in a natural way. The Album should have Genre and Artist as members, not their IDs.
Currently, you have their IDs as members and so Album.getGenre() returns an Integer object. How can an Integer object have a getName() method?
I have followed the tutorial line for line and it worked on the tutors side but when I entered the code as per tutorial I got the getName() problem. I dont understand what you mean by making them as members of the Album class and not their ID's as members. Apologies for my lack of understanding.
Of course, I found a very beautiful couch. Definitely. And this tiny ad: