Hi I know that and tested before merge will reattach the object back to session preventing lazy initialization exception when object is no longer in session.
a.) So I have a few question.
If i payment --> customer (in a many-to-one unidirectional relationship) and I do
Payment payment = Payment.class.cast(session.merge(oldPayment));
Will customer object also be reattach into session, or do I have to make another merge call for the customer.
b.) What happen if the payment--> customer (many-to-one bidirectional relationship). What would happen than.
c.) How about if i have relationship of more than three hierarchy.
example: hotel --> payment --> customer.
If I do Hotel hotel = Hotel.class.cast(session.merge(unmergeHotel)), will the payment and customer object also be merge into session?
Thanks
It's defined by cascading options of your relationships.
Related exceprt from JPA Specification (I guess native Hibernate's
Session
interface offers the same semantics):See also: