Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Query to MappedSuperclass fails
Query to MappedSuperclass fails [message #544557] Sat, 03 July 2010 19:45 Go to next message
n0weak  is currently offline n0weak
Messages: 4
Registered: April 2010
Junior Member
My application is a store selling fishes, aquariums etc. I want to get a list of top 10 items among all the items based on sales count. I use the following class:

@MappedSuperclass
@NamedQueries({
	@NamedQuery(name="getTopItems",query="SELECT x FROM FishStoreItem x ORDER BY x.salescnt DESC, x.title DESC")
})
public abstract class FishStoreItem extends DomainSuperClass implements Serializable {
......
}


Problem is in the following exception:

Quote:

Exception [EclipseLink-8034] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Error compiling the query [getTopItems: SELECT x FROM FishStoreItem x ORDER BY x.salescnt DESC, x.title DESC]. Unknown entity type [FishStoreItem].



Same code works fine with Apache OpenJpa 2.0.0, but fails with EclipseLink ver 2.0.0, 2.0.1, 1.0 (I have not tested it with other versions).

Upd: Solution

As I was answered here, there is no chance to make it work with EclipseLink. So I solved the problem simply by switching to @Inheritance(strategy=InheritanceType.JOINED).

[Updated on: Mon, 05 July 2010 09:36]

Report message to a moderator

Re: Query to MappedSuperclass fails [message #544799 is a reply to message #544557] Mon, 05 July 2010 14:39 Go to previous message
Doug Clarke is currently offline Doug Clarke
Messages: 155
Registered: July 2009
Senior Member
A JOINED strategy where FishStoreItem has its own table allows for querying on that class where FishStoreItem as a @MappedSuperclass does not. It really depends what you want/need.

If you do not want a common table for FishStoreItem then you may want to consider a TABLE_PER_CLASS inheritance strategy but the querying is less robust and may not support all the features you need.

Doug

Previous Topic:Returning 1 member of a collection using jpql
Next Topic:Question on Native Sequence Implementation Choices..
Goto Forum:
  


Current Time: Fri Oct 31 19:32:01 GMT 2014

Powered by FUDForum. Page generated in 0.13842 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software