Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Additional Criteria"
m (New page: <pre> @AdditionalCriteria("this.address.city IS NOT NULL") </pre> <pre> <additional-criteria> <criteria>this.address.city IS NOT NULL</criteria> </additional-criter...) |
|||
Line 1: | Line 1: | ||
+ | {{EclipseLink_UserGuide | ||
+ | |info=y | ||
+ | |toc=n | ||
+ | |eclipselink=y | ||
+ | |eclipselinktype=JPA}} | ||
+ | |||
+ | =Additional Criteria= | ||
+ | |||
+ | Additional criteria can be specified at the Entity or MappedSuperclass level. When specified at the mapped superclass level, it applies to all inheriting entities unless those entities define their own additional criteria, in which case the additional criteria from the mapped superclass is ignored. | ||
+ | |||
+ | The additional criteria supports any valid JPQL string and must use <tt>this</tt> as an alias to form the additional criteria, for example, | ||
+ | |||
+ | <pre> | ||
+ | @Entity | ||
+ | @AdditionalCriteria("this.nut.size = :NUT_SIZE and this.nut.color = :NUT_COLOR")public class Bolt {...} | ||
+ | </pre> | ||
+ | |||
+ | Additional criteria parameters are also accepted and are set through properties on the entity manager factory or on an entity manager. When set on the entity manager, the properties must be set before any query execution and should not be changed for the life span of that entity manager. | ||
+ | |||
+ | Properties set on the entity manager override those similarly named properties set on the entity manager factory. | ||
+ | |||
+ | Additional criteria is not supported with any native queries. | ||
+ | |||
+ | ==Examples== | ||
<pre> | <pre> | ||
@AdditionalCriteria("this.address.city IS NOT NULL") | @AdditionalCriteria("this.address.city IS NOT NULL") | ||
Line 8: | Line 32: | ||
</additional-criteria> | </additional-criteria> | ||
</pre> | </pre> | ||
+ | |||
+ | |||
+ | {{EclipseLink_JPA | ||
+ | |previous= [[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/Criteria|Criteria]] | ||
+ | |next=[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/Native|Native]] | ||
+ | |up=[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying|Querying]] | ||
+ | |version=2.2.0 DRAFT}} |
Revision as of 14:37, 3 February 2011
EclipseLink JPA
EclipseLink | |
Website | |
Download | |
Community | |
Mailing List • Forums • IRC • mattermost | |
Issues | |
Open • Help Wanted • Bug Day | |
Contribute | |
Browse Source |
Additional Criteria
Additional criteria can be specified at the Entity or MappedSuperclass level. When specified at the mapped superclass level, it applies to all inheriting entities unless those entities define their own additional criteria, in which case the additional criteria from the mapped superclass is ignored.
The additional criteria supports any valid JPQL string and must use this as an alias to form the additional criteria, for example,
@Entity @AdditionalCriteria("this.nut.size = :NUT_SIZE and this.nut.color = :NUT_COLOR")public class Bolt {...}
Additional criteria parameters are also accepted and are set through properties on the entity manager factory or on an entity manager. When set on the entity manager, the properties must be set before any query execution and should not be changed for the life span of that entity manager.
Properties set on the entity manager override those similarly named properties set on the entity manager factory.
Additional criteria is not supported with any native queries.
Examples
@AdditionalCriteria("this.address.city IS NOT NULL")
<additional-criteria> <criteria>this.address.city IS NOT NULL</criteria> </additional-criteria>
Criteria | Native | |
EclipseLink Home
JPA User Guide: Table of Contents, Search |
||
How to contribute to this guide... |