openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hinshaw <>
Subject CriteriaQuery on mapped-superclass does not work with orm.xml
Date Tue, 19 Mar 2013 19:13:10 GMT
I have been switching code to use the orm.xml from the annotations for code cleanliness and
better documentation. As I was doing this I broke the ability to query an MappedSuperClass.
I know what this is not a jpa 2.0 specification but this functionality does work with openjpa.
 I have tried the newest 2.2.1 version and am still having the same problem. I did notice
that in the orm.xsd for 2.0 mapped-superclass does not support the <inheritance> tag
which may be causing my problem since I am unable to specify that the strategy will be TABLE_PER_CLASS
and this may be a prerequisite? Any ideas?

The following are my base class and the class that extends AnalyticsOperation. 

	<mapped-superclass class="com.hp.vf.server.domain.AnalyticsOperation"

			<basic name="isPublic" />
			<basic name="name" />
			<basic name="description" />

			<one-to-many name="inputs"
				fetch="LAZY" orphan-removal="true">
				<order-column />
					<cascade-all />

			<one-to-many name="outputs" target-entity="com.hp.vf.server.domain.metric.Metric"
				fetch="LAZY" orphan-removal="true">
				<order-column />
					<cascade-all />

			<one-to-one name="owner" fetch="LAZY">
					<cascade-persist />
					<cascade-merge />

	<entity class="com.hp.vf.server.domain.RAnalyticsOperation"
		<inheritance strategy="TABLE_PER_CLASS" />
			<basic name="code" fetch="LAZY">
				<lob />

In this class the clazz is the AnalyticsOperation.class from above.
    	EntityManager entityManager = ThreadLocalPersistenceManager.getEntityManager();
		CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
		CriteriaQuery<T> criteriaQuery = criteriaBuilder.createQuery(clazz);
		Root<T> root = criteriaQuery.from(clazz);

		List<Predicate>  conditions = new ArrayList<Predicate>();

		if(searchColumn != null && (searchText != null && searchText.trim().length()
> 0 )){
			conditions.add(<String> get(searchColumn), "%" + searchText.trim()
+ "%"));

But when executing I get this exception. The is "Root<T> root = criteriaQuery.from(clazz);"

java.lang.IllegalArgumentException: "class com.hp.vf.server.domain.AnalyticsOperation" categorized
	at org.apache.openjpa.persistence.meta.MetamodelImpl.instantiate(
	at org.apache.openjpa.persistence.meta.MetamodelImpl.find(
	at org.apache.openjpa.persistence.meta.MetamodelImpl.entity(
	at org.apache.openjpa.persistence.criteria.CriteriaQueryImpl.from(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message