Search in sources :

Example 1 with Location

use of com.xiaolyuh.entity.Location in project spring-boot-student by wyh-spring-ecosystem-student.

the class DataController method save.

@RequestMapping("/save")
public Person save() {
    Person p = new Person("wyf", 32);
    Collection<Location> locations = new LinkedHashSet<Location>();
    Location loc1 = new Location("上海", "2009");
    Location loc2 = new Location("合肥", "2010");
    Location loc3 = new Location("广州", "2011");
    Location loc4 = new Location("马鞍山", "2012");
    locations.add(loc1);
    locations.add(loc2);
    locations.add(loc3);
    locations.add(loc4);
    p.setLocations(locations);
    return personRepository.save(p);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Person(com.xiaolyuh.entity.Person) Location(com.xiaolyuh.entity.Location) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Location (com.xiaolyuh.entity.Location)1 Person (com.xiaolyuh.entity.Person)1 LinkedHashSet (java.util.LinkedHashSet)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1