This week's book giveaway is in the Design forum.
We're giving away four copies of Head First Software Architecture: A Learner's Guide to Architectural Thinking and have Raju Gandhi, Mark Richards, Neal Ford 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

CMP Entity Beans and Pointbase

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have created a simple Bean Managed Persistence EJB and got it to work with PointBase4 and JBoss3.0.3
I am now try to convert the bean to use Container mananged persistence but I am having problems running the test program.
The EJB is a simple "Quote of the day" app that reads a quote from the database.
The table is defined as follows in Pointbase
**************************************************
CREATE TABLE "QOTD"."QOTD" (
"ID" INTEGER IDENTITY NOT NULL,
"CREATE_DATE" TIMESTAMP,
"MODIFY_DATE" TIMESTAMP,
"QUOTE_TEXT" VARCHAR(1000),
"DISPLAY_FLAG" BOOLEAN );
**************************************************
The Entity bean is defined in ejb-jar.xml as follows..
**************************************************
<ejb-jar>

<enterprise-beans>
...
<entity>
<ejb-name>quotecmp</ejb-name>
<home>qotd.QuoteCMPHome</home>
<remote>qotd.QuoteCMP</remote>
<ejb-class>qotd.QuoteCMPBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>qotd.QuotePK</prim-key-class>
<reentrant>false</reentrant>

<cmp-version>2.x</cmp-version>
<abstract-schema-name>QuoteCMPBean</abstract-schema-name>
<cmp-field><field-name>quote</field-name></cmp-field>
<cmp-field><field-name>display</field-name></cmp-field>
<cmp-field><field-name>lastMod</field-name></cmp-field>
<cmp-field><field-name>created</field-name></cmp-field>
</entity>
</enterprise-beans>
...
</ejb-jar>
**************************************************
The content of the jbosscmp-jdbc.xml packaged in the jar is :

**************************************************
<?xml version="1.0" encoding="UTF-8"?>
<jbosscmp-jdbc>
<defaults>
<debug>true</debug>
<create-table>false</create-table>
<remove-table>false</remove-table>

<unknown-pk>
<unknown-pk-class>java.lang.Integer</unknown-pk-class>
<field-name>id</field-name>
<column-name>id</column-name>
<jdbc-type>INTEGER</jdbc-type>
<auto-increment/>
</unknown-pk>

<read-only>false</read-only>
<time-out>0</time-out>
<select-for-update>false</select-for-update>
<pk-constraint>true</pk-constraint>
<relation-mapping-style>foreign-key</relation-mapping-style>
<read-ahead>
<strategy>on-load</strategy>
<page-size>500</page-size>
<eager-load-group>group name</eager-load-group>
</read-ahead>
</defaults>
<enterprise-beans>
<entity>
<ejb-name>quotecmp</ejb-name>
<table-name>qotd</table-name>
<cmp-field>
<field-name>created</field-name>
<column-name>create_date</column-name>
</cmp-field>
<cmp-field>
<field-name>lastMod</field-name>
<column-name>modify_date</column-name>
</cmp-field>
<cmp-field>
<field-name>quote</field-name>
<column-name>quote_text</column-name>
</cmp-field>
<cmp-field>
<field-name>display</field-name>
<column-name>display_flag</column-name>
</cmp-field>
</entity>
</enterprise-beans>
</jbosscmp-jdbc>
**************************************************
I pieced this file together from various snippets of info on the net so not sure if it is correct!

When I run a simple test to create a new bean I get the following error:
**************************************************
javax.ejb.FinderException: Find failed: java.sql.SQLException: Expected to find "FROM" instead found
"QOTD" at position 13.
at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractQueryCommand.execute(JDBCAbstractQueryCommand.
java:148)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCFindEntityCommand.execute(JDBCFindEntityCommand.java:4
4)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.findEntity(JDBCStoreManager.java:541)
at org.jboss.ejb.plugins.CMPPersistenceManager.findEntity(CMPPersistenceManager.java:336)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.findEntity(CachedConnect
ionInterceptor.java:301)...
**************************************************

TIA for your help!
Ayub.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like the SQL query used by your bean is not quite right. This should be inside your ejb-jar.xml file, and should conform to the EJB-QL standard e.g:
<query>
<query-method>
<method-name>findAll</method-name>
</query-method>
<ejb-ql>SELECT OBJECT(a) FROM QOTD AS a</ejb-ql>
</query>
 
Ayub Malik
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply I will try this. I was under the assumption that the App server was supposed to create the finder methods?
 
reply
    Bookmark Topic Watch Topic
  • New Topic