how Entity bean will be populated from database

Hi,

i am new for EJB.

I am using CMP EJB2.X with jboss4 server. How can i store and retrieve date from database. When i call create then i creates a bean instance but it does not store passing values in create in database. And when i call findAll() then it does not give me the all records what are in the database. Database have only 10 records. My query is correct in descriptor. It give me only one record which data i pass in create method.

Would u please advise me to solve this problem. What mistakes i am committing. If u need then i'll place u me code.

Thanks in advance

Ravi

[622 byte] By [raviadhaa] at [2007-11-27 1:58:12]
# 1
Can any body tell me how can i store a record in database using CMP bean. i dont know where i can write insert qeury? Pelase help its urgentMessage was edited by: raviadha
raviadhaa at 2007-7-12 1:34:36 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Hello,I think this coud help you. http://cwiki.apache.org/GMOxDOC12/very-simple-example-of-cmp-ejb.htmlRegards,Sebastien Degardin
sdegardina at 2007-7-12 1:34:37 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

Hello Sabastien,

Thank you very much to give me a good link. but i am still have problem. entity bean does not store data in database and also does not retrive data from db. I thing there is mistak with descriptor. i am placing here please give me help.

*********ejb-jar.xml

<entity>

<ejb-name>StudentCMP</ejb-name>

<home>org.retro.gis.system.StudentCMPHome</home>

<remote>org.retro.gis.system.StudentCMP</remote>

<local-home>org.retro.gis.system.StudentCMPLocalHome</local-home>

<local>org.retro.gis.system.StudentCMPLocal</local>

<ejb-class>org.retro.gis.system.StudentCMPBean</ejb-class>

<persistence-type>Container</persistence-type>

<prim-key-class>java.lang.Integer</prim-key-class>

<reentrant>False</reentrant>

<cmp-version>2.x</cmp-version>

<abstract-schema-name>Student</abstract-schema-name>

<cmp-field><field-name>id</field-name></cmp-field>

<cmp-field><field-name>name</field-name></cmp-field>

<cmp-field><field-name>subject</field-name></cmp-field>

<primkey-field>id</primkey-field>

<query>

<description>Query for get all students</description>

<query-method>

<method-name>findAll</method-name>

<method-params></method-params>

</query-method>

<ejb-ql><![CDATA[ SELECT OBJECT(s)

FROM Student s

]]> </ejb-ql>

</query>

</entity>

************jboss.xml

<jboss>

<enterprise-beans>

<entity>

<ejb-name>StudentCMP</ejb-name>

<jndi-name>org/retro/gis/system/StudentCMPHome</jndi-name>

<resource-ref>

<res-ref-name>Datasource</res-ref-name>

<resource-name>mySQL</resource-name>

</resource-ref>

</entity>

</enterprise-beans>

<assembly-descriptor>

</assembly-descriptor>

<resource-managers>

<resource-manager>

<res-name>mySQL</res-name>

<res-jndi-name>MySqlDS1</res-jndi-name>

</resource-manager>

</resource-managers>

</jboss>

**************** jbosscmp-jdbc.xml

<jbosscmp-jdbc>

<defaults>

<datasource>MySqlDS1</datasource>

<datasource-mapping>mySQL</datasource-mapping>

</defaults>

<enterprise-beans>

<entity>

<ejb-name>StudentCMP</ejb-name>

<create-table>true</create-table>

<remove-table>true</remove-table>

<table-name>simple</table-name>

<cmp-field>

<field-name>id</field-name>

<column-name>id</column-name>

</cmp-field>

<cmp-field>

<field-name>name</field-name>

<column-name>name</column-name>

<jdbc-type>VARCHAR</jdbc-type>

<sql-type>VARCHAR(50)</sql-type>

</cmp-field>

<cmp-field>

<field-name>subject</field-name>

<column-name>subject</column-name>

<jdbc-type>VARCHAR</jdbc-type>

<sql-type>VARCHAR(50)</sql-type>

</cmp-field>

</entity>

</enterprise-beans>

</jbosscmp-jdbc>

******************mysql-ds.xml

<datasources>

<local-tx-datasource>

<jndi-name>MySqlDS1</jndi-name>

<connection-url>jdbc:mysql://192.168.5.204:3306/gcs1</connection-url>

<driver-class>com.mysql.jdbc.Driver</driver-class>

<user-name>gcs_user</user-name>

<password>gcs_pass</password>

<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>

<metadata>

<type-mapping>mySQL</type-mapping>

</metadata>

</local-tx-datasource>

</datasources>

Is there problem with creating datasource ?

Please help me to solve this problem

raviadhaa at 2007-7-12 1:34:37 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...