-->
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.  [ 1 post ] 
Author Message
 Post subject: Property duplication fails for components
PostPosted: Wed Aug 08, 2007 12:31 pm 
Beginner
Beginner

Joined: Tue Aug 17, 2004 5:06 am
Posts: 46
Hibernate version: 3.2.3.GA

I think that there's a bug in PersistentClass.

I have the following mapped class:

Code:
@Entity
@Table(name = "OPER_INCOMINGFLIGHTS")
public class IncomingFlight {
   private Long oid;
   private IATAFlightNumber iataFlightNumber;
   private String flightNumber;
   ...
   @Embedded
   @AttributeOverrides( ... )
   public IATAFlightNumber getIataFlightNumber() {
      return iataFlightNumber;
   }
   ...
   @Column(length = 12)
   public String getFlightNumber() {
      return flightNumber;
   }
}


This class embeds a component:

Code:
@Embeddable
public class IATAFlightNumber {
   private String airlineCode;
   private String flightNumber;
   private String suffix;
   ...
   @Column(length = 8)
   public String getFlightNumber() {
      return flightNumber;
   }
   ...
}


PersistentClass checks the mapped classes for duplicate properties. Unfortunately it treats properties that are included inside embedded Components just like if they were part of the (surrounding) mapped class. In my special case a...
Code:
org.hibernate.MappingException: Repeated column in mapping for entity: at.vie.mach2.flight.flightops.flight.IncomingFlight column: flightNumber (should be mapped with insert="false" update="false")

...exception is thrown.

The reason for this is (from org.hibernate.mapping.PersistentClass):
Code:
protected void checkPropertyColumnDuplication(Set distinctColumns, Iterator properties)
   throws MappingException {
      while ( properties.hasNext() ) {
         Property prop = (Property) properties.next();
         if ( prop.getValue() instanceof Component ) { //TODO: remove use of instanceof!
            Component component = (Component) prop.getValue();
            checkPropertyColumnDuplication( distinctColumns, component.getPropertyIterator() );
         }
         else {
            if ( prop.isUpdateable() || prop.isInsertable() ) {
               checkColumnDuplication( distinctColumns, prop.getColumnIterator() );
            }
         }
      }
   }


As you can see the collection distinctColumns is used both for first level properties and component properties, although the component properties are in a different class.
As a result the namespaces are mixed up.

Is this a bug or am I missing something ?


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

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.