-->
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: Update to Hibernate 3.6.1: Error "expecting IdClass mapping"
PostPosted: Mon Feb 28, 2011 4:09 pm 
Newbie

Joined: Mon Feb 28, 2011 3:46 pm
Posts: 1
Hi,

currently I'm upgrading from Hibernate 3.5 to Hibernate 3.6.1 and I'm stuck in following exception:

Code:
Caused by: java.lang.IllegalArgumentException: expecting IdClass mapping
   at org.hibernate.ejb.metamodel.AttributeFactory$2.resolveMember(AttributeFactory.java:924)
   at org.hibernate.ejb.metamodel.AttributeFactory$3.resolveMember(AttributeFactory.java:962)
   at org.hibernate.ejb.metamodel.AttributeFactory.determineAttributeMetadata(AttributeFactory.java:445)
   at org.hibernate.ejb.metamodel.AttributeFactory.buildAttribute(AttributeFactory.java:95)
   at org.hibernate.ejb.metamodel.MetadataContext.wrapUp(MetadataContext.java:216)
   at org.hibernate.ejb.metamodel.MetamodelImpl.buildMetamodel(MetamodelImpl.java:66)
   at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902)
   at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)


I had to debug the sources to find the classes, which seem to cause this Exception.. but I just don't understand what is wrong, or what changed in 3.6.1.
Maybe someone out there can help me :)

There is this MappedSuperclass
Code:
@MappedSuperclass
public abstract class SoBean extends Object implements Idable, Serializable{
   
   @Column(name = "data_preview", nullable = true)
   private Boolean beanPreview;
   
   @Column(name = "data_deleted", nullable = true)
   private Boolean beanDeleted;
...
}

and a class extending the superclass
Code:
@Entity
@Table(name = "so_season", catalog = "db173274_30")
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public class SoSeason extends SoBean {

   private static final long serialVersionUID = 2953899113435252942L;

   @Id
   @GeneratedValue(strategy = IDENTITY)
   @Column(name = "id_season", unique = true, nullable = false)
   private Integer idSeason;
   
   @Column(name = "season_start", nullable = false)
   private int seasonStart;

...
}


For some reason Hibernate wants me to have an @IdClass mapping ... but why and where should this be?

This following code from Hibernatesources checks if the identifier is virtual and throws the exception if not.
Of course the identifier is an Integer, and it is not virtual ...so - why is it a problem in 3.6.1 ?
Code:
private final MemberResolver VIRTUAL_IDENTIFIER_MEMBER_RESOLVER = new MemberResolver() {
      /**
       * {@inheritDoc}
       */
      public Member resolveMember(AttributeContext attributeContext) {
         final IdentifiableType identifiableType = (IdentifiableType) attributeContext.getOwnerType();
         final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel( identifiableType );
         if ( ! entityMetamodel.getIdentifierProperty().isVirtual() ) {
            throw new IllegalArgumentException( "expecting IdClass mapping" );
         }
         org.hibernate.type.Type type = entityMetamodel.getIdentifierProperty().getType();
         if ( ! EmbeddedComponentType.class.isInstance( type ) ) {
            throw new IllegalArgumentException( "expecting IdClass mapping" );
         }

         final EmbeddedComponentType componentType = (EmbeddedComponentType) type;
         final String attributeName = attributeContext.getPropertyMapping().getName();
         return componentType.getTuplizerMapping()
               .getTuplizer( EntityMode.POJO )
               .getGetter( componentType.getPropertyIndex( attributeName ) )
               .getMember();
      }
   };


If someone has a hint or a solution for this - please help me :)

Thanks in advance - Jan


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.