Hi,
I would like to implement something like a PDO pattern in conjunction with Spring. All domain objects are implemented according to their interface. Each domain object implementation also has an autowired DAO implementation to be able to directly persist the object. (e.g. foo.persist()). This works pretty well, Spring also inserts the proper DAO implementation.
To create those beans I implemented a BeanFactory which just creates the Beans with the aid of Spring. Nevertheless Spring creates Dynamic Proxies and that's where the problem begins. Once I have a many-to-one relationship and, I get two different Dynamic Proxy objects. When persisting, Hibernate tells me:
"could not get a field value by reflection getter".
The interface of the two objects is defined as follows:
public interface Client {
public Long getId();
public void setId(Long id);
}
The interface of the user is defined as follows:
public interface User {
public Long getId();
public Client getClient();
public void setClient(Client client);
public void setId(Long id);
}
The implementation of the User is made according to the JPA, I've used the tag targetEntity to link to the right Implementation of the Client object. Nevertheless persisting doesn't work when inserting a Client object which has been created through Spring. Hope one from your side can help regarding this issue.
Regards
Matthias