Monday November 21, 2005
Do you know java2db mode for deployment in Sun App server? One my colleague from doc team sent me one EJB module that was very strange for him. The module includes
some CMP beans but mapping file sin-cmp-mappings.xml nether dbschema ar missing in this module. First question from him was: How you can run this module without mappings info? How does a container know which CMP fields should be mapped in appropriate table columns? I should disclose that I couldn't answer his questions. I asked Rochelle Raccah who works in team that works on mapping framework in Sun Application server. She answered, this module uses java2db mode for deployment in Sun Application server.
What does it mean? It means that you can't write sun-cmp-mappings.xml file for this module. This file is created during module deployment.
How does container know which CMP fields should be mapped in appropriate table column? Since the container creates tables too. If you already has these tables, you shouldn't use this mode.
How can I enable it in NetBeans? Very simple add folowing elements in sun-ejb-jar.xml:
<cmp-resource>
<jndi-name>jdbc/cmpcustomer</jndi-name>
<create-tables-at-deploy>true</create-tables-at-deploy>
<drop-tables-at-undeploy>true</drop-tables-at-undeploy>
<database-vendor-name>oracle</database-vendor-name>
</cmp-resource>
and delete sun-cmp-mappings.xml file and dbschema from project. Option create-tables-at-deploy should be set to true. Option database-vendor-name specifies the name of the database vendor for which tables can be created. Allowed values are db2, mssql, oracle, pointbase, and sybase.