| Query to MappedSuperclass fails [message #544557] |
Sat, 03 July 2010 15:45  |
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 05:36] Report message to a moderator
|
|
|
| Re: Query to MappedSuperclass fails [message #544799 is a reply to message #544557] |
Mon, 05 July 2010 10:39  |
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
|
|
|
Powered by
FUDForum. Page generated in 0.02013 seconds