Hi, I'm new to Hibernate. I have 2 classes which are connected by many-to-one relation and I set lazy loading = true. For example: public class Domain{ private Long domainId; private String name; private Date dateCreated; private User userCreated;
// getter/setter }
public class User { private Long userId; private String userName; private String password;
// getter/setter }
I want to write the Domain object to file with the reference. So I use initialize: Domain domain = getObject(Domain.class, id); Hibernate.initialize(domain); Hibernate.initialize(domain.getUserCreated()); writeToFile(domain);
Then I read object from file: Object obj = readFromFile();
I want to have the obj like that: obj.getUserCreated.getClass().getName() is User, not the proxy for User (User$$enhancerByCGILib$$) but somtimes it works, sometimes it doesn't. Could anyone show me how to get the reference? Thank you.
|