Hi,
I'm fairly comfortable using Hibernate outside of Spring with Annotations. I personally prefer using annotations to map my POJOs (@Entity, @Id, etc.), but I just can't seem to figure out how to configure Hibernate/JPA.
How do I have the Spring container recognize that I'm using JPA annotations to map my POJOs? The following is my data source and session factory bean in application.xml:
Finally, am I correct to assume that my DAO bean will be injected with the same Hibernate Session Factory object?Code:<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost/_reviews" /> <property name="username" value="xxxx" /> <property name="password" value="xxxx" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="mappingResources"> <!-- No hbm.xml files. Just annotations. How do I configure it here? --> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop> <prop key="current_session_context_class">thread</prop> </props> </property> </bean> <bean id="bookServiceDAO" class="com.springbookstore.data.BookServiceDAOImplementation"> <property name="sessionFactory" ref="sessionFactory" /> </bean>
I started programming about six months ago, so I'm still a little shaky on using documentations to solve all of my problems. As such, if you could point to a place where I could have found a solution to this particular problem, I would greatly appreciate it.
Thank you so much for your help.


Reply With Quote
