Tks
my 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:tx="
http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<!-- This is the main configuration file for our JPA work. All the
magic is here. -->
<!-- First we set up a nice little property configurer, so you can
just modify jdbc.properties
to point to a different database. -->
<!-- Now we set up a simple datasource. Use a better one in
production. -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/TEST"/>
<property name="username" value="user"/>
<property name="password" value="password"/>
</bean>
<!-- At last, the entity manager. -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="MySpring"/>
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter">
<property name="showSql" value="true"/>
<property name="generateDdl" value="true"/>
<property name="databasePlatform"
value="oracle.toplink.essentials.platform.database.MySQL4Platform"/>
</bean>
</property>
<property name="loadTimeWeaver">
<bean
class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver"/>
</property>
</bean>
<!-- A simple transaction manager for our (single)
EntityManagerFactory. -->
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="baseTransactionProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager" ref="transactionManager"/>
<property name="transactionAttributes">
<props>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<!-- We want to use Spring's declarative @Transaction management -->
<tx:annotation-driven/>
<!-- This makes Spring perform the magic
@PersistenceContext/_at_PersitenceUnit injection -->
<bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
<bean id="userDAO" parent="baseTransactionProxy">
<property name="target">
<bean class="beyondm.ex.service.jpa.UserDAOImpl">
<property name="entityManagerFactory"
ref="entityManagerFactory"/>
</bean>
</property>
</bean>
<!-- Here's our DAO (which we call "service" - sorry. I wish I had
a better refactoring tool.) -->
<!--<bean id="service" class="beyondm.ex.service.jpa.UserDAOImpl" />-->
</beans>
If I do the coding
public void save() {
em.persist(user);
} This is not persisting
But
public void save() {
EntityManager em =
getJpaTemplate().getEntityManagerFactory().createEntityManager();
em.getTransaction().begin();
em.persist(user);
em.getTransaction().commit();
}
This works
But I want this commit to remove and put it in the application config
HOW????????????????
Sanjeeb Kumar Sahoo wrote:
> Vasanthakumar wrote:
>
>> Hi all
>> I am using Toplink + GlassFish for persistent layer for my project
>>
>>
>> I have a aproblem in persistency. When I persist one object it is not
>> persisted but no exception comes but when
>> do like
>>
>> EntityManager em =
>> getJpaTemplate().getEntityManagerFactory().createEntityManager();
>> em.getTransaction().begin();
>>
>> em.persist(user);
>> em.getTransaction().commit();
>>
>>
>> It works.
>
> Here you said "it works" and earlier you mentioned "the object is not
> persisted". Can you clarify what works and what does not work?
>
>> Please tell me how can I configure rollback = false in the
>> application-config for JpaTransactionManager/
>
> What is application-config? What is JpaTransactionManager?
>
> Sahoo
>
>>
>>
>
>
--
Software Engineer,
BeyondM (Pvt) Ltd.
(a hSenid Company)
Phone: +94-11-2446623/4 (m): +94785387497
Fax: +94-11-2307579
Web: http://www.hSenidMobile.com
Mobilizing your enterprises
Disclaimer: This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to which they are addressed. The content and opinions contained in this email are not necessarily those of hSenid Software International. If you have received this email in error please contact the sender.