So I'm a little confused about how the EJB 2.0 relations are represented in the db. I 
know that JBoss (my app server) creates an additional attribute for a relation in the 
table if it is specified in the xml file under relationships (ie user has one-to-one 
with  contact info, db creates  USER_CONTACTINFO_PKUSERNAME in user and 
CONTACTINFO_PKCONTACTINFOID in contact info so that they point to each other). That 
means, and please tell me if this is correct, I do not need to have attribute fields 
in my beans for representing foreign keys (ie user has pkusername, and and I don't 
need to put in there a FKContactInfo explicitly).

Second, how do local interfaces work? Here is the actual scenario I'm working with. 2 
tables, book and course. A 'Book' has a 'course' that may or not exist. I made 
'course' a Local Interface for a 'book'. If the course already exists in the db, how 
do I create a book with a course? Normally I call create() with a param that has both 
a book and a course in it, and it calls the helper method create course to make the 
course instance and call 'setcourse()'. Now am I creating a real course in the 
database (and it MAY OR MAY NOT exist in the db already), or is it simply making a 
local interface so he can refer to the the right row in the db? should i maybe call 
findbyprimarykey in the createcourse below? I recall my trace said once that the row 
already exists in the db.


public void ejbPostCreate(BookValueObject Book,CourseValueObject Course, 
DepartmentValueObject Department) throws CreateException{
CourseLocal myCourseLocal  = createCourse(Course, Department);
setCourse(myCourseLocal);
}


private CourseLocal createCourse(CourseValueObject CourseView, DepartmentValueObject 
DepartmentView){
try{
InitialContext initial = new InitialContext();
CourseLocalHome home = (CourseLocalHome)
initial.lookup("java:comp/env/ejb/Course");
return home.create(CourseView,DepartmentView);
} catch (Exception e) {
throw new javax.ejb.EJBException(e);
}
}
;


In addition, have I specified something wrong in code or xml dd?, because for one 
creation of a table jboss 3.0 seems to be doing too many transactions here (insert a 
user, delete him cause for some reason the info was done wrong the first time, insert 
his contact info, delete it cause its wrong for some reason, then insert the correct 
ones for both. Very odd!

INSERT INTO USER 
VALUES('eric','open','2002-03-10','bird',NULL,'2002-03-10','normal',NULL)
INSERT INTO CONTACTINFO VALUES(0,'','','etree',NULL,'','','','',0,'','','','',NULL)
DELETE FROM CONTACTINFO WHERE PKCONTACTINFOID=0 AND TELEPHONENUMBER='' AND 
ADDRESSFIRST='' AND EMAIL='etree' AND FKUSERNAME=NULL AND FIRSTNAME='' AND CITY='' AND 
ADDRESSSECOND='' AND POSTALCODE='' AND FKHOUSINGUNITID=0 AND COUNTRY='' AND 
LASTNAME='' AND STATE='' AND MIDDLENAME='' AND USER_CONTACTINFO_PKUSERNAME=NULL
INSERT INTO CONTACTINFO VALUES(0,'','','etree',NULL,'','','','',0,'','','','','eric')
DELETE FROM USER WHERE PKUSERNAME='eric' AND ACCOUNTSTATUS='open' AND 
EXPIRATIONDATE='2002-03-10' AND PASSWORD='bird' AND RELIABILITY=NULL AND 
LOCKDATE='2002-03-10' AND ACCOUNTTYPE='normal' AND CONTACTINFO_PKCONTACTINFOID=NULL
INSERT INTO USER VALUES('eric','open','2002-03-10','bird',NULL,'2002-03-10','normal',0)



Sorry for the amount of content in this message. Please answer as many questions as 
soon as possible( mainly the recreate question and the key question) , I really need 
the help.


Warmest Regards,
Eric Dunn

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to