I'm using Spring + JPA and i have mapped an entity as an Database View, where i got all fields.
Now i want add one field to this entity and return a link image based to another field (all image are stored in resource/images)
@Entity
@Table(name = "Release")
public class Release implements Serializable
{
private String user;
private String userImageLink; // This is what i need to implement
@XmlElement
@JsonProperty
public String getUser(){
return user;
}
public void setUser(String user) {
this.user = user;
}
public String getUserImageLink(){
String imageUrl = /*i need to access to resource/images and create the link
If i run on localhost should return: http://127.0.0.1:8080/resources/images..
In production coudl return: http://myServer.com/resources/images..
*/;
return imageUrl;
}
}
}
The question is: how i can create and return this url ?
MORE INFO
If the table have 3 entry: User1, User2, User3
In the userImageLink i should return:
http://myserver.com/resources/images/User1.jpg http://myserver.com/resources/images/User2.jpg
Isn't important if the image exists or not in resources/image, i just need to compose the url as additional parameter when i access to the Service that take the data from my "Release" @Entity