[ 
https://issues.apache.org/jira/browse/OFBIZ-4346?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13068996#comment-13068996
 ] 

David E. Jones commented on OFBIZ-4346:
---------------------------------------

The concern of the attribute is not so much if limit/offset are allowed, if 
they are not supported the JDBC driver will eventually throw an exception.

The attribute would be used to configure the SQL syntax variation for the 
offset/limit concept. The attribute might look something like:

{code}
            <xs:attribute name="offset-style" default="fetch">
                <xs:simpleType><xs:restriction base="xs:token">
                        <xs:enumeration value="fetch"/>
                        <xs:enumeration value="limit"/>
                </xs:restriction></xs:simpleType>
            </xs:attribute>
{code}

The code for the SQL syntax options might look like:

{code}
        if (databaseNode."@offset-style" == "limit") {
            // use the LIMIT/OFFSET style
            this.sqlTopLevel.append(" LIMIT ").append(limit ?: "ALL")
            this.sqlTopLevel.append(" OFFSET ").append(offset ?: 0)
        } else {
            // use SQL2008 OFFSET/FETCH style by default
            if (offset != null) this.sqlTopLevel.append(" OFFSET 
").append(offset).append(" ROWS")
            if (limit != null) this.sqlTopLevel.append(" FETCH FIRST 
").append(limit).append(" ROWS ONLY")
        }
{code}

This is how I would have implemented it in OFBiz, demonstrated by the fact that 
this is how I implemented it Moqui.


> Support MySQL and Postgres's LIMIT and OFFSET options
> -----------------------------------------------------
>
>                 Key: OFBIZ-4346
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-4346
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>    Affects Versions: SVN trunk
>            Reporter: Shi Jinghai
>            Priority: Minor
>         Attachments: mysql_postgres_limit_offset_trunk.patch
>
>
> Two helper classes are added for MySQL and Postgres to support LIMIT and 
> OFFSET options.
> These classes can be configured in entityengine.xml:
> helper-class="org.ofbiz.entity.datasource.postgres.PostgresHelperDAO" for 
> Postgres
> and
> helper-class="org.ofbiz.entity.datasource.mysql.MysqlHelperDAO" for MySQL.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to