| 
					
						 Hi,
 Thanks so much for the replies! Here is attached mapping file
 
 
 <?xml version="1.0" encoding="UTF-8"?>
 
 <!DOCTYPE hibernate-mapping PUBLIC
     "-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
     "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
 
 <hibernate-mapping
 >
     <class
         name="com.poeware.ephotoshop.prods.AttributeValueEnumeration"
         table="AttribValueEnums"
         lazy="false"
     >
 
         <id
             name="id"
             column="Id"
             type="long"
             unsaved-value="-1"
         >
             <generator class="native">
               <!--  
                   To add non XDoclet generator parameters, create a file named 
                   hibernate-generator-params-AttributeValueEnumeration.xml 
                   containing the additional parameters and place it in your merge dir. 
               --> 
             </generator>
         </id>
 
         <list
             name="enumElements"
             lazy="false"
             cascade="all"
             fetch="join"
         >
 
             <key
                 column="EnumerationId"
             >
             </key>
 
             <index
                 column="ListNdx"
             />
 
             <one-to-many
                   class="com.poeware.ephotoshop.prods.AttributeValueEnumerationElement"
             />
 
         </list>
 
         <property
             name="attributeTypeId"
             type="int"
             update="true"
             insert="true"
             column="AttributeTypeId"
         />
 
         <!--
             To add non XDoclet property mappings, create a file named
                 hibernate-properties-AttributeValueEnumeration.xml
             containing the additional properties and place it in your merge dir.
         -->
 
     </class>
 
 And the class code:
 /**
  *
  * Class representing the enumeration of the attribute values. This class is referenced 
  * by EnumAttribute, and holds the list of possible AttributeValues, referenced via AttributeValueEnumerationElements. 
  * Because of such a many-to-one relationship, when enumeration is updated, the change will be visible to all
  * referencing EnumAttributes.
  * 
  * The ID of the enumeration will correspond to the AttributeTypeId of the attribute, as defined
  * in AttributeFactory class. 
  * 
  * @hibernate.class 
  * 			table = "AttribValueEnums"
  *          lazy = "false"
  */
 public class AttributeValueEnumeration extends PersistentEntity{
     protected AttributeValueEnumeration(){
         super();
     }
     
     public AttributeValueEnumeration(EnumAttribute attribute){
         super();
         this.setAttributeTypeId(attribute.getAttributeTypeId());
         attribute.setEnumeration(this);
     }
     
     /**
      * 
      * @return List of all AttributeValues from this AttributeValueEnumeration
      */
     public List getAllValues(){
         List list = new ArrayList();
         for(int i=0; i<this.enumElements.size(); i++){
             AttributeValueEnumerationElement valEl = (AttributeValueEnumerationElement) this.enumElements.get(i);
             AttributeValue attrVal = valEl.getAttributeValue();
             if( attrVal != null ){
                 list.add(attrVal);
             }
         }
         return list;
     }
     
     /**
      * 
      * @return List of all Enabled AttributeValues from this AttributeValueEnumeration
      */
     public List getEnabledValues(){
         List list = new ArrayList();
         for(int i=0; i<this.enumElements.size(); i++){
             AttributeValueEnumerationElement valEl = (AttributeValueEnumerationElement) this.enumElements.get(i);
             AttributeValue attrVal = valEl.getAttributeValue();
             if( attrVal != null && attrVal.isEnabled() ){
                 list.add(attrVal);
             }
         }
         return list;
     }
     
     /**
      * 
      * @return List of all Disables AttributeValues from this AttributeValueEnumeration
      */
     public List getDisabledValues(){
         List list = new ArrayList();
         for(int i=0; i<this.enumElements.size(); i++){
             AttributeValueEnumerationElement valEl = (AttributeValueEnumerationElement) this.enumElements.get(i);
             AttributeValue attrVal = valEl.getAttributeValue();
             if( attrVal != null && attrVal.isEnabled() == false){
                 list.add(attrVal);
             }
         }
         return list;
     }
     
     /**
      * Adds an AttributeValueEnumerationElement to the AttributeValueEnumeration, 
      * making sure the values in the AttributeValueEnumeration are UNIQUE
      * @param enumElement AttributeValueEnumerationElement to be added
      */
     public void addEnumerationElement(AttributeValueEnumerationElement enumElement){
         boolean unique = true;
         //make sure the values within the enumeration (referenced by the AttributeValueEnumerationElements 
         //are unique
         for(int i=0; i<this.enumElements.size(); i++){
             AttributeValueEnumerationElement enumE = (AttributeValueEnumerationElement) this.enumElements.get(i);
             AttributeValue val = (AttributeValue)enumE.getAttributeValue();
             if( val.isTheSame(enumElement.getAttributeValue()) ){
                 unique = false;
                 break;
             }
         }
         if(unique == true){
             this.enumElements.add(enumElement);
         }
     }
     
     /**
      * Adds an AttributeValueEnumerationElement to the AttributeValueEnumeration, 
      * making sure the values in the AttributeValueEnumeration are UNIQUE
      * @param pos position in the List on which to add the AttributeValueEnumerationElement
      * @param enumElement AttributeValueEnumerationElement to be added
      */
     public void addEnumerationElement(int pos, AttributeValueEnumerationElement enumElement){
         boolean unique = true;
         //make sure the values within the enumeration (referenced by the AttributeValueEnumerationElements 
         //are unique
         for(int i=0; i<this.enumElements.size(); i++){
             AttributeValueEnumerationElement enumE = (AttributeValueEnumerationElement) this.enumElements.get(i);
             AttributeValue val = (AttributeValue)enumE.getAttributeValue();
             if( val.isTheSame(enumElement.getAttributeValue()) ){
                 unique = false;
                 break;
             }
         }
         if(unique == true){
             this.enumElements.add(pos, enumElement);
         }
     }
     
     /**
      * Removes the AttributeValueEnumerationElement from the List of AttributeValueEnumerationElements 
      * associated with the AttributeValueEnumeration.
      * @param enumElement AttributeValueEnumerationElement to be removed
      */
     public void removeEnumerationElement(AttributeValueEnumerationElement enumElement){
         this.enumElements.remove(enumElement);
     }
     
     /**
      * Get associated AttributeValueEnumerationElements. 
      * 
      * @return the contained com.poeware.ephotoshop.prods.AttributeValueEnumerationElement.
      *
      * @hibernate.list 
      *    		role="attributeValueElements"
      *    		lazy="false"
      *    		cascade="all"
      *          join="true"
      * @hibernate.collection-key
      *    		column="EnumerationId"
      * @hibernate.collection-index 
      * 			column = "ListNdx"
      * @hibernate.collection-one-to-many
      *    		class="com.poeware.ephotoshop.prods.AttributeValueEnumerationElement"
      * 		
      */
     public List getEnumElements() {
         return enumElements;
     }
     
     private void setEnumElements(List enumElements) {
         this.enumElements = enumElements;
     }
     
     /**
      * This method "recompiles" the Enumeration - ensuring its internal integrity.
      * Should be called after each modification made to the NumericRangeAttributeValues
      * of the enumeration. Especially designed to support NumericRangeAttributeValues 
      * making sure that adding, removing or modifying those values (from within this 
      * enumeration) will remain consistent: there will be no gaps within the total range.<br>
      * This method does nothing, if the associated AtributeValues are not 
      * NumericRangeAttributeValues.
      * @throws BusinessLogicException if there were problems or unrecovable inconsistencies found 
      * (like AttributeValues other than instances of NumericRangeAttributeValues found)
      */
     public void recompileNumericRange() throws BusinessLogicException{
         if(this.enumElements.size() > 0 ){
             //check whether this method applies to this enumeration
             AttributeValueEnumerationElement el = (AttributeValueEnumerationElement)this.enumElements.get(0);
             if((el.getAttributeValue() instanceof NumericRangeAttributeValue)==false) return;
         }else{
             //initialize this enumeration with the full range NumericRangeAttributeValue
             new AttributeValueEnumerationElement(this, 
                 	new NumericRangeAttributeValue(NumericRangeAttributeValue.MIN_RANGE_VALUE,
                 	        					   NumericRangeAttributeValue.MAX_RANGE_VALUE),
                 	        					   I18n.getString("entirePossibleRange"),"entirePossibleRangeDesc");
         }
         /* ok, we need to recompile the range: we need to make sure that the entire range
          * defined in the NumericRangeAttributeValue class will be covered without the gaps.
          * Algorythm:
          * 1) we will sort ascending all contained NumericRangeAttributeValues by their 
          *    MIN values
          * 2) we make sure that the first NumericRangeAttributeValue start from 
          *    MIN_RANGE_VALUE defined in NumericRangeAttributeValue class
          * 3) we make sure that the last NumericRangeAttributeValue ends at 
          *    MAX_RANGE_VALUE defined in NumericRangeAttributeValue class
          * 4) each range will start at its MIN value and will last till MIN 
          *    value of the next range value (the last one will end at MAX_RANGE_VALUE)
          */
         try {
             //soriting
             TreeMap tree = new TreeMap();
             for(int cnt=0; cnt<this.enumElements.size(); cnt++){
                 AttributeValueEnumerationElement el = (AttributeValueEnumerationElement)this.enumElements.get(cnt);
                 NumericRangeAttributeValue val = (NumericRangeAttributeValue) el.getAttributeValue();
                 tree.put( new Double(val.getMinValue()), el);
             }
             //now, clean the collection of the enumeration elements
             this.enumElements.clear();
             //we will add them again in the proper order
             Collection values = tree.values();
             int cnt = 0;
             NumericRangeAttributeValue prevValue = null;
             for (Iterator i = values.iterator(); i.hasNext();) {
                 AttributeValueEnumerationElement el = (AttributeValueEnumerationElement) i.next();
                 NumericRangeAttributeValue v = (NumericRangeAttributeValue) el.getAttributeValue();
                 if( cnt == 0){
                     //make sure the first range starts from the MIN_RANGE_VALUE
                     v.setMinValue(NumericRangeAttributeValue.MIN_RANGE_VALUE);
                     this.addEnumerationElement(el);
                 }else if( v.getMinValue() > NumericRangeAttributeValue.MIN_RANGE_VALUE){
                     prevValue.setMaxValue(v.getMinValue());
                     this.addEnumerationElement(el);
                 }
                 //make sure the last range ends at MAX_RANGE_VALUE
                 v.setMaxValue(NumericRangeAttributeValue.MAX_RANGE_VALUE);
                 prevValue = v;
                 cnt++;
             }
         } catch (Exception e) {
             throw new BusinessLogicException("Exception caught when recompiling numeric range", e);
         }
     }
     
     /**
 	 * 
 	 * @return new AttributeValueEnumeration instance as a copy of this AttributeValueEnumeration instance. The returned instance
 	 * will have id = PersistentEntity.NO_ID_YET, which will become valid after saving instance
 	 */
 	public AttributeValueEnumeration createCopy(EnumAttribute attr){
 	    try {
 	        AttributeValueEnumeration copy = new AttributeValueEnumeration(attr);
 	        
             // copy the contents of  priceComponents collection
             copy.enumElements.clear();
             List l = this.getEnumElements();
             for (int i = 0; i < l.size(); i++) {
                 AttributeValueEnumerationElement originalEnumEl = (AttributeValueEnumerationElement) l.get(i);
                 AttributeValueEnumerationElement copyEnumEl = originalEnumEl.createCopy();
                 copy.enumElements.add(copyEnumEl);
             }
             return copy;
         } catch (Exception e) {
             Terminator.fatal("unnable to create a copy of AttributeValueEnumeration!", e);
             return null;
         }
 	}
 
     /**
 	 * @hibernate.property
 	 * 			column = "AttributeTypeId"
 	 * @return Returns the attributeTypeId.
 	 */
 	public int getAttributeTypeId() {
 		return attributeTypeId;
 	}
 
     public void setAttributeTypeId(int id) {
         this.attributeTypeId = id;
     }
     
     public boolean equals(Object obj) {
         if ( obj == null) return false;
         AttributeValueEnumeration other = (AttributeValueEnumeration)obj;
         return (this.attributeTypeId == other.attributeTypeId) ? true : false;
     }
 
     public int compareTo(Object obj) {
         AttributeValueEnumeration other = (AttributeValueEnumeration)obj;
         return new Long(this.attributeTypeId).compareTo(new Long(other.attributeTypeId));
     }
 
     public int hashCode() {
         return (int)(this.attributeTypeId % Integer.MAX_VALUE);
     }
 
     private int attributeTypeId = -1;
     private List enumElements = new ArrayList();
     private static final long serialVersionUID = 1L;
 }
 
 All that works within JBoss. I get the the AttributeValueEnumereation class via EJB call and then (replying on its lazy=false) use the internal lists of AttributeValueEnumerationElements that couse the problem. That call is been performed from servlet. 
 
 One think I simply cannot understand: everything worked pretty good with Hibernate 2.1.8, but I cannot simply get it running on the 3.1.1. I read the migration guide several times... changed all I could to lazy=false, but it still doesn't help. 
 Many thanks for any further ideas!
 Cheers,
 Bartek 
					
  
						
					 |