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