Home WrongClassException switching from eclipselink to Hibernate
Reply: 0

WrongClassException switching from eclipselink to Hibernate

user2061 Published in July 23, 2018, 1:44 pm

I had a working code written in pure JPA and running on Glassfish v3.0.1 (eclipselink) I decided to switch persistence provider to hbernate 3.5.1-final and I'm experiencing exceptions in one query that had worked before.
All other queries( named queries) work fine. Could someone tell me what is wrong with the one below? I can't make it a named query because I need to sort the job by different parameters.
Why are the collections inside Job class not being queried?
Thanks for any help

javax.persistence.PersistenceException: org.hibernate.WrongClassException: Object with id: 16 was not of the specified subclass: mypackage.Job (Discriminator: )


select job0_.id as id7_, job0_.version as version7_, job0_.created as creat ed7_, job0_.error_msg as error5_7_, job0_.priority as priority7_, job0_.retries as retries7_, job0_.status as status7_, job0_.subject as subject7_, job0_.user_id as user10_7_, job0_.DTYPE as DTYPE7_ from test_job job0_ where job0_.user_id=? order by job0_.created DESC limit ?

List foo;

   String qst = " SELECT e from Job e WHERE e.user = :user ";

   qst += " ORDER BY e." + orderBy;
   Query q = em.createQuery(qst); //TypedQuery +List
   q.setParameter("user", user);

   foo = q.getResultList();


Job extends BaseEntity{
@ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "job_address",
            joinColumns = @JoinColumn(name = "job_id"),
            inverseJoinColumns = @JoinColumn(name = "address_id"))
    protected Set FtpAddress> addresses;

    @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    @JoinTable(name = "job_transmission",
            joinColumns = @JoinColumn(name = "job_id"),
            inverseJoinColumns = @JoinColumn(name = "transmission_id"))
    protected Set Transmission> transmissions; 

@MappedSuperclass BaseEntity{
    int id
    int version ....
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.4225 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO