Part I Development Tasks and Tools
1. Setting Up a Development Environment
Part II Developing Applications and Application Components
6. Using the Java Persistence API
7. Developing Web Applications
8. Using Enterprise JavaBeans Technology
9. Using Container-Managed Persistence
GlassFish Server Support for CMP
The Mapping Deployment Descriptor File
Automatic Primary Key Generation
Fixed Length CHAR Primary Keys
Automatic Schema Generation for CMP
Version Column Consistency Checking
Configuring Queries for 1.1 Finders
CMP Restrictions and Optimizations
Restrictions on Remote Interfaces
No Support for lock-when-loaded on Sybase
Set RECURSIVE_TRIGGERS to false on MSSQL
12. Developing Lifecycle Listeners
13. Developing OSGi-enabled Java EE Applications
Part III Using Services and APIs
14. Using the JDBC API for Database Access
15. Using the Transaction Service
16. Using the Java Naming and Directory Interface
The following topics are addressed here:
You can configure a CMP bean in GlassFish Server to automatically capture the database metadata and save it in a .dbschema file during deployment. If the sun-cmp-mappings.xml file contains an empty <schema/> entry, the cmp-resource entry in the glassfish-ejb-jar.xml file is used to get a connection to the database, and automatic generation of the schema is performed.
Note - Before capturing the database schema automatically, make sure you have a properly configured CMP resource. See Configuring the CMP Resource.
You can use the capture-schema command to manually generate the database metadata (.dbschema) file. For details, see the Oracle GlassFish Server 3.1-3.1.1 Reference Manual.
The capture-schema utility does not modify the schema in any way. Its only purpose is to provide the persistence engine with information about the structure of the database (the schema).
Keep the following in mind when using the capture-schema command:
The name of a .dbschema file must be unique across all deployed modules in a domain.
If more than one schema is accessible for the schema user, more than one table with the same name might be captured if the -schemaname option of capture-schema is not set.
The schema name must be upper case.
Table names in databases are case-sensitive. Make sure that the table name matches the name in the database.
PostgreSQL databases internally convert all names to lower case. Before running the capture-schema command on a PostgreSQL database, make sure table and column names are lower case in the sun-cmp-mappings.xml file.
An Oracle database user running the capture-schema command needs ANALYZE ANY TABLE privileges if that user does not own the schema. These privileges are granted to the user by the database administrator.