2014-06-18 2 views
0

테이블 Usuario_tbl 및 RolUsuario_tbl있다. 나는 모든 UsuarioTbl 속성하지만 난을 필요로 그 날 이야기 한 RolUsuarioTbl는 getHibernateTemplate().save(rolUsuarioTbl) 최대 절전 모드를 사용하여 저장하려고하면 나는 최대 절전 모드 리버스 엔지니어링이 .hbm.xml에게최대 절전 many-to-one

<hibernate-mapping> 
    <class name="co.ejemplo.modelo.UsuarioTbl" table="usuario_tbl" catalog="structse_db"> 
     <id name="idUsuario" type="java.lang.Integer"> 
      <column name="id_usuario" /> 
      <generator class="identity" /> 
     </id> 
     <property name="login" type="string"> 
      <column name="login" length="50" not-null="true" unique="true" /> 
     </property> 
     <property name="clave" type="string"> 
      <column name="clave" not-null="true" /> 
     </property> 
     <property name="habilitado" type="byte"> 
      <column name="habilitado" not-null="true" /> 
     </property> 
     <property name="fechaAlta" type="timestamp"> 
      <column name="fecha_alta" length="19" /> 
     </property> 
     <property name="fechaBaja" type="timestamp"> 
      <column name="fecha_baja" length="19" /> 
     </property> 
     <set name="rolUsuarioTbls" table="rol_usuario_tbl" inverse="true" lazy="true" fetch="select"> 
      <key> 
       <column name="login" not-null="true" /> 
      </key> 
      <one-to-many class="co.ejemplo.modelo.RolUsuarioTbl" /> 
     </set> 
    </class> 
</hibernate-mapping> 

<hibernate-mapping> 
    <class name="co.ejemplo.modelo.RolUsuarioTbl" table="rol_usuario_tbl" catalog="structse_db"> 
     <id name="idUsuarioRol" type="java.lang.Integer"> 
      <column name="id_usuario_rol" /> 
      <generator class="identity" /> 
     </id> 
     <many-to-one name="usuarioTbl" class="co.ejemplo.modelo.UsuarioTbl" fetch="select"> 
      <column name="login" not-null="true" /> 
     </many-to-one> 
     <property name="rol" type="string"> 
      <column name="rol" length="50" not-null="true" /> 
     </property> 
    </class> 
</hibernate-mapping> 

을 갖는 자바 모델을 생성 만 UsuarioTbl에 로그인을 설정하고 있습니다.

UsuarioTbl의 로그인 속성 만 가지고 RolUsuarioTbl을 어떻게 저장할 수 있습니까?

답변

0

many to one 관계는 두 테이블의 코드로 이루어져야하며, 그렇지 않으면 hibernate는 부모 테이블의 자식을 인식하지 못합니다.

관련 문제