This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

AnnouncementAnnouncement Module

Collapse

No announcement yet.

Defining getting an object from bean in spring-context.xmlPage Title Module

Defining getting an object from bean in spring-context.xml

Oct 13th, 2007, 10:13 AM

Hi folk,

the headline might sound a little bit odd, but here is my explaination. I like to use a part of JPA. The JPA- Implementation is provided by Hibernate. I want to use the Hibernate API in my DAO via HibernateDaoSupport, but want to define my domainobject with JPA.

What I did was configuring a entityManagerFactory. This one I set into my DAO which extracts the SessionFactory for Hibernate an set it into the method of HiberateDaoSupport. Now I am able to use the HibernateTemplate instead of the JPATemplate. Because I like the much more powerful API of Hibernate than the one of JPA.

Now I am stucked. I like to use the OpenSessionInViewInterceptor, what wants the SessionFactory be set in the spring-context.

Comment

thanks for your reply. I like to use JPA Annotation for my domainclasses, to provide a tool independent model. Also I like to use Hibernate for my current DAOs. In the future it could be another vendor. For this case I like to keep my domainmodel clean of tool specific code.

Prove me when I am wrong, but if I use JPA Annotations I cannot use a SessionFactory from startup. I have to take the detour through an EntityMangerFactory. That leads to my problem.