Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

spring data rest relationships

/*when working with relationships in spring data rest it's supper easy if you 
understand whats happening for example:
let's say we have an Entity Student*/
public class Student{
  	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
 	private long id;
 	@OneToMany
 	private set<Course> coursesList;
}

public class Courses{
  	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
    private long id;
    @OneToMany
    private set<Student> studentList;
}
/* this means that a new url will be generated by spring data rest
/student/coursesList and /courses/studentList and with thouse assosiation 
we can start sending POST request to add relationship or PUT request to replace
a relationship /*
/* to add a student to a list of courses you can send a POST request for example
to /courses/{courseID}/studentList/ and this request must have a 
Content-Type:text/uri-list in the header and the body must be a plain text 
containing the student url /student/{id} */
/*hope this explains every thing for you */
Happy Coding (●'◡'●)
Comment

PREVIOUS NEXT
Code Example
Java :: google intent for directions 
Java :: android studio cannot resolve @nullable 
Java :: Labeled continue Statement Java 
Java :: jaggies 
Java :: setsystemuivisibility example 
Java :: generate infinity steam java 
Java :: java commands in different packages not working 
Java :: java feld erstellen 
Java :: aws lambda upload file to s3 java 
Java :: Double matrix 
Java :: Program to check Vowel or Consonant using Switch Case 
Java :: newinstance in java giving exception 
Java :: getter and setter in java 
Java :: recursion java 
Java :: can abstract class have constructor in java 
Java :: The JAVA_HOME environment variable is not defined correctly, this environment variable is needed to run this program. 
Java :: Jlabel icon 
Java :: call activity method from adapter 
Java :: arraylist add at index 
Java :: java remove double spaces 
Java :: Java Lambda Expressions with parameters 
Java :: x = x + y; in java 
Java :: java color light gray 
Java :: why does the ribbon dependency crush my app 
Sql :: mysql workbench turn off safe mode 
Sql :: oracle see column type 
Sql :: psql kill pid 
Sql :: SELECT list is not in GROUP BY clause 
Sql :: sql now - 1 day 
Sql :: mysql change database charset and collation 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =