Hibernate 4.1 x Spring 3.1.1 - [RESOLVIDO]

Pessoal no meu applicationContext.xml antes eu usava esta anotacao “org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean” agora com Spring 3.1.1 nao existe mais o que usar dei uma olhada no javadoc e existe “org.springframework.orm.hibernate4” ?

Exemplo:

		<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
			<property name="hibernateProperties">
			</property>
		</bean>

Obrigado !!!

Segundo a documentação ainda existe o pacote do hibernate3 e foi incluído o pacote do hibernate4: http://static.springsource.org/spring/docs/3.1.1.RELEASE/spring-framework-reference/html/
E a documentação do pacote hibernate4 fala sobre a sua dúvida: http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework/orm/hibernate4/package-summary.html

[quote=romarcio]Segundo a documentação ainda existe o pacote do hibernate3 e foi incluído o pacote do hibernate4: http://static.springsource.org/spring/docs/3.1.1.RELEASE/spring-framework-reference/html/
E a documentação do pacote hibernate4 fala sobre a sua dúvida: http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework/orm/hibernate4/package-summary.html
[/quote]

So uma duvida eu usei a seguinte classse LocalSessionFactoryBean esta certo outro detalhe agora sou obrigado a usar DataSource para usar Spring 3.1.1 e o Hibernate 4.1.1 ?

&lt;bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;

Fiz da seguinte form e resolveu.

  1. Solucao.
    applicationContext.xml
		<!-- ############# H I B E R N A T E ############# -->	
			
		<!-- Configurando o Transaction -->
		<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
			<property name="sessionFactory" ref="sessionFactory"/>
		</bean>
		
		<!-- Configurando JDBC com Hibernate -->
		<bean id="firebirdDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
			<property name="driverClassName" value="org.firebirdsql.jdbc.FBDriver"/>
			<property name="url" value="jdbc:firebirdsql:localhost/3050:/dba/JVDS.FDB"/>
			<property name="username" value="SYSDBA"/>
			<property name="password" value="masterkey"/>
		</bean>
  		
	
		<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">			
			<property name="dataSource" ref="firebirdDataSource"/>
			<property name="hibernateProperties">
				<props>
					<prop key="hibernate.dialect">org.hibernate.dialect.FirebirdDialect</prop>
					<prop key="hibernate.show_sql">true</prop>					
					<prop key="hibernate.format_sql">true</prop>
					<prop key="hibernate.connection.autocommit">false</prop>
				</props>
			</property>
			<property name="annotatedClasses">
				<list>	
					<value>br.com.jvds.modelo.CadUf</value>
				</list>
			</property>  			
		</bean>		

Logo estarei postando a segunda solucao com JPA estou terminando o exemplo.

Obrigado !!!
JVDS

Estou postando a segunda solucao


		<!-- ############# J P A ############# -->
		
		<!-- Configurando Transaction JPA -->
		<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    		<property name="entityManagerFactory" ref="entityManagerFactory"/>
  		</bean>

		<!-- Configurando JDBC JPA -->
		<bean id="firebirdDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		    <property name="driverClassName" value="org.firebirdsql.jdbc.FBDriver"/>
		    <property name="url" value="jdbc:firebirdsql:localhost/3050:/dba/JVDS.FDB"/>
		    <property name="username" value="SYSDBA"/>
		    <property name="password" value="masterkey"/>
 		</bean>

		<!-- Configurando DAO Session -->
		<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
			<property name="dataSource" ref="firebirdDataSource"/>
			<property name="jpaVendorAdapter">  
		        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> 
        			<!-- 		        	 
		            <property name="showSql" value="true" />  
		            <property name="databasePlatform" value="org.hibernate.dialect.FirebirdDialect" />
		             -->  
		        </bean>  
		    </property>			
		    <!-- Properties Hibernate -->
  			<property name="jpaProperties">
		       	<props>
					<prop key="hibernate.dialect">org.hibernate.dialect.FirebirdDialect</prop>
					<prop key="hibernate.show_sql">true</prop>					
					<prop key="hibernate.format_sql">true</prop>
					<prop key="hibernate.connection.autocommit">false</prop>
		        </props>
		    </property>
			<!-- SCAN @Entity -->
			<property name="packagesToScan">				
		        <list>		        	
					<value>br.com.jvds.modelo</value>
		        </list>
		    </property>  	
		</bean>		

DAO

@Component
@Repository("daoHibernateEntityManagerFactorySpring")
public class DaoHibernateEntityManagerFactorySpring<T> implements Dao<T> {	
	private EntityManagerFactory entityManagerFactory;
	
	@PersistenceUnit
	//@PersistenceContext
	public void setEntityManagerFactory(
			EntityManagerFactory entityManagerFactory) {
		this.entityManagerFactory = entityManagerFactory;
	}
}