INT-3159: JPA: Add max-results Alias Attribute
JIRA: https://jira.springsource.org/browse/INT-3159 * Deprecate `max-number-of-results` * Tests and Docs Doc Polishing
This commit is contained in:
committed by
Gary Russell
parent
405fce672b
commit
9c42a65e3c
@@ -25,6 +25,7 @@ import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.AbstractPollingInboundChannelAdapterParser;
|
||||
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||
import org.springframework.integration.jpa.inbound.JpaPollingChannelAdapter;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* The JPA Inbound Channel adapter parser
|
||||
@@ -43,8 +44,24 @@ public class JpaInboundChannelAdapterParser extends AbstractPollingInboundChanne
|
||||
|
||||
final BeanDefinitionBuilder jpaExecutorBuilder = JpaParserUtils.getJpaExecutorBuilder(element, parserContext);
|
||||
|
||||
String maxNumberOfResults = element.getAttribute("max-number-of-results");
|
||||
boolean hasMaxNumberOfResults = StringUtils.hasText(maxNumberOfResults);
|
||||
|
||||
String maxResults = element.getAttribute("max-results");
|
||||
boolean hasMaxResults = StringUtils.hasText(maxResults);
|
||||
|
||||
if (hasMaxNumberOfResults) {
|
||||
parserContext.getReaderContext().warning("'max-number-of-results' is deprecated in favor of 'max-results'", element);
|
||||
if (hasMaxResults) {
|
||||
parserContext.getReaderContext().error("'max-number-of-results' and 'max-results' are mutually exclusive", element);
|
||||
}
|
||||
else {
|
||||
element.setAttribute("max-results", maxNumberOfResults);
|
||||
}
|
||||
}
|
||||
|
||||
BeanDefinition definition = IntegrationNamespaceUtils
|
||||
.createExpressionDefinitionFromValueOrExpression("max-number-of-results", "max-results-expression",
|
||||
.createExpressionDefinitionFromValueOrExpression("max-results", "max-results-expression",
|
||||
parserContext, element, false);
|
||||
if (definition != null) {
|
||||
jpaExecutorBuilder.addPropertyValue("maxResultsExpression", definition);
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||
import org.springframework.integration.jpa.support.OutboundGatewayType;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* The Parser for the Retrieving Jpa Outbound Gateway.
|
||||
@@ -47,8 +48,24 @@ public class RetrievingJpaOutboundGatewayParser extends AbstractJpaOutboundGatew
|
||||
jpaExecutorBuilder.addPropertyValue("firstResultExpression", firstResultExpression);
|
||||
}
|
||||
|
||||
String maxNumberOfResults = gatewayElement.getAttribute("max-number-of-results");
|
||||
boolean hasMaxNumberOfResults = StringUtils.hasText(maxNumberOfResults);
|
||||
|
||||
String maxResults = gatewayElement.getAttribute("max-results");
|
||||
boolean hasMaxResults = StringUtils.hasText(maxResults);
|
||||
|
||||
if (hasMaxNumberOfResults) {
|
||||
parserContext.getReaderContext().warning("'max-number-of-results' is deprecated in favor of 'max-results'", gatewayElement);
|
||||
if (hasMaxResults) {
|
||||
parserContext.getReaderContext().error("'max-number-of-results' and 'max-results' are mutually exclusive", gatewayElement);
|
||||
}
|
||||
else {
|
||||
gatewayElement.setAttribute("max-results", maxNumberOfResults);
|
||||
}
|
||||
}
|
||||
|
||||
BeanDefinition maxResultsExpression = IntegrationNamespaceUtils
|
||||
.createExpressionDefinitionFromValueOrExpression("max-number-of-results", "max-results-expression",
|
||||
.createExpressionDefinitionFromValueOrExpression("max-results", "max-results-expression",
|
||||
parserContext, gatewayElement, false);
|
||||
if (maxResultsExpression != null) {
|
||||
jpaExecutorBuilder.addPropertyValue("maxResultsExpression", maxResultsExpression);
|
||||
|
||||
@@ -228,7 +228,7 @@
|
||||
The attribute that is used to set the first result marker while executing the
|
||||
results. A negative value will retrieve from first record in the result set.
|
||||
It is a way for the application to use the gateway to paginate the results in
|
||||
combination with the max-number-of-results attribute. This attribute is mutually
|
||||
combination with the max-results attribute. This attribute is mutually
|
||||
exclusive to first-result-expression attribute
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
@@ -240,7 +240,7 @@
|
||||
be evaluated to get the first record while executing the JPA query for result
|
||||
A negative value will retrieve from first record in the result set.
|
||||
It is a way for the application to use the gateway to paginate the results in
|
||||
combination with the max-number-of-results attribute. This attribute is mutually
|
||||
combination with the max-results attribute. This attribute is mutually
|
||||
exclusive to first-result attribute
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
@@ -415,12 +415,19 @@
|
||||
|
||||
<xsd:attributeGroup name="commonRetrievingJpaAttributes">
|
||||
<xsd:attribute name="max-number-of-results">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
[DEPRECATED] Use 'max-results' instead.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="max-results">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Specifies the maximum number of entities that shall be returned
|
||||
by a JPA Operation. Using this attribute you basically set
|
||||
by a JPA Operation. Using this attribute sets
|
||||
the 'maxResults' property of the JPA Query object. This attribute is mutually
|
||||
exclusive to max-results-expression attribute.
|
||||
exclusive with 'max-results-expression' (and the deprecated 'max-number-of-results') attributes.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
@@ -428,9 +435,9 @@
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Specifies the expression for the maximum number of entities that shall be returned
|
||||
by a JPA Operation. Using this attribute you basically set
|
||||
by a JPA Operation. Using this attribute sets
|
||||
the 'maxResults' property of the JPA Query object. This attribute is mutually
|
||||
exclusive to max-number-of-results attribute.
|
||||
exclusive with the 'max-results' attribute.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<int-jpa:inbound-channel-adapter id="jpaInboundChannelAdapter2"
|
||||
entity-manager-factory="entityManagerFactory"
|
||||
entity-class="org.springframework.integration.jpa.test.entity.StudentDomain"
|
||||
max-number-of-results="13"
|
||||
max-results="13"
|
||||
channel="out">
|
||||
<int:poller fixed-rate="5000"/>
|
||||
</int-jpa:inbound-channel-adapter>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
entity-class="org.springframework.integration.jpa.test.entity.StudentDomain"
|
||||
order="1"
|
||||
first-result="1"
|
||||
max-number-of-results="55"
|
||||
max-results="55"
|
||||
request-channel="in"
|
||||
reply-channel="out"
|
||||
reply-timeout="100"
|
||||
|
||||
@@ -409,6 +409,7 @@
|
||||
query="select s from Student s" ]]><co id="inboundAdapterQuery"/><![CDATA[
|
||||
expect-single-result="true" ]]><co id="inboundAdapterExpectResult"/><![CDATA[
|
||||
max-number-of-results="" ]]><co id="inboundAdapterMaxResults"/><![CDATA[
|
||||
max-results="" ]]><co id="inboundAdapterMaxResults2"/><![CDATA[
|
||||
max-results-expression="" ]]><co id="inboundAdapterMaxResultsExpression"/><![CDATA[
|
||||
delete-after-poll="true"> ]]><co id="inboundAdapterDeleteAfterPoll"/><![CDATA[
|
||||
<int:poller fixed-rate="2000" >
|
||||
@@ -452,16 +453,22 @@
|
||||
</para>
|
||||
</callout>
|
||||
<callout arearefs="inboundAdapterMaxResults">
|
||||
<para>
|
||||
<emphasis>Deprecated</emphasis>. Use <code>max-results</code> instead.
|
||||
<emphasis>Optional</emphasis>.
|
||||
</para>
|
||||
</callout>
|
||||
<callout arearefs="inboundAdapterMaxResults2">
|
||||
<para>
|
||||
This non zero, non negative integer value tells the adapter not to select more than given number
|
||||
of rows on execution of the select operation. By default, if this attribute is not set,
|
||||
all the possible records are selected by given query. This attribute is mutually exclusive to
|
||||
all the possible records are selected by given query. This attribute is mutually exclusive with
|
||||
<code>max-results-expression</code>. <emphasis>Optional</emphasis>.
|
||||
</para>
|
||||
</callout>
|
||||
<callout arearefs="inboundAdapterMaxResultsExpression">
|
||||
<para>
|
||||
An expression mutually exclusive to <code>max-number-of-results</code> that can
|
||||
An expression, mutually exclusive with <code>max-results</code>, that can
|
||||
be used to provide an expression that will be evaluated to find the maximum number of results
|
||||
in a result set. <emphasis>Optional</emphasis>.
|
||||
</para>
|
||||
@@ -1155,6 +1162,7 @@ public class Student {
|
||||
jpa-operations=""
|
||||
jpa-query=""
|
||||
max-number-of-results="" ]]><co id="outGateMaxNumOfResults"/><![CDATA[
|
||||
max-results="" ]]><co id="outGateMaxNumOfResults2"/><![CDATA[
|
||||
max-results-expression="" ]]><co id="outGateMaxNumOfResultsExpression"/><![CDATA[
|
||||
first-result="" ]]><co id="outGateFirstResult"/><![CDATA[
|
||||
first-result-expression="" ]]><co id="outGateFirstResultExpression"/><![CDATA[
|
||||
@@ -1182,16 +1190,22 @@ public class Student {
|
||||
</para>
|
||||
</callout>
|
||||
<callout arearefs="outGateMaxNumOfResults">
|
||||
<para>
|
||||
<emphasis>Deprecated</emphasis>. Use <code>max-results</code> instead.
|
||||
<emphasis>Optional</emphasis>.
|
||||
</para>
|
||||
</callout>
|
||||
<callout arearefs="outGateMaxNumOfResults2">
|
||||
<para>
|
||||
This non zero, non negative integer value tells the adapter not to select more than given number
|
||||
of rows on execution of the select operation. By default, if this attribute is not set,
|
||||
all the possible records are selected by given query. This attribute is mutually exclusive to
|
||||
all the possible records are selected by given query. This attribute is mutually exclusive with
|
||||
<code>max-results-expression</code>. <emphasis>Optional</emphasis>.
|
||||
</para>
|
||||
</callout>
|
||||
<callout arearefs="outGateMaxNumOfResultsExpression">
|
||||
<para>
|
||||
An expression mutually exclusive to <code>max-number-of-results</code> that can
|
||||
An expression, mutually exclusive with <code>max-results</code>, that can
|
||||
be used to provide an expression that will be evaluated to find the maximum number of results
|
||||
in a result set. <emphasis>Optional</emphasis>.
|
||||
</para>
|
||||
|
||||
@@ -604,13 +604,17 @@
|
||||
</para>
|
||||
</section>
|
||||
<section id="3.0-jpa-max-results">
|
||||
<title>JPA Adapters: max-results-expression attribute</title>
|
||||
<title>JPA Adapters: max-results and max-results-expression Attributes</title>
|
||||
<para>
|
||||
Retrieving gateways and inbound adapters now has a flexibility to specify the maximum
|
||||
number of results in a result set as an expression. We now have <code>max-number-of-results</code>
|
||||
and <code>max-results-expression</code> attributes which are used to provide the
|
||||
maximum number of results and the expression to compute the maximum number of results in the
|
||||
result set respectively. For more information see <xref linkend="jpa"/>.
|
||||
The JPA retrieving gateway and inbound adapter now have an attribute to specify the maximum
|
||||
number of results in a result set as an expression. In addition, the
|
||||
<code>max-results</code> attribute has been introduced to replace
|
||||
<code>max-number-of-results</code>, which has been deprecated.
|
||||
<code>max-results</code> and <code>max-results-expression</code>
|
||||
are used to provide the maximum number of results,
|
||||
or an expression to compute the maximum number of results, respectively, in the
|
||||
result set.
|
||||
For more information see <xref linkend="jpa"/>.
|
||||
</para>
|
||||
</section>
|
||||
<section id="3.0-redis">
|
||||
@@ -640,7 +644,7 @@
|
||||
<para>
|
||||
New <classname>FileListFilter</classname>s that use a persistent <classname>MetadataStore</classname> are
|
||||
now available. These can be used to prevent duplicate files after a system restart. See
|
||||
<xref linkend="file-reading"/>, <xref linkend="ftp-inbound"/>, and <xref linkend="sftp-inbound"/> for more information.
|
||||
<xref linkend="file-reading"/>, <xref linkend="ftp-inbound"/>, and <xref linkend="sftp-inbound"/> for more information.
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user