|
I know that xdoclet (CVS snapshot from ~a week ago) supports real m:n
relations (as defined in mastering ejb 2nd ed.) with Weblogic.
Bi-directional is easy: put the @ejb.relation tag with the same name in both
beans, each associated with an abstract getter that returns a
java.util.Collection:
// StudentBean.java
/**
* @ejb.interface-method
view-type="local"
* @ejb.relation
name="students-courses"
*
role-name="student-has-many-courses"
* @weblogic:relation
join-table-name="student_xref_course"
* @weblogic:column-map
foreign-key-column="student_id"
* key-column="student_id"
*/
public abstract java.util.Collection getCourses();
/**
* @ejb.interface-method
view-type="local"
*/
public abstract void setCourses( java.util.Collection courses );
// CourseBean.java
/**
* @ejb.interface-method
view-type="local"
* @ejb.relation
name="students-courses"
*
role-name="course-has-many-students"
* @weblogic:relation
join-table-name="student_xref_course"
* @weblogic:column-map
foreign-key-column="course_id"
* key-column="course_id" */
public abstract java.util.Collection getStudents();
/**
* @ejb.interface-method
view-type="local"
*/
public abstract void setStudents( java.util.Collection students );
I think the term "real m:n relationships", though, is a misnomer.
This just doesn't describe reality. For example, the student's grade for a
given course cannot be described in this object model. In reality, "grade"
would be a field in the above "student_xref_course" table. It is better
mapped using a "fake" m:n relationship. In other words, two 1:m
relationships--Student:Enrollments, Course:Enrollments.
In the book, Roman says that he prefers the fake relationships, but (I
think) for the wrong reason. It's not about extensibility or
control.
HTH,
Joe >>> "Ingo Bruell" <[EMAIL PROTECTED]> 05/07/02 10:51AM >>> Hi Aslak, > Hi. I don't understand what you mean by "real relations" > and "enrollment table". Are you talking about unidirectional m:n > relations? Join tables? I have used the termini from the book MasteringEJB2. That says that m:n relations that uses a enrolement table are fake m:n relations and m:n relations that uses Collections or something else to holde the relation information are real m:n realtions. > Anyway, XDoclet should(*) support relations with any combination of > directionality and cardinality, at least on the ejb-jar.xml level. See > documentation for @ejb:relation. i am using xdoclet drom cvs (one week old), jboss3.0.0RC2 and jdk1.4. CU Ingo Br�ll _______________________________________________________________ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] _______________________________________________ Xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user |
- [Xdoclet-user] real m-n relations Ingo Bruell
- Re: [Xdoclet-user] real m-n relations aslak.hellesoy
- Re: [Xdoclet-user] real m-n relations Ingo Bruell
- Joseph Parks
