Hi,
I'm trying to setup my generic JPA DAO which seems to be working fine it does get primary key value and throws no exception. However, in the log I don't find any SQL INSERT statement and also the record is not being inserted.
persist method from generic dao:
Code:
@Transactional(propagation = Propagation.REQUIRED)
public void persist(T entity) {
entityManager.persist(entity);
}
Here is how entity manager is configured in spring.
Code:
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="ORACLE" />
<property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="generateDdl" value="true" />
<property name="showSql" value="true" />
</bean>
</property>
<property name="persistenceUnitName" value="travelRequestPersistenUnit"/>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"/>
</property>
</bean>
See log below:
Code:
DEBUG com.spring.hibernate.jpa.CustomerFileService - Befor persisting file it has - Customer [Id=null, fileName=Test Application File, contentType=text/html, file=null]
DEBUG com.spring.hibernate.jpa.CustomerFileService - File service is calling file dao....
DEBUG org.hibernate.impl.SessionImpl - opened session at timestamp: 5345098932588544
DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
DEBUG org.hibernate.SQL - select hibernate_sequence.nextval from dual
DEBUG org.hibernate.id.SequenceGenerator - Sequence identifier generated: 3
DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connection
DEBUG org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
DEBUG org.hibernate.event.def.AbstractSaveEventListener - generated identifier: 3, using strategy: org.hibernate.id.SequenceGenerator
DEBUG com.spring.hibernate.jpa.CustomerFileService - DAO call to persists completed....
DEBUG com.spring.hibernate.jpa.CustomerFileService - After persisting file it has - Customer [Id=3, fileName=Test Application File, contentType=text/html, file=null]
Any help or pointers are much appreciated???