Hi. I'm new to Hibernate group. When I want to save my persistent domain object,I take an exception as :
HibernateException("unmapped property: " + propertyName);
My codes are shown below:
Session Bean method
public void createKesinOSSOgrenciKayit(AbstractOgrenciDTO ogrDTO, OgrenciNufusDTO ogrNufusDTO, OgrenciAskerlikDTO ogrAskerlikDTO,
OgrenciAdresDTO ogrAdresDTO, OgrenciHarcDTO ogrHarcDTO, OgrenciOSSDTO ogrOSSDTO) throws KesinKayitControllerAppException, KesinKayitControllerSysException, java.rmi.RemoteException{
try {
getOgrenciDAO();
getOgrenciNufusDAO();
AbstractOgrenciDO asilOgrenci = new AbstractOgrenciDO(ogrDTO);
ogrenciDAO.saveOgrenci(asilOgrenci);
//ogrenciDAO.refresh(asilOgrenci);
OgrenciNufusDO ogrenciNufus = new OgrenciNufusDO(ogrNufusDTO);
// EXCEPTION IS TAKEN BELOW
ogrenciNufusDAO.saveOgrenciNufus(ogrenciNufus);
} catch (DAOSysException dse) {
getSessionContext().setRollbackOnly();
throw new KesinKayitControllerSysException(dse.getMessage());
} catch (DAOAppException dae) {
getSessionContext().setRollbackOnly();
throw new KesinKayitControllerAppException(dae.getMessage());
}
}
}
DAOImpl save method
public void saveOgrenciNufus(OgrenciNufusDO ogrenciNufus)
throws DAOSysException, DAOAppException {
Session session = getSession();
try {
session.save(ogrenciNufus);
session.flush();
} catch (HibernateException he) {
throw new DAOAppException(
he.getMessage());
} finally {
closeSession();
}
}
Domain Object
public class OgrenciNufusDO{
private Long id;
private String anaAdi;
private String babaAdi;
private String medeniHali;
private String dogumYeri;
private String tcKimlikNo;
private String kutukIl;
private String kutukIlce;
private String kutukMahalleKoy;
private String ciltNo;
private String siraNo;
private String aileSiraNo;
//setters and getters
}
Mapping files
<class name="iyte.oi.components.ogrenciler.ogrenci.model.AbstractOgrenciDO" discriminator-value="AbstractOgrenci"
table="OGRENCILER">
<id column="ID" name="id" type="long">
<generator class="identity"></generator>
</id>
<discriminator column="TIP" type="string" not-null="true"/>
<property name="ogrenciNo" column="OGRENCI_NO" not-null="true" type="string"/>
<property name="ad" column="AD" not-null="true" type="string"/>
<property name="soyad" column="SOYAD" not-null="true" type="string"/>
<property name="dogumTarihi" column="DOGUM_TARIHI" not-null="true" type="java.sql.Date"/>
<property name="cinsiyet" column="CINSIYET" not-null="true" type="string"/>
<property name="uyruk" column="UYRUK" not-null="true" type="string"/>
<property name="email" column="EMAIL" not-null="true" type="string"/>
<property name="kayitTarihi" column="KAYIT_TARIHI" not-null="false" type="java.sql.Date"/>
<property name="egitimDerecesi" column="EGITIM_DERECESI" not-null="true" type="string"/>
</class>
<class name="iyte.oi.components.ogrenciler.ozluk.model.OgrenciNufusDO" table="OGRENCI_NUFUS">
<id column="ID" type="long" name="id">
<generator class="foreign"><param name="property"></param></generator>
</id>
<property name="anaAdi" type="string" column="ANA_ADI"/>
<property name="babaAdi" type="string" column="BABA_ADI"/>
<property name="medeniHali" type="string" column="MEDENI_HALI"/>
<property name="dogumYeri" type="string" column="DOGUM_YERI"/>
<property name="tcKimlikNo" type="string" column="TC_KIMLIK_NO"/>
<property name="kutukIl" type="string" column="KUTUK_IL"/>
<property name="kutukIlce" type="string" column="KUTUK_ILCE"/>
<property name="kutukMahalleKoy" type="string" column="KUTUK_MAHALLE"/>
<property name="ciltNo" type="string" column="CILT_NO"/>
<property name="siraNo" type="string" column="SIRA_NO"/>
<property name="aileSiraNo" type="string" column="AILE_SIRA_NO"/>
</class>
I think this problem is from the foreign key of id for OgrenciNufus. But I'm not sure and I couldn't solve the problem. Thanks for your interest.
|