-
1. Re: JBoss UUIDKeyGenerator Example
cwrinch Jul 24, 2003 11:01 AM (in response to jmejia424)Your jbosscmp-jdbc.xml should look something like the following, to use the MS SQLServer Command for auto-generated primary keys.
<jbosscmp-jdbc>
java:/SQLServer2000DS
<datasource-mapping>MS SQLSERVER</datasource-mapping>
<enterprise-beans>
<ejb-name>TestTable</ejb-name>
<create-table>false</create-table>
<remove-table>false</remove-table>
<table-name>TestTable</table-name>
<cmp-field>
<field-name>creationDate</field-name>
<column-name>CreationDate</column-name>
<not-null/>
</cmp-field>
<cmp-field>
<field-name>modificationDate</field-name>
<column-name>ModificationDate</column-name>
<not-null/>
</cmp-field>
<!--Generate the primary key with an auto-increment column.-->
<unknown-pk>
<unknown-pk-class>java.lang.Long</unknown-pk-class>
<field-name>testTableKey</field-name>
<column-name>TestTableKey</column-name>
<auto-increment/>
</unknown-pk>
<!--get-generated-keys must be defined in the commands section of the data source mapping-->
<entity-command name="get-generated-keys"/>
<created-time>
<field-name>creationDate</field-name>
</created-time>
<updated-time>
<field-name>modificationDate</field-name>
</updated-time>
....
And your JBOSS_HOME/server/default/conf/standardjbosscmp-jdbc.xml should have the following in the "defaults" section
<!-- other defaults -->
<entity-command name="get-generated-keys" class="org.jboss.ejb.plugins.cmp.jdbc.mssql.JDBCMsSQLCreateCommand"/>
Hope that helps -
2. Re: JBoss UUIDKeyGenerator Example
borislav Jul 25, 2003 7:04 AM (in response to jmejia424)Hi cwrinch,
can you tell me how to configure it for Oracle9i and what value should I type then in home create method for the primary key
(sorry for my poor english)
Thank you in advance -
3. Re: JBoss UUIDKeyGenerator Example - Help for PostgreSQL, pl
artmotion Aug 6, 2003 8:05 AM (in response to jmejia424)I also purchased JBossCMP and the JBossAdminandDev_321 Book. Funny in the JBossAdminAndDev Book the CMP chapter is a bit bigger and has newer information, but ...
Okay I found in the JBA&D book on page 620+ the definition of the <entity-command>. But I seem to need a full example for PostgreSQL.
I'm working now since 2 days on bringing the cmp2 example to PostgreSQL instead on Hypersonic. The only problem I hope that is still open is the auto_generation of the primary key.
PostgreSQL can create a sequence and primary key, if you declare the PK field as serial:
eg:
PostgreSQL:CREATE TABLE "project" (
"idproject" SERIAL,
"projectName" varchar(64),
"budget" int4,
"start" date,
"end" date,
CONSTRAINT "project_pkey" PRIMARY KEY ("idproject")
);
But I don't know how to define the <auto-increment-template> Tag to help JBoss to create the correct table definition.
Nor do I completly understand how to use the UUIDKeyGenerator to let JBoss create the primary keys and use it with PostgreSQL!
Maybe you could present it here. (Or maybe update the cmp2 example. PostgreSQL doesn't like the column name "desc" in the cmp2 example :-)