| 
					
						 Hibernate version: 3.1.2
 
 I have a simple scenario which is giving me problems.
 
 I have two mappings.  A Company and a CompanyLogo.  Right now, a company can only have one logo (this might change in the future), so here is my mappings:
 
 <class name="Company" table="company">
         <id name="companyId"
             type="java.lang.Long"
             column="company_id"
             unsaved-value="0">
            <generator class="native"/>
        </id>
    
       .... properties here ...
        
         <one-to-one name="companyLogo"
             class="CompanyLogo"
             cascade="all"
             constrained="true"
             lazy="proxy"
             property-ref="company">
         </one-to-one>
 </class>
 
 <class name="CompanyLogo" table="company_logo" lazy="true">
         <id name="companyLogoId"
             type="java.lang.Long"
             column="company_logo_id"
             unsaved-value="0">
            <generator class="native"/>
         </id>
 
         <many-to-one name="company"
             class="Company"
             column="company_id"
             cascade="none"
             not-null="true"
             unique="true"
             fetch="select"
             index="idx_company_logo_company">
         </many-to-one>
 </class>       
 
 As you can see the CompanyLogo has it's own native primary key and has a many to one relationship with Company.
 
 I tried the following code:
 
 Company c = new Company();
 
 ... set properties ...
 
 CompanyLogo l = new CompanyLogo();
 l.setCompany(c);
 c.setCompanyLogo(l);
 
 ... get session ...
 
 ses.save(c);
 
 This throws a null or transient exception on CompanyLogo.company...
 
 If i change the company mapping from constrained="true" to constrained="false" it will work, but I want to keep it so that i have lazy support.  In addition, a logo always exists for a company (just not always full of data).
 
 Any have any ideas how I can get this working?
 
 Thanks. 
					
  
						
					 |