how save child entity spring data jpa repositories if know parent id?
for example if have 1 many relation:
@entity public class customer { @id @generatedvalue(strategy=generationtype.auto) private long id; private string firstname; private string lastname; @manytoone private customercategory category; } @entity public class customercategory { @id @generatedvalue(strategy=generationtype.auto) private long id; private string name; }
one can like:
customercategory somecategory = customerrepository.findone(1l);// how skip line. id should enough. customer cust = new customer("evgeni", "dimitrov", somecategory); customerrepository.save(cust);
jpa can load
(just create proxy , set id) instead of 'get'(select db). possible spring data jpa?
Comments
Post a Comment