当前位置:首页 > 技术问答集
firefox

求救关于hibernate中1对1关联的问题!

 所属目录:Java   |   类型:技术问答   |   时间:2007-05-21
 问题:

family.htm.xml  
   
  <?xml   version="1.0"?>  
  <!doctype   hibernate-mapping   public  
                  "-//hibernate/hibernate   mapping   dtd   3.0//en"  
                  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">  
  <hibernate-mapping   package="foreignkey">  
  <class   name="familypo"   table="t_family">  
  <id   name="id"   column="id"   type="string">  
  <generator   class="org.hibernate.id.foreigngenerator">  
  <param   name="property">user</param>  
  </generator>  
   
  </id>  
  <property   name="home"   column="home"   type="string"/>  
  <one-to-one   name="user"   class="userpo"   constrained="true"/>  
  </class>  
  </hibernate-mapping>  
   
  users.htm.xml  
  <?xml   version="1.0"?>  
  <!doctype   hibernate-mapping   public   "-//hibernate/hibernate   mapping   dtd   3.0//en"    
  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">  
  <hibernate-mapping   package="foreignkey">  
  <class   name="userpo"   table="t_users">  
  <id   name="id"   column="id"   type="string">  
  <generator   class="org.hibernate.id.uuidhexgenerator"/>  
  </id>  
  <property   name="name"   column="name"   type="string"/>  
  <one-to-one   name="family"   class="familypo"   cascade="all"/>  
  </class>  
  </hibernate-mapping>  
   
  我有两张表   user和family,他们共享主键。可是插入的时候会报   [microsoft][sqlserver   2000   driver   for   jdbc][sqlserver]insert   语句与   column   foreign   key   约束   fk_t_users_t_family   冲突。该冲突发生于数据库   quickstart,表   t_family,   column   id这个异常  
  怎么回事啊    
  我实在看不出有什么不对的地方,各位大虾帮我看看   ,小弟谢过了  
 

.

· 网友精彩回答:

© 2006-2008 All Rights Reserved