Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Error with criteria API if an entity extends a non-entity
Error with criteria API if an entity extends a non-entity [message #516293] Tue, 23 February 2010 14:26 Go to next message
Janne is currently offline Janne
Messages: 10
Registered: February 2010
Junior Member
Hi,

While testing out EclipseLink criteria API, I'm getting an error

java.lang.IllegalArgumentException: The type [null] is not the expected [ManagedType] for the key class [EntityBase]

when calling EntityManager.getCriteriaBuilder(). I seem to get the error only if any of the project's entities extend a non-entity. Without such entities the criteria query works, but if I add to the project something like:

@Entity
public class TestEntity extends EntityBase {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long id;
public void setId(Long id){
this.id=id;
}
public Long getId() {
return id;
}
}

public class EntityBase {

}

.. the criteria query again fails at calling getCriteriaBuilder():

-- clip --
java.lang.IllegalArgumentException: The type [null] is not the expected [ManagedType] for the key class [EntityBase].
at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl .managedType(MetamodelImpl.java:424)
at org.eclipse.persistence.internal.jpa.metamodel.ManagedTypeIm pl.getManagedSuperType(ManagedTypeImpl.java:755)
at org.eclipse.persistence.internal.jpa.metamodel.ManagedTypeIm pl.isAttributeDeclaredOnlyInLeafType(ManagedTypeImpl.java:10 51)
at org.eclipse.persistence.internal.jpa.metamodel.ManagedTypeIm pl.isAttributeDeclaredOnlyInLeafType(ManagedTypeImpl.java:99 9)
at org.eclipse.persistence.internal.jpa.metamodel.ManagedTypeIm pl.getDeclaredAttributes(ManagedTypeImpl.java:314)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl. initializeCanonicalMetamodel(EntityManagerSetupImpl.java:198 0)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl. getMetamodel(EntityManagerSetupImpl.java:1958)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImp l.getMetamodel(EntityManagerFactoryImpl.java:472)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImp l.getCriteriaBuilder(EntityManagerFactoryImpl.java:456)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.getCr iteriaBuilder(EntityManagerImpl.java:2081)
-- clip --

I'm using EclipseLink 2.0.1, Spring 2.5.6, Tomcat 6, PostgreSQL 8.4.

Any ideas how to get around this?

Regards,
Janne
Re: Error with criteria API if an entity extends a non-entity [message #516417 is a reply to message #516293] Tue, 23 February 2010 21:06 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1034
Registered: July 2009
Senior Member
Hello,

Please file a bug for this issue and be sure to vote for it. Unfortunately I can't see any workarounds other than not using criteria api or not inheriting from non-Object classes. You might try making the EntityBase a mapped superclass, but its not much of a workaround. Hopefully someone else when looking at the bug.

Best Regards,
Chris
Re: Error with criteria API if an entity extends a non-entity [message #516480 is a reply to message #516417] Wed, 24 February 2010 08:08 Go to previous message
Janne is currently offline Janne
Messages: 10
Registered: February 2010
Junior Member
Thanks, filed bug 303722 for this issue.

Regards,
Janne
Previous Topic:my-entites.jar in EAR /lib directory using glassfish
Next Topic:JPA / EclipseLink, Spring 2.5 and Tomcat 6
Goto Forum:
  


Current Time: Thu Oct 23 11:23:02 GMT 2014

Powered by FUDForum. Page generated in 0.02090 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software