-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: JPQL and inheritance
PostPosted: Tue May 24, 2011 11:33 am 
Newbie

Joined: Tue May 24, 2011 11:04 am
Posts: 1
(sorry - I'm write from notebook, now havn't any IDE, syntax-errors may present in code)

I'm use JPA and Hibernate as provider.
I have a next classes-hierarchy:

Code:
@Entity
@Inheritance(InheritanceType=JOINED)
public abstract class CLS {
// ...
}

@Entity
public class CLS1 extends CLS {
// ...
}

@Entity
public class CLS2 extends CLS {
// ...
}

// ...

@Entity
public class CLS_nnn extends CLS {
// ...
}


I wanna retreive per one request entities CLS1 and CLS2 (but not CLS3, CLS4 etc). For example, without any additional conditions. I'm wrote next code:

Code:
EntityManager em = ...
TypedQuery tq<CLS> = em.createQuery("SELECT c FROM CLS WHERE TYPE(c) = CLS1 OR TYPE(c) = CLS2", CLS.class);
List<CLS> result = tq.getResultList();


...but I get an empty list.

What wrong?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.