Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] EntityManager.find returning instance of wrong type

Environment: JBoss, Jersey, Spring, EclipseLink JPA, PostgreSQL
 
@Entity
public abstract class Base {
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE)
    private Long id;
 
    @Version
    private long version;
 
    ...
}
 
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
public class Foo extends Base { ... }
 
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
public class Bar extends Base { ... }
 
Then when I do:

    Long aId = 76576; // a valid id for an entity of type Bar
    Foo foo = em.find(Foo.class, aId); // em is EntityManager

an exception is thrown (the root cause seems to be ClassCastException)
because the EntityManager tries to return an object of type Bar.

What am I doing wrong?
-- 
View this message in context: http://www.nabble.com/EntityManager.find-returning-instance-of-wrong-type-tp22367490p22367490.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top