Hibernate siwtch to JPA 报错

org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: com.linkin.crm.customer.model.Customer; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.linkin.crm.customer.model.Customer
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:634)
at org.springframework.orm.hibernate3.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:690)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:566)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:662)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:632)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:319)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy43.createCustomerLeadsContactRecord(Unknown Source)
at com.linkin.crm.web.action.CustomerAction.createLeads3(CustomerAction.java:1044)
at com.linkin.crm.web.action.CustomerAction$$FastClassByCGLIB$$90cffca0.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:624)
at com.linkin.crm.web.action.CustomerAction$$EnhancerByCGLIB$$2643cca.createLeads3(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Customer 类的JPA

@Entity
@Table(name = "t_customer")
@SuppressWarnings(value = "serial")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "c_cust_type", discriminatorType = DiscriminatorType.STRING)
public class Customer implements Serializable {

@Id
@Column(name = "c_id")
@GeneratedValue(generator = "hibseq")
@GenericGenerator(name = "hibseq", strategy = "hilo", parameters = {
@Parameter(name = "table", value = "t_c1_hi_value"),
@Parameter(name = "column", value = "c_cust_next_value"),
@Parameter(name = "max_lo", value = "10") })
private long id;

Hibernate配置文件
<class name="Customer" table="t_customer" dynamic-update="true">
<id name="id" type="long" column="c_id" unsaved-value="0">
<generator class="hilo">
<param name="table">t_c1_hi_value</param>
<param name="column">c_cust_next_value</param>
<param name="max_lo">10</param>
</generator>
</id>
<discriminator column="c_cust_type" type="string" />
<!--客户名称-->
<property name="name" type="string">
<column name="c_name" length="100" />
</property>
......
</class>
求解。

你可能感兴趣的:(java,AOP,Hibernate,orm,jpa)