Example usage for org.hibernate ScrollMode toResultSetType

List of usage examples for org.hibernate ScrollMode toResultSetType

Introduction

In this page you can find the example usage for org.hibernate ScrollMode toResultSetType.

Prototype

public int toResultSetType() 

Source Link

Document

Get the corresponding JDBC scroll type code constant value.

Usage

From source file:org.jahia.utils.DatabaseUtils.java

License:Open Source License

public static ScrollMode getFirstSupportedScrollMode(ScrollMode fallback, ScrollMode... scrollModesToTest) {

    ScrollMode supportedMode = null;// w  w w.  j ava  2  s .co  m
    Connection conn = null;
    try {
        conn = getDatasource().getConnection();
        DatabaseMetaData metaData = conn.getMetaData();
        for (ScrollMode scrollMode : scrollModesToTest) {
            if (metaData.supportsResultSetType(scrollMode.toResultSetType())) {
                supportedMode = scrollMode;
                break;
            }
        }
    } catch (Exception e) {
        if (logger.isDebugEnabled()) {
            logger.warn("Unlable to check supported scrollable resultset type. Cause: " + e.getMessage(), e);
        } else {
            logger.warn("Unlable to check supported scrollable resultset type. Cause: " + e.getMessage());
        }
    } finally {
        closeQuietly(conn);
    }

    return supportedMode != null ? supportedMode : fallback;

}