• 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 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?
 
Popeye has his spinach. I have this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic