Say you have a car with a collection of tires.
@Entity public class Car { private Long id; @OneToMany(mappedBy = "car") private Set<Tire> tires = new HashSet<>(); } @Entity public class Tire { private Long id; ... }
Now, if you want to add a new car and add existing tires, you can get all existing Tire objects to fill the Car Set.
Is it possible to simply have several bus identifiers and save the car without first inserting the entire bus object into memory? Is there a way to save it with only the bus id if it were just a Single Tire instance instead of Set? Using JPA and API criteria, or possibly JPQL.
source share