Hi Sebastien,

Sebastien Cesbron wrote:
Hi,

I hope this is my last post for the week :-)
Here are two new problems that I face during my adoption of ojb. I think
 that if I can resolve both of them and the other one of my last post I
can change my mapping layer.

1 - Is it possible to specify a conversion on a collection. There is
nothing about that in the doc. My problem is that I have a n:m relation
between an object (represented by a table in my db) and an enum type
(represented by an Integer column.
Ex :
Class User -> Table User
Enum Role -> Integer on table User_Role

table User
(
  ID integer not null
)

table User_Role
(
  USER_ID integer not null,
  ROLE_ID integer not null,
  foreign key (USER_ID)   references USER(ID)
)

This point is quite important because I don't want to create a Role
table. I want my Role's instances to be unique, I don't want to load one
Role each time I have a link.

tough question! I don't have a very beautiful solution, but it's better than nothing. The problem is that we don't have a table for Role and thus are not able to treat it as a normal entity class...


1. define a class User
2. define a class UserRole
3. in the class-descriptor for User define a collection descriptor for a collection of UserRole elements. Do not specify as an m:n collection, as there is no table for the n side!
4. define class Role with a static factory method that creates Role instances from a given ROLE_ID and that maintains the uniqueness of Role instances.
5. in class UserRole provide a method getRole() that navigates to the Role instance identified ROLE_ID.


Maybe someone has a more elegant solution?

2 - Multiple indirections
User has a m:n relation with Profile which has m:n relation with Role. I
want to put a link User -> Role in my object model. Is it possible to
specify such a link that has to go through the tables :
TUSER->TUSER_PROFILE->TPROFILE->TPROFILE_ROLE ?

I am not sure what exactly you want to do. OJB queries provide path-expressions that allow to specify such joins across an arbitrary number of joined tables (see query html for details).


cheers,
Thomas


This point is not really important because if this is not possible I can load my profiles and make the user-role link programmaticaly.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to