Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring/JPA/Hibernate persist entity : Nothing happen
    text
    copied!<p>I'm trying to make an application with Spring 3, JPA 2 and Hibernate 3. I have a problem when y persist an entity : nothing happen ! Data are not inserted in database, and not query is executed. But when i'm using a request like query.getResultList() a select works correctly.</p> <p>So I think my problem is only on a persist/update and on the transaction manager but i'm not really good with spring. Can you help me please ?</p> <p>Here are my configuration files :</p> <blockquote> <h2>My applicationContext.xml</h2> </blockquote> <pre><code> &lt;jee:jndi-lookup id="soireeentreamis_DS" jndi-name="jdbc/soireeentreamis" /&gt; &lt;bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager"&gt; &lt;property name="persistenceXmlLocations"&gt; &lt;list&gt; &lt;value&gt;classpath*:META-INF/persistence.xml&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;property name="defaultDataSource" ref="soireeentreamis_DS" /&gt; &lt;property name="dataSources"&gt; &lt;map&gt; &lt;entry key="soireeentreamisDS" value-ref="soireeentreamis_DS" /&gt; &lt;/map&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt; &lt;property name="persistenceUnitManager" ref="persistenceUnitManager" /&gt; &lt;property name="persistenceUnitName" value="soireeentreamisPU" /&gt; &lt;property name="jpaDialect"&gt; &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" /&gt; &lt;/property&gt; &lt;property name="jpaVendorAdapter"&gt; &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt; &lt;property name="showSql" value="false" /&gt; &lt;/bean&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="soireeentreamisTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt; &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt; &lt;property name="jpaDialect"&gt; &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" /&gt; &lt;/property&gt; &lt;/bean&gt; &lt;tx:annotation-driven transaction-manager="soireeentreamisTransactionManager" /&gt; &lt;context:annotation-config /&gt; &lt;/beans&gt; </code></pre> <blockquote> <h2>My persistence.xml</h2> </blockquote> <pre><code> &lt;persistence-unit name="soireeentreamisPU" transaction-type="RESOURCE_LOCAL"&gt; &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt; &lt;non-jta-data-source&gt;soireeentreamisDS&lt;/non-jta-data-source&gt; &lt;properties&gt; &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /&gt; &lt;property name="hibernate.hbm2ddl.auto" value="create"/&gt; &lt;/properties&gt; &lt;/persistence-unit&gt; </code></pre> <blockquote> <h2>My service</h2> <pre><code>@Service @Transactional("soireeentreamisTransactionManager") public class UserServiceImpl implements UserService ... </code></pre> <h2>My dao</h2> <pre><code>@Repository public class UserDaoImpl extends GenericDaoImpl&lt;User, String&gt; implements UserDao { @PersistenceContext(unitName = "soireeentreamisPU") private EntityManager em; public void persist(final User entity) { em.persist(entity); } } </code></pre> </blockquote> <p>Can somebody help me please?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload