I'm using postgresql 8.2.6 + Spring 2.5.1 + Hibernate 3.3.2 + JPA .
no error and no data saved.
but when I move to mysql (InnoDB) , everything is ok.
and there're so many similar theads here about data not saved problem through JPA.
need someone to help us 
applicationContext.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Application context definition for PetClinic on JPA.
-->
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" 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:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
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/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<context:property-placeholder location="classpath:jdbc-postgresql.properties"/>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="${jdbc.driverClassName}"
p:url="${jdbc.url}"
p:username="${jdbc.username}"
p:password="${jdbc.password}"/>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:dataSource-ref="dataSource">
<property name="persistenceUnitName" value="sfcpu"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:database="${jpa.database}"
p:showSql="${jpa.showSql}"
p:generateDdl="true"/>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
<property name="dataSource" ref="dataSource"/>
</bean>
<context:annotation-config />
<context:component-scan base-package="com.emice.sfc.service" />
<!--
Post-processor to perform exception translation on @Repository classes (from native
exceptions such as JPA PersistenceExceptions to Spring's DataAccessException hierarchy).
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
-->
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="personAction" scope="prototype" class="com.emice.sfc.sample.PersonAction">
</bean>
<bean id="userAction" scope="prototype" class="com.emice.sfc.user.UserAction">
</bean>
</beans>
persistence.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<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="sfcpu">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
</persistence-unit>
</persistence>
jdbc-postgresql.properties:
Code:
hibernate.generate_statistics = true
hibernate.show_sql = true
jpa.showSql = true
jdbc.driverClassName=org.postgresql.Driver
jdbc.url=jdbc:postgresql://localhost/quickstart
jdbc.username=postgres
jdbc.password=123
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
jpa.database = POSTGRESQL
Organization.java
Code:
package com.emice.sfc.model;
import javax.persistence.*;
...
@Entity
@Table(name=Constant.DB_PREFIX+"organizations")
public class Organization implements IDEntity{
@Id
@GeneratedValue
private Integer id;
...
@OneToMany(mappedBy="organization",fetch=FetchType.LAZY)
@OrderBy("id desc")
private List<Person> people;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
... other getter/setter s
}
PersistenceServiceImpl.java
Code:
package com.emice.sfc.service;
@Repository
public class PersistenceServiceImpl implements PersistenceService {
private EntityManager em;
@PersistenceContext
public void setEntityManager(EntityManager em) {
this.em = em;
}
private EntityManager getEntityManager() {
return em;
}
...
@Transactional
public <T extends IDEntity> void save(T obj){
if (obj.getId() == null) {
// new
em.persist(obj);
} else {
// update
em.merge(obj);
}
}
}
PersistenceServiceTest.java
Code:
public class PersistenceServiceTest extends ServiceTestBase{
@Autowired
private PersistenceService ps;
@Test
@Transactional
public void testDeleteEmployeeCascade() {
Organization org = new Organization();
org.setEname("emice2");
ps.save(org);
}
}
I can see insert sql statement in console, and sequence increases too,
but the table is still empty.
why ? where's the problem ?
Thank you !