java - Converting Between Hibernate Collections and My Own Collections -
i have set hibernate give me set<integer>
convert internally , set<myobjecttype>
(myobjecttype
can represented single integer). say, when hibernate calls void setmyobjecttypecollection(set<integer> theset)
method iterate through elements in theset
, convert them myobjecttype
. when hibernate calls set<myobjecttype> getmyobjecttypecollection()
allocate new hashset , convert myobjecttype
s integer
s.
the problem every time call commit
, hibernate deletes in collection , re-inserts regardless of whether element of collection has changed or collection has changed.
while don't technically consider bug, afraid deleting , inserting many rows cause database perform unnecessarily slowly.
is there way hibernate recognize though have allocated , returned different instance of collection, collection contains items used , there no need delete , reinsert them all?
i think best way achieve goal use usertype. lets handle conversion sql own objects (back , forth).
you can see example on how use here.
Comments
Post a Comment