I have three classes corresponding to three tables in mysql database. My classes are as follows.
@Entity
@Table(name="location")
public class Location {
private Integer locationId;
private Integer hospitalId;
private Integer regionId;
private String locationCode;
private String locationName;
private String locationType;
@Entity
@Table(name="hospital_region")
public class HospitalRegion {
private Integer regionId;
private Integer hospitalId;
private String regionCode;
private String regionName;
public enum Status{Active,Inactive}
private Status status;
@Entity
@JsonAutoDetect
@Table(name="hospital_information")
public class HospitalInformation{
private Integer hospitalId;
private String shortName;
private String name;
private Integer packageId;
private Date implementationDate;
private Date validFrom;
private Date validUpTo;
private Date lastUpload;
public enum SubscriptionType{Free,Complimentary,Paid}
private Integer totalUsers;
I am making a Web Services for a Hospital Application where one region could have multiple locations(one-to-many) and one hospital could be in multiple regions(one-to-many).
So what I want to do is make a web service that would insert the data into location table.The ideal workflow should be that I shall pass every field in Location class as a json
object to insert a record into the Location table.
My Business Logic
should first check for my regionId
and hospitalId
value passed in the json
object . If the hospitalId
which is passed corresponds to the value of regionId
in region table
, if both correspond, only then data should be saved.
So I need help about how to implement it as a Business Logic
.Thanks in advance