-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: update a component (address) within its entity (person)
PostPosted: Mon Feb 02, 2015 3:19 pm 
Newbie

Joined: Mon Feb 02, 2015 2:34 pm
Posts: 1
Hi everyone,

Foremost my setup:
- I have 2 Classes - Person(entity) and Address(component), in which a Person object can have 1 or more Address objects
- Person-to-Address association within Person class
@ElementCollection(fetch = FetchType.EAGER)
@JoinTable(name = "T_Address", joinColumns = @JoinColumn(name = "ORDER_ID"))
public List<Address> getAddresses() {
return addresses;
}
- Address-to-Person association within Address class not needed since I do not need any address-to-person reference

My current Situation:
Whenever I modify an address field or add/delete an address object within the address List in a person object, Hibernate seems to first delete all address objects associated with this person, and afterwards it has them inserted again.

In the Code below I only modified the street of an address object; Hibernate deleted all Adress objects and subsequently inserted all 3 Address objects into Address table again:

Hibernate: delete from T_ADDRESS where PERSON_ID=?
Hibernate: insert into T_ADDRESS (PERSON_ID, CREATED, STREET, ZIP, COUNTRY) values (?, ?, ?, ?, ?)
Hibernate: insert into T_ADDRESS (PERSON_ID, CREATED, STREET, ZIP, COUNTRY) values (?, ?, ?, ?, ?)
Hibernate: insert into T_ADDRESS (PERSON_ID, CREATED, STREET, ZIP, COUNTRY) values (?, ?, ?, ?, ?)



My Question:
Is there any possibility to make Hibernate only delete/modify/add the affected address objectwithin the address list of the person object? For I hope the solution will improve the performance of my written program tremendously.

Thank you for your time and help. I really appreciate it!
Charlie


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.