TemplateHibernateを使用して継承したオブジェクトを保存しようとすると問題が発生します。 次のように2つのクラスがあります。 < --------- EntrepriseContact と、ここではcontact.hbm.xmlSpringでTemplateHibernateを使用して継承クラスを保存する方法
<joined-subclass name="Entreprise" table="Entreprise">
<key column="ID_ENTREPRISE" />
<property name="numSiret">
<column name="NUM_SIRET" />
</property>
</joined-subclass>
私はENTREPRISEオブジェクトを作成し、休止状態を使用して、それを保存すると、それは
try
{
SessionFactory sessionFactory =
new Configuration().configure().buildSessionFactory();
session = sessionFactory.openSession();
org.hibernate.Transaction tx = session.beginTransaction();
........................................
session.saveOrUpdate(entreprise);
tx.commit();
}catch(Exception e){
System.out.println(e.getMessage());
}
しかし、私はHibernを使用しようとしたの作品ですateTemplate、次のエラーが発生しました:
org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: domain.Contact; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: domain.Contact
この問題を解決するにはどうすればよいですか?私は連絡先をしようとしたとき、私は両方の状況で働いていたが、ENTREPRISEと、それが機能しなかったことを
注:(
あなたはしませんでしたここでhibernateTemplateコードを提供してください。投稿してください –