File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JBoss/WildFly and the fly likes CMP 2.0 with oracle-sequence and composite primary key Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "CMP 2.0 with oracle-sequence and composite primary key" Watch "CMP 2.0 with oracle-sequence and composite primary key" New topic

CMP 2.0 with oracle-sequence and composite primary key

Hetal Shah

Joined: Feb 20, 2004
Posts: 2
Hi All,

I want to use the CMP 2.0 that would work with the oracle database sequence...
I m using Jboss 4.0.1 as my application server.

I have successfully used the Oracle sequence with my CMP 2.0, ....but it works only when the primary key is a single field primary key and not a composite key for which PrimaryKeyClass would have to be used.
Example when the primary key is a single field::

in ejb-jar.xml::==>


in the jbosscmp-jdbc.xml file ::==>

<entity-command name="oracle-sequence">
<attribute name="sequence">tempseq</attribute>

Here <field-name>no</field-name> is my field on which oracle-sequence is applied....and so that I dont have to pass
that field while calling create method of the bean (CMP 2.0)...

The problem I face is that in one of the tables, the primary key is a composite key, constituting of 4 fields. On one of the fields out of these, the oracle-sequence is to be applied. But the above described method does not work in the case of composite primary key. Could some one please help me out in this ?

the ejb-jar.xml file has the following entry for the primary key class::==>

in the jbosscmp-jdbc.xml file the entry for the field on which sequence is applied, is::==>
<entity-command name="oracle-sequence">
<attribute name="sequence">MT_REQ_EMAIL_ID_SEQ</attribute>

But with above configuration, at deployment time, I get following exception ................. ==>

org.jboss.deployment.DeploymentException: Generation only supported with single PK field
at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.getGenerated
at org.jboss.ejb.plugins.cmp.jdbc.JDBCIdentityColumnCreateCommand.initGe
at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.init(JDBCAbs
at org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCOracleCreateCommand.init(JD
at org.jboss.ejb.plugins.cmp.jdbc.JDBCCommandFactory.createCreateEntityC
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.startStoreManager(JDB
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManage

Please guide me in using Oracle-sequence with CMP 2.0 EntityBean when the primary key is composite key and the application server used is JBoss 4.0.1.

Thanks in advance,
Consider Paul's rocket mass heater.
subject: CMP 2.0 with oracle-sequence and composite primary key
It's not a secret anymore!