Re:spring jpa hibernate desktop

1 resposta
manoel180

voce conseguiu resolver estou com o mesmo problema

1 Resposta

I

Gente estou tendo um probleminha na configuração. Aí segue meu arquivo de configuração

Persistence.xml

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
	version="1.0">
	<persistence-unit name="hbm/passaporte/punit" transaction-type="RESOURCE_LOCAL">
		   <provider>org.hibernate.ejb.HibernatePersistence </provider>
	       <properties>
	    	<property name="hibernate.hbm2ddl.auto" value="update" />
  			<property name="hibernate.format_sql" value="true" />
  			<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" /> 
  			<property name="hibernate.connection.driver_class" value="org.postgresql.Driver" /> 
  			<property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/tce" /> 
  			<property name="hibernate.connection.username" value="teste" />
  			<property name="hibernate.connection.password" value="teste" /> 
	  </properties>  
	</persistence-unit>
</persistence>

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
    	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
			http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd 
			http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
			
			
    <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
	
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
     
        <property name="persistenceUnitName" value="hbm/passaporte/punit" />
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="database" value="POSTGRESQL" />
                <property name="showSql" value="true" />
            </bean>
        </property>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory" />
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager" />
    
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
       <tx:attributes>
           <tx:method name="salvar*" propagation="REQUIRED" />
       </tx:attributes>
    </tx:advice>
            
    <aop:config>
      <aop:pointcut id="service" expression="execution(* br.gov.am.tce.passaporte.model.service.*.impls.*.*(..))" />
	  <aop:advisor advice-ref="txAdvice" pointcut-ref="service" />       
    </aop:config>        
    
   	<context:annotation-config />
	
	<!-- Carrega os Beans de Servico -->
	<context:component-scan base-package="br.gov.am.tce.passaporte.model.service.impls" />

	<context:component-scan base-package="br.gov.am.tce.passaporte.facade" />
	
	<!-- Carrega os Beans DAO Hibernate -->
	<context:component-scan base-package="br.gov.am.tce.passaporte.model.dao.impls" />
 	    	
</beans>

Consegue carregar as classes e acessas o banco portem quenado vai injetar o EntityManager da erro.

Alguem pode da uma força esta aplicação é desktop.

Criado 7 de junho de 2012
Ultima resposta 6 de out. de 2010
Respostas 1
Participantes 2