Database Hibernate Resources


This chapter is composed of :

  1. Introduction
  2. Database Hibernate Resources
    1. Source Folder
    2. Configuration
    3. Options
      1. Generate Hibernate Code
        1. Use Basic Renderer
          1. Generate Empty Concrete Classes
          2. Generate Basic Finder
        2. Use Velocity Renderer
      2. Generate Stateless Session Bean
      3. Use hbm2java Config
        1. Use Internal Config
        2. Configuration
    4. Finish

 

1. Introduction

The purpose of this chapter is to show how to generate Hibernate Java classes.

This wizard needs to use a target Java Project.

This wizard is an integration of the separate Hibernate Extensions hbm2java.

EclipseDatabase provides the current embedded Hibernate Extensions API.

 

2. Database Hibernate Resources

To start the Hibernate Java Resources wizard, select :

File->New->Other->Database->Database Hibernate Resources

or

Select an object in the Package Explorer View or the Navigator View then right-click and select :

New->Other->Database->Database Hibernate Resources

The selection is contextual.

This means that if you select an existing Hibernate Configuration file.

 

 

The wizard will be opened with a selected Hibernate Configuration file if applicable.

 

Otherwise :

 

 

The wizard will be opened without any selected Hibernate Configuration file.


 

You can run this wizard in another way.

Select a set of Hibernate Mapping file definitions, right-click and select :

Create Hibernate Java Resources

 

 

However the Configuration selector will not be available.

 

2.1. Source Folder

 

 

Type in the Java Source Folder text field the targeted Java Source Folder.

The Java Source Folder should exist.

Otherwise use the Browse button :

 

 

Select the appropriate Java Source Folder.

 

2.2. Configuration

 

 

Use the Browse button :

 

 

Select the appropriate Hibernate Configuration file.

 

2.3. Options

You can set various Hibernate options.

 

2.3.1. Generate Hibernate Code

The hbm2java Hibernate code generator works in two ways :

The first one is an internal code generator, Basic Renderer.

The second one uses a Velocity template, Velocity Renderer.

 

2.3.1.1. Use Basic Renderer

This code generator is the preferred Hibernate code generator.

 

2.3.1.1.1. Generate Empty Concrete Classes

With this option, the wizard will generate two sets of classes:

- one set of Abstract classes.

- one set of Concrete classes.

With this option you will obtain a clean separation between your code and the generated code.

 

2.3.1.1.2. Generate Basic Finder

With this option, the wizard will generate three sets of classes:

- one set of Abstract classes.

- one set of Concrete classes.

- one set of Finder classes.

With this option you will obtain a clean separation between your code and the generated code.

 

2.3.1.2. Use Velocity Renderer

Below your Plugin Templates or MyTemplates you should see the following file:

Hibernate/pojo.vm

If checked, the wizard will use this velocity template to generate Hibernate Java classes.

 

2.3.2. Generate Stateless Session Bean

The hbm2java tool contains a Stateless Session Bean generator.

This generator uses as its input a set of Hibernate files.

 

2.3.3. Use hbm2java Config

You can use an optional xml file to configure this wizard.

 

2.3.3.1. Use Internal Config

Below your Plugin Templates or MyTemplates you should see the following file:

Hibernate/hbm2java.config.xml

If checked, the wizard will use this hbm2java.config.xml file.

 

2.3.3.2. Configuration

 

 

The Browse button lets you locate an .xml file.

Usually you locate hbm2java.config.xml file.

 

2.4. Finish

The code generation process will be performed in the targeted Java Source Folder.

 

 

Detailed information will be displayed in the DatabaseConsole window.