This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 303722 - Criteria API's getCriteriaBuilder() fails if any of the entity classes extend a non-entity class
Summary: Criteria API's getCriteriaBuilder() fails if any of the entity classes extend...
Status: CLOSED DUPLICATE of bug 302606
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P2 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL: http://wiki.eclipse.org/EclipseLink/D...
Whiteboard:
Keywords:
Depends on: 266912 315287
Blocks: 338837
  Show dependency tree
 
Reported: 2010-02-24 03:04 EST by Janne Kytömäki CLA
Modified: 2022-06-09 10:29 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Janne Kytömäki CLA 2010-02-24 03:04:42 EST
Build Identifier: 2.0.1.v20100213-r6600

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.

Reproducible: Always

Steps to Reproduce:
1. Make one of project's @Entity annotated classes extend an empty class without any JPA annotations
2. Make a call to EntityManager.getCriteriaBuilder()
Comment 1 Tom Ware CLA 2010-03-02 11:32:44 EST
Setting target and priority.  See the following page for a description of the meanings of these values:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Comment 2 Janne Kytömäki CLA 2010-03-08 07:53:00 EST
This is duplicate to report
https://bugs.eclipse.org/bugs/show_bug.cgi?id=302606 filed 2010-02-11 12:19

*** This bug has been marked as a duplicate of bug 302606 ***
Comment 3 Michael OBrien CLA 2010-07-21 14:32:06 EDT
>This Transient root of an Entity issue was fixed in SVN rev# 7444 (2 June 2010 in EclipseLink 2.1) for bug# 315287
http://fisheye2.atlassian.com/changelog/eclipselink/?cs=7444
>I forgot that I fixed this 50 days ago (if you still experience the issue - we can reopen the bug)

Fix: We were not returning correctly when the superType of a ManagedType was a
BasicType (Transient)

>This was design issue 103 for enhancement bug# 266912
http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/metamodel_api#DI_103:_20100601:_315287:_Handle_BasicType_as_inheritance_root_for_ManagedTypes
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:29:53 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink