• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

cmr field can refrence an entity of same table

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
entity to refrence the other entity that is in same table like
table xyz
id parent
1 0
2 1

here for 2 parent is 1 may be few id whose parent is 0 meance it dose not
got any parent

can i map this in entity beans
waiting 4 replay
jhon
 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess this is what u want in sql.
parent id need not be 0 just null if there is no parent.

(I dont have any ejbserver installed as of now. I am just studying for the certification and hopefully wont need to actually workout with it till I am done. I have only so much of time available. Anyway when I was studying for Java cert there was this guy who claimed he scored 100% (I scored a lousy 88% with all my notes making and hardwork) just by reading and understanding without writing even one line of code when he was studying. To make matters worse he was not even a Java programmer. So I want to see if thats really true with EJB certs also.

If someone has a ejbserver available and a databse maybe they would like to share their inputs.)



DROP TABLE TABLEA CASCADE CONSTRAINTS ;

CREATE TABLE TABLEA (
PK NUMBER NOT NULL,
TEXT VARCHAR2 (4),
PARENTID NUMBER,
CONSTRAINT TABLEA_PK
PRIMARY KEY ( PK ) );

ALTER TABLE TABLEA ADD CONSTRAINT TABLEA_FK
FOREIGN KEY (PARENTID)
REFERENCES TABLEA (PK) ;
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Did u want How to create in the database or whether it can be implemented using entity beans.
I guess it must be possible to implement it as CMR fields are nothing but virtual fields and you can reference an entity bean of the same type like am EMP-MGR classic Oracle Example.

Correct me if i am wrong!!
 
jhon Reader
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can anybody give me the sample deployment descriptor for this case
 
Nileesha Bojjawar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assume a Table like Employee with the following fields:
EmpId,EmpName,EmpAddress & manager which is the referential integrity field with EmpId of the same table

The UML can be shown (or not) something like this ( considering a bi directional relationship,but in this case we can also say it is unidirectional if we dont want to implement the functionality to get to employees of a manager )

couldnt draw the UML - gave up.

Hope it is clear
The ejb-jar can be as follows:

<ejb-jar>
<display-name>EmployeeJar</display-name>
<enterprise-beans>
<entity>
<display-name>EmployeeBean<.display-name>
<ejb-name>EmployeeBean</ejb-name>
<local-home>EmployeeLocalHome</local-home>
<local>EmployeeLocal</local>
<!-- in this case u need bot the local and remote interface declared as CMR field can return only its local component interface-->
<home>EmployyeHome<home>
<remote>Employee</remote>
<ejb-class>EmployeeBean</ejb-class>
<persistent-type>Contaner</persistent-type>
<prim-key-class>jva.lang.String</prim-key-class>
<reentrant>false</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>EmployeeSchema</abstract-schema-name>
<cmp-field>
<field-name>empId</field-name>
</cmp-field>
<cmp-field>
<field-name>empName</field-name>
</cmp-field>
<cmp-field>
<field-name>empAddress</field-name>
</cmp-field>
<!--do not define mgrId as it is a relationship field-->
<primkey-field>empId</primkey-field>
<!--
.
. define oher req. fields if any
.
-->
</entity>
</enterprise-beans>
<!-- notice only one bean defination-->

<relationships>
<ejb-relation>
<ejb-relationship-role>
<ejb-relationship-role-name>Manager</ejb-relationship-role-name><!-- cancall it anything-->
<multiplicity>One</multiplicity>
<relationship-role-source>
<ejb-name>EmployeeBean</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>employees</cmr-field-name>
<cmr-field-type>Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>Employee</ejb-relationship-role-name><!-- cancall it anything-->
<multiplicity>Many</multiplicity>
<relationship-role-source>
<ejb-name>EmployeeBean</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>manager</cmr-field-name>
<!-- no field type required, its the local component interfaceof the employeeBean-->
</cmr-field>
</ejb-relationship-role>
</ejb-relation>

</relationships>

</ejb-jar>

assign the virtual field manager its value by finding the Employee bean having the emp id of the manager specified in the create arguments within the ejbPostCreate(...) method.

You can also refer to HFEJB chapter on entity bean relationships and replace movied and director to one Employee table andbuild up from there.
Hope this works, I havent tried it but somebody let me know if and where i am wrong.

Regards,
[ October 12, 2004: Message edited by: Nileesha Bojjawar ]
 
The happiness of your life depends upon the quality of your thoughts -Marcus Aurelius ... think about this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic