When needing CriteriaBuilder, it always has to call entityManager.getCriteriaBuilder().
Thus I want to configure the bean in the spring apllicationContext and add the Annotation @Autowired, but my configuration doesn't work.
Code:
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="cn.tata.t2s.ssm.entity" />
<property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
<property name="persistenceUnitName" value="t2sPersistanceUnit" />
<property name="persistenceXmlLocation" value="classpath:persistence.xml" />
<property name="jpaProperties">
<props>
<prop key="hibernate.physical_naming_strategy">cn.tata.t2s.ssm.util.AcmeCorpPhysicalNamingStrategy</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hiberante.format_sql">true</prop>
</props>
</property>
</bean>
<bean id="criteriaBuilder" class="org.hibernate.query.criteria.internal.CriteriaBuilderImpl">
<property name="sessionFactory" ref="entityManagerFactory"/>
</bean>
No qualifying bean of type [org.hibernate.internal.SessionFactoryImpl] found for dependency [org.hibernate.internal.SessionFactoryImpl]: expected at least 1 bean which qualifies as autowire candidate for this dependency.