I know you can do it in one direction but not both, I haven't been able to do
it in both directions
say you have
| @Entity
| class Employee{
| employeeno;
| name;
| ....
| mangerid;
| //managerid points to an existing employeeno in the same schema
| }
|
from the code above you can have the following relationship setup in one
direction
Employee can get a Manager (another employee) but from a Manager Employee to
get a list of his subordinates (possible by running the query below) is not
straight forward:
| SELECT e FROM Employee e WHERE e.managerid=:currentemployeeid
|
to establish a self-referenced relationship try
| class Employee{
| @Id employeeno;
| name;
| //....other properties...
| @ManyToOne
| @JoinColumn(name="managerid",referencedColumn="employeeno")
| managerid
| }
|
i have done this from memory, I will probably pull out me examples later on,
and double check the @JoinColumn annotation I always get the name, and
referencedname upside down
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3944054#3944054
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3944054
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user