Sample Hibernate application for OpenAccess data sources - Forum - DataDirect Connect - Progress Community

Sample Hibernate application for OpenAccess data sources


Sample Hibernate application for OpenAccess data sources

  • This article demonstrates how to configure sample Hibernate application with OpenAccess data sources. It includes sample Hibernate application,
    that can run SQL queries on OpenAccess data sources connected using OpenAccess JDBC driver. It also includes sample OpenAccessDialect class which allows
    hibernate to generate the appropriate SQL’s for OpenAccess. This solution uses Emp class with annotations to map objects with the defined Emp table, having
    EmpNo as a Primary Key and other columns consists few data types.
    Step-by-Step Instructions to build a Hibernate application
    It’s very simple to configure the Hibernate application with your OpenAccess data source via JDBC. All you need is

    ·        Eclipse

    ·        OpenAcess Server

    ·        OpenAccess JDBC driver

    ·        Hibernate package


    1.      Create a java project in eclipse and add the attached application. Add the OpenAccess JDBC driver (oajc.jar) in build path to connect to the OpenAccess Server.

    Add all the required Hibernate jars which can be downloaded from Your Application will looks like as shown below



    2.      The sample dialect class contains definition of data types and scalar functions supported by OpenAccess. As shown below, this dialect class

    should be the part of hibernate package “org.hibernate.dialect “.



    3.      Define the OpenAccess server configuration details and dialect class name in hibernate.cfg.xml file. Hibernate requires to know in advance where

    to find the mapping information that defines how your Java classes relate to the database tables. It also requires a set of configuration settings

    related to database and other related parameters. All such information is usually supplied in this XML file.

    Please note that property “” is set as “create”, which will recreate the Emp table every time you runs the application,

    You can modify it according to your needs.

    4.      This application is ready to run and can be triggered from “”. File “input1.sql” contains few examples of select queries to execute

    via hibernate HQL and file “input2.sql” contains few examples of scalar functions defined in the OpenAccessDialect class. These files will execute against

    your configured OpenAccess data source and generates the corresponding output files.

    Download ZIP File
  • The mentioned steps to setup Hibernate application are applicable to both OpenAccess 7.2 and OpenAccess 8.0



  • Thanks Prashant