Reputation: 319
my problem is this. ill try to make it simple. I am using spring data jpa +spring boot (hibernate config) with mysql.
I have a class (entity) like this.
public class A {
@EmbeddedId
Aid id;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "a")
@OrderBy("order ASC")
@MapKey(name = "b.bid")
Map<String, B> b;
//id class
@Embeddable
public static class Aid implements Serializable {
private String agent;
private String id;
}
//some other fields/methods
}
here other class
public class B {
private Integer x;
private String code;
@Transient
private String value;
//B embedable id class goes here
}
Note you can assume all missing annotations / method / id are there and this is perfectly working code. I did not added those here to avoid being complicate the question.
this is my question.
when I fetch this A object from database I adding it to map [storageMap] and during the program from A object which is in storageMap read and its B objects value field (B object in Map of A object) get update.
but my problem is when i fetch again A from database it give me previously fetched and dirty (modified) object. but I need fresh copy from database to reset all modifications. hibernate does not know its dirty because its @Transient ? how I can solve this. ( I know if I deep copy what return from database before adding to my storageMap would solve the problem. any other better way to do?)
Upvotes: 0
Views: 294