-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: <parent> of <composite-element> can't find field
PostPosted: Fri Oct 28, 2005 2:56 pm 
Beginner
Beginner

Joined: Thu May 26, 2005 1:00 pm
Posts: 29
I have the following:
Code:
public class Product {
  int productId;
  //... other stuff
}
public class ProductFan : Product {
  IList products; //list of ProductMap elements
  //... other stuff
}
public class ProductMap {
  Product parentProduct;
  Product childProduct
  //... other stuff
}

These are mapped as follows:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-access="field">
  <class name="SpringAir.Objects.Product, SpringAir.Objects" table="Product">
    <id name="productId" type="Int32" column="ProductId" unsaved-value="-1">
       <generator class="hilo">
         <param name="table">IdGenerator</param>
         <param name="column">NextProductId</param>
         <param name="max_lo">0</param>
      </generator>
    </id>
  </class>
  <joined-subclass name="SpringAir.Objects.ProductFan, SpringAir.Objects" table="ProductFan" extends="SpringAir.Objects.Product, SpringAir.Objects">
   <key column="ProductId" />
    <bag name="products" table="ProductMap" cascade="all" lazy="true">
      <key column="ProductId" />
      <composite-element class="SpringAir.Objects.ProductMap, SpringAir.Objects">
         <parent name="parentProduct" />       <!--THIS CAUSES AN ERROR!!-->
         <property name="sequenceNumber" column="SequenceNumber" />
         <many-to-one name="childProduct" column="ChildProductId" not-null="true" />
      </composite-element>
    </bag>
  </joined-subclass>
</hibernate-mapping>

I originally had ProductMap as its own entity, but really it's lifecycle is tied to the parentProduct, so it's now a component. Unfortunately, the parent definition under the composite-element triggers the following exception when building the session factory:
Code:
[PropertyNotFoundException: Could not find a setter for property 'parentProduct' in class 'SpringAir.Objects.ProductMap']
   NHibernate.Property.BasicPropertyAccessor.GetSetter(Type type, String propertyName)
   NHibernate.Type.ComponentType..ctor(Type componentClass, String[] propertyNames, IGetter[] propertyGetters, ISetter[] propertySetters, Boolean foundCustomAcessor, IType[] propertyTypes, OuterJoinFetchStrategy[] joinedFetch, CascadeStyle[] cascade, String parentProperty) +313
   NHibernate.Cfg.Binder.BindComponent(XmlNode node, Component model, Type reflectedClass, String className, String path, Boolean isNullable, Mappings mappings) +3299
   NHibernate.Cfg.Binder.BindCollectionSecondPass(XmlNode node, Collection model, IDictionary persistentClasses, Mappings mappings) +1351
   NHibernate.Cfg.CollectionSecondPass.SecondPass(IDictionary persistentClasses) +21
   NHibernate.Cfg.AbstractSecondPass.DoSecondPass(IDictionary persistentClasses) +100
   NHibernate.Cfg.Configuration.SecondPassCompile() +124
   NHibernate.Cfg.Configuration.BuildSessionFactory() +12

The session factor loads fine without the parent definition, but there is some code that uses parentProduct, so I'd like to get it working. It seems it can't find the setter. Is it looking for a propery rather than a field? I have specified field-level access, so I'm not sure what the problem might be. Any thoughts?


Top
 Profile  
 
 Post subject: Any ideas?
PostPosted: Wed Nov 02, 2005 1:46 pm 
Beginner
Beginner

Joined: Thu May 26, 2005 1:00 pm
Posts: 29
Anyone have any ideas? Anything?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.