Re: Help with record definition
Franck Routier <[email protected]>
| Newsgroups | gmane.comp.java.orm.simpleorm |
|---|---|
| Message-ID | <[email protected]> |
Hi,
sure, it is the very purpose of SFieldReference.
you should just add the following fields to you UserRole class :
public static final SFieldReference ROLE =
new SFieldReference(meta, Role.meta)
public static final SFieldReference USER =
new SFieldReference(meta, User.meta)
(provided that you defined a Role and User class representing these tables).
This very straightforward constructor works if the name of the fields in
both tables are the same, which seems to be your case !
You then can use SRecordInstance.getReference(UserRole.USER) to access
the referenced user....
Does it help ?
Franck
john_price_137 a écrit :
>
> Help, I have a table with the following definition:
>
> CREATE TABLE USER_ROLES (
> USER_NAME VARCHAR(20) NOT NULL,
> ROLE_ID INTEGER NOT NULL
> );
>
> PRIMARY KEY (USER_NAME, ROLE_ID);
> FOREIGN KEY (USER_NAME) REFERENCES USERS (USER_NAME);
> FOREIGN KEY (ROLE_ID) REFERENCES "ROLE" (ROLE_ID);
>
> and have defined a class for it as:
>
> public class UserRole extends SRecordInstance
> {
> public static final SRecordMeta meta = new
> RecordMeta(UserRole.class, "USER_ROLES");
>
> public static final SFieldString USER_NAME = new
> SFieldString(meta, "USER_NAME", 20, SCon.SFD_PRIMARY_KEY);
>
> public static final SFieldLong ROLE_ID = new SFieldLong(meta,
> "ROLE_ID", SCon.SFD_PRIMARY_KEY);
> }
>
> is it possible to define references to the USERS and ROLE tables ?
> and how do I do it!
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Something is new at Yahoo! Groups. Check out the enhanced email design.
http://us.click.yahoo.com/kOt0.A/gOaOAA/yQLSAA/5cFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/SimpleORM/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/SimpleORM/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[email protected]
mailto:[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/