2012-02-16 2 views
0

나는 다음 코드를Hibernate는 호출 순서 생성기를 어떻게 호출합니까?

getEntityManager().persist(country.getCity().getClinic().getPatient()); 

을 가지고 발생하지 않는 '국가'에 대한 로그

Hibernate: 
select 
    next value for patient_seq 
from 
    dual_patient_seq 
Hibernate: 
    select 
     next value for clinic_seq 
    from 
     dual_lclinic_seq 
Hibernate: 
    select 
     next value for city_seq 
    from 
     dual_city_seq 

그러나 sequance에서 다음 SQL을 참조하십시오. 모든 XML은 괜찮습니다. Whan이 문제 야? 감사합니다. .

+1

엔티티 및 특히 관계에 대한 더 자세한 정보가 필요합니까? 캐스케이드 등이 정의되어 있습니까? '국가'는 이미 지속될 것인가? – Thomas

+0

시퀀스는 일반적으로 엔티티 클래스/hbm xml에 정의되어 있습니다. 시퀀스 생성기가 국가에 정의되어 있는지 확인하십시오. – Rocky

답변

0

Thx, Thomas! 문제는 '캐스케이드'에있었습니다. 나는

<set name="countrysPersistent" lazy="true" inverse="true" cascade="all"> 
    <key column="country" /> 
     <one-to-many class="Country" /> 
     </set> 

<set name="countrysPersistent" lazy="true" inverse="true" > 
    <key column="country" /> 
     <one-to-many class="Country" /> 
     </set> 

에서 City.hbm.xml을 변경하고는 도움이되었다!

관련 문제