हाइबरनेट जावाडोक बताता है कि Session.update(Object o)
अपवाद उठाएगा यदि पहले से ही o
का लगातार उदाहरण है, है ना?हाइबरनेट * अप * फेंकना नहीं है (मुझे लगता है कि यह चाहिए)
If there is a persistent instance with the same identifier, an exception is thrown.
हालांकि, जब मैं इसे चलाता हूं तो निम्न कोड कुछ भी नहीं फेंकता है। और मुझे लगता है कि यह चाहिए!
Email email = new Email("andre", "girafa", "hi");
Session session = factory.openSession();
Transaction tx = session.beginTransaction();
session.save(email);
session.update(email);
session.update(email);
tx.commit();
// didn't throw... Let's try again
tx = session.beginTransaction();
session.update(email);
session.update(email);
tx.commit();
session.close();
// still nothing! :(
आप कह सकते हैं के रूप में, दो बार मैं कई update()
रों करने की कोशिश, लेकिन अभी भी हाइबरनेट का मुझ पर आसान लेने।
किसी के पास एक झटका है क्यों?
संपादित करें: ऐसा लगता है कि यह केवल यदि एक और बराबर वस्तु,, email2
email
के रूप में एक ही आईडी से फेंक उदाहरण के लिए। मुझे लगता है कि प्रलेखन थोड़े मैला था।
हां! दस्तावेज़ कभी इसे स्पष्ट नहीं लिखना चाहते हैं और यह मुझे इस सवाल पर ले जाता है! – GMsoF