This week's book giveaway is in the Java in General forum.
We're giving away four copies of Helidon Revealed: A Practical Guide to Oracle’s Microservices Framework and have Michael Redlich on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

CMP 2.0 with oracle-sequence and composite primary key

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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::==>

<prim-key-class>java.lang.Integer</prim-key-class>
<primkey-field>no</primkey-field>

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

<unknown-pk>
<unknown-pk-class>java.lang.Integer</unknown-pk-class>
<field-name>no</field-name>
<column-name>NO</column-name>
<jdbc-type>Integer</jdbc-type>
<sql-type>Integer</sql-type>
<auto-increment/>
</unknown-pk>
<entity-command name="oracle-sequence">
<attribute name="sequence">tempseq</attribute>
</entity-command>

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::==>
<prim-key-class>com.business.process.EjbTwoPK</prim-key-class>

in the jbosscmp-jdbc.xml file the entry for the field on which sequence is applied, is::==>
<unknown-pk>
<unknown-pk-class>com.business.process.EjbTwoPK</unknown-pk-class>
<field-name>emailId</field-name>
<column-name>EMAIL_ID</column-name>
<jdbc-type>Integer</jdbc-type>
<sql-type>Integer</sql-type>
<auto-increment/>
</unknown-pk>
<entity-command name="oracle-sequence">
<attribute name="sequence">MT_REQ_EMAIL_ID_SEQ</attribute>
</entity-command>

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
PKField(JDBCAbstractCreateCommand.java:160)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCIdentityColumnCreateCommand.initGe
neratedFields(JDBCIdentityColumnCreateCommand.java:46)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.init(JDBCAbs
tractCreateCommand.java:84)
at org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCOracleCreateCommand.init(JD
BCOracleCreateCommand.java:37)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCCommandFactory.createCreateEntityC
ommand(JDBCCommandFactory.java:151)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.startStoreManager(JDB
CStoreManager.java:466)
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,
 
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic