java - References to one to many relationship objects doesn't update -



java - References to one to many relationship objects doesn't update -

class person { list<skill> skills; //... other stuff } class skill{ //stuff } myskilllist.add(skill); person.add(skill); person.getskills(); //all skills have id attribute null repository.save(person); person.getskills(); //all skills have id not null, after saving

but when iterate on myskilllist, none of skills have ids (an attribute named id still null).

i'm trying understand going wrong, why list of objects not getting updated after saving, when original person objects' list of skills gets updated.

i'm using spring-data, if makes difference.

update

so seems behavior get, expected according docs. requirement ids of skills stored in myskilllist, not nowadays in person object.

i can of course, skills person object before , after saving, figure skills new, newly created skills loose order in saved in myskilllist want. in other simple words, need skills new in same order i've inserted them in person's object. help appreciated.

thanks

from the javadoc sdc save:

saves given entity. utilize returned instance farther operations save operation might have changed entity instance completely.

spring info works on ordinary pojos, , contracts might not same instance back, depending on persistence setup. you'll need reload skill objects repository after saving.

if want skill objects shared between various in-memory info structures, need save each skill build before add together list and/or person.

java spring java-ee spring-data spring-data-jpa

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -