JPA2: هل يمكننا استخدام العديد من lementCollection في كيان؟

StackOverflow https://stackoverflow.com/questions/9525721

  •  15-11-2019
  •  | 
  •  

سؤال

هنا هو الإصدار المحرز من الرمز الخاص بي: giveacodicetagpre.

هل الكود أعلاه المسموح به؟لدي تكلفة دروستين قابلة للمضمون وتكلفة Itemlocation التي أستخدمها مع elementCollection.

المشكلة: عندما أحاول تشغيل استعلام مسمى giveacodicetagpre.

لدي سلوك غريب.يتم مضاعفة السجلات في عنصر الإرسال الثاني (جدول ItemLccation) (إدراجها في الجدول).

هل كانت مفيدة؟

المحلول

What it comes to JPA 2.0, your code is allowed. It is perfectly legal to have more than one collections that are annotated with ElementCollection. Also, it most likely does not have anything to do with problem you have. By the way, to find out is that really your problem, had you tried your code without costs collection?

In which point exactly duplicates in this collection occur first time? If ItemLocation does not define equals&hashcode, duplicates can easily come as result of adding items by yourself.

Possibly you are facing this problem: Primary keys in CollectionTable and chancing type to list and adding @OrderColumn will help.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top