Hi guys,
I have and app with Spring, JBoss AS7 and Hibernate 4. For some reson, everything seem to work fine. I can even query the database. But, when I call persist on my entityManager, nothing happens. It looks like it is not commiting transactions on the database. I've already played around with the @Transactional annotation initially put only on the top of my Service class.
Please, guys. Any help or suggestion is more then welcome!
Here go my config files for persistance:
persistance.xml:
Code:<persistence version="2.0" 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_2_0.xsd"> <persistence-unit name="ekobinPersistenceUnit"> <!-- If you are running in a production environment, add a managed data source, this example data source is just for development and testing! --> <!-- The datasource is deployed as WEB-INF/spring-quickstart-ds.xml, you can find it in the source at src/main/webapp/WEB-INF/spring-quickstart-ds.xml --> <jta-data-source>java:jboss/datasources/MysqlDS</jta-data-source> <properties> <property name="jboss.entity.manager.factory.jndi.name" value="java:jboss/ekobin/persistence" /> <!-- Properties for Hibernate --> <property name="hibernate.hbm2ddl.auto" value="create-drop" /> <property name="hibernate.show_sql" value="true" /> </properties> </persistence-unit> </persistence>
infrastructure.xml
applicationContext.xmlCode:<?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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd"> <!-- JDNI name for EntityManagerFactory is defined in src/main/resources/META-INF/persistence.xml --> <jee:jndi-lookup jndi-name="java:jboss/ekobin/persistence" id="entityManagerFactory" expected-type="javax.persistence.EntityManagerFactory" /> <!-- <jee:jndi-lookup jndi-name="java:jboss/datasources/MysqlDS" id="dataSource" expected-type="javax.sql.DataSource" /> --> <bean id="entityManager" class="org.springframework.orm.jpa.support.SharedEntityManagerBean"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> <tx:jta-transaction-manager /> <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <property name="basenames"> <list> <value>classpath:messages/pageText</value> <value>classpath:messages/general</value> </list> </property> <property name="defaultEncoding" value="UTF-8"></property> <property name="fallbackToSystemLocale" value="false" /> <property name="cacheSeconds" value="3" /> <property name="fileEncodings" value="UTF-8" /> </bean> <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver"> <property name="defaultLocale" value="pt_BR"></property> </bean> </beans>
Code:<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:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:p="http://www.springframework.org/schema/p" xmlns:security="http://www.springframework.org/schema/security" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.3.xsd"> <context:component-scan base-package="br.com.ekoimpacto.ekobin.user" /> <context:component-scan base-package="br.com.ekoimpacto.ekobin.device" /> <context:component-scan base-package="br.com.ekoimpacto.ekobin.material" /> <context:component-scan base-package="br.com.ekoimpacto.ekobin.general" /> <tx:annotation-driven /> </beans>


Reply With Quote
