1

The following snippet is retrieving a Player object instance from the database. How can I make it retrieve only the User instance and then use another query to retrieve a Player instance?

Query q = em.createQuery("SELECT u FROM User u WHERE email = :email", User.class);
User u = (User) q.setParameter("email", email).getSingleResult();

Inherance type is Joined.

Thank you,

Hibernate 4.3.5.Final

EDIT: I could find a question that matches this and already flagged my question as duplicate. Thank you!

Community
  • 1
  • 1
hawaii
  • 328
  • 4
  • 12
  • How is it returning a Player on this query? – JSeven Apr 30 '14 at 23:46
  • Player inherits from the User class and the specific instance I'm testing (via the email variable), is a Player. The problem with this is that with that code I wasnt expecting a Player instance and that is what I want to understand. – hawaii Apr 30 '14 at 23:48
  • possible duplicate of [Retrieve only the superclass from a class hierarchy](http://stackoverflow.com/questions/13186572/retrieve-only-the-superclass-from-a-class-hierarchy) – hawaii May 01 '14 at 00:07

0 Answers0