Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: AW: [eclipselink-users] Query on rootclass (inheritance hierarchy) also returns instances of the subclasses

To set descriptor to never read subclasses, you can use a
DescriptorCustomizer (@Customizer)

descriptor.getInheritancePolicy().setShouldReadSubclasses(false)



Goerler, Adrian wrote:
> 
> Hi Christian,
> 
> In [JPA] 2.0, you could use an "entity type expression":
> 
> "select t from Team t where TYPE(t) = Team"
> 
> -Adrian
> 
> 
> Adrian Görler
> SAP AG
> 
> Pflichtangaben/Mandatory Disclosure Statements:
> http://www.sap.com/company/legal/impressum.epx
> 
> 
> Von: eclipselink-users-bounces@xxxxxxxxxxx
> [mailto:eclipselink-users-bounces@xxxxxxxxxxx] Im Auftrag von Christian
> Neumann
> Gesendet: Freitag, 22. Januar 2010 14:19
> An: EclipseLink User Discussions
> Betreff: [eclipselink-users] Query on rootclass (inheritance hierarchy)
> also returns instances of the subclasses
> 
> Hello List,
> 
> I am currently working on a RCP project with Eclipselink JPA for
> persistence support.
> 
> As suggested by the title I have two classes and one inherit from the
> other. Code looks like the following:
> 
> @Entity
> @Table(name="Teams")
> @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> public class Team implements Comparable<Team>{...}
> 
> And
> 
> @Entity
> @Table(name="MissionTeams")
> public class MissionTeam extends Team {...}
> 
> Now I want to do a Query to get all "Team"-Objects stored in the database.
> So i call:
> 
> Query qtm = entityManager.createQuery("select t from Team t");
> 
> But the query returns also objects of the Type "MissionTeam" instead only
> those of "Team". A search on the "Eclipselink User Guide" told me that
> this behaviour is intentional and can be configured using "Descriptors".
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://old.nabble.com/Query-on-rootclass-%28inheritance-hierarchy%29-also-returns-instances-of-the-subclasses-tp27273012p27324328.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top