Spring and hibernate applications – HP Integrity NonStop J-Series User Manual

Page 192

Advertising
background image

1.

Inject the interceptor on the Configuration object. The interceptor can be injected in one
of the following ways:
a.

Specify a session-scoped interceptor by opening a session with a call to one of the
overloaded SessionFactory.openSession() methods, which accepts an
Interceptor

. For example:

Configuration cfg = new Configuration().configure();
SessionFactory sessFactory= cfg.buildSessionFactory();
Session session =
sessFactory.openSession(org.hibernate.dialect.SqlmxInterceptor.getInterceptorInstance());

b.

Specify a SessionFactory-scoped interceptor on the Hibernate Configuration
object prior to building the SessionFactory. All session factories built with this
Configuration

object have the interceptor set. For example:

Configuration cfg = new Configuration().configure();
cfg.setInterceptor(SqlmxInterceptor.getInterceptorInstance()));
SessionFactory sessFactory= cfg.buildSessionFactory();

2.

Include Regex Patterns by creating the BrowseAccessIncludeExcludeList.xml
file, and add it to the CLASSPATH (place this file with hibernate.properties/
hibernate.cfg.xml

files). Copy the following into

BrowseAccessIncludeExcludeList.xml

file.

<?xml version="1.0" encoding="UTF-8"?>
<java version="1.6.0_22" class="java.beans.XMLDecoder">
<object class="org.hibernate.dialect.SqlmxInterceptor">
<void property="applyBrowseAccessTo">
<!-- INCLUDE LIST- Please Specify a regular expression
(regex pattern)here.You can specify more than one regex by
adding any number of method tags,for ex: <void
method="add"> <string>regex</string> </void>. If any of
these regex matches with the query browse access will be
enabled -->
<object class="java.util.ArrayList">
<void method=”add”>
<string>select.*</string>
</void>

<void method=”add”>
<string></string>
</void>
</object>
</void>
</object>
</java

By default, the interceptor intercepts all the select queries and enables Browse Access. If there
is a need to disable Browse Access for any of the tables or queries, update the
BrowseAccessIncludeExcludeList.xml

file.

Spring and Hibernate

Applications

For Spring and Hibernate applications, you can enable Browse Access through the
configuration. The steps to enable Browse Access are:

192 Configuring Hibernate Applications on NonStop Systems

Advertising
This manual is related to the following products: