Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / October 2003

Tip: Looking for answers? Try searching our database.

same field for both primary key and foreign key

Thread view: 
Olve Hansen - 29 Oct 2003 17:52 GMT
I am using MySQL as db, and want to make a bean that has a primary key
that references the primary key of another bean through a one - one
relationship.

How can I make the primary key in one table also be a foreign key? Is
this possible using JBoss, version 3.0.8?

I have tried to make the relationship (cmr-field-name) name be the same
as the cmp field name, and setting the field to be the primary key, but
JBoss doesn't let me do that.

If anyone else has done this, please help.

Thanks
Olve
Johann Burkard - 29 Oct 2003 19:30 GMT
> I am using MySQL as db, and want to make a bean that has a primary key
> that references the primary key of another bean through a one - one
> relationship.

Why don't you reference the other bean directly? Like

public interface BlaLocal extends EJBLocalObject {
 public BlaLocal getBla();
 public void setBla(BlaLocal bla);
}

and

public class BlaEJB implements EntityBean {
 public abstract void setBla(BlaLocal bla);
 public abstract BlaLocal getBla();
}

Johann
Signature

`/()|_| (/-\|\| |-|/-\\/3 |\/|`/ |3/-\|\||)\/\/||)7|-| ||°|-| `/()|_|
/-\5|< |\||(3|_`/

Olve Hansen - 30 Oct 2003 10:42 GMT
>> I am using MySQL as db, and want to make a bean that has a primary key
>> that references the primary key of another bean through a one - one
[quoted text clipped - 13 lines]
>  public abstract BlaLocal getBla();
> }

I want to ensure that three entities have a primary key in the same
sequence. So that if entity1 has a pk of 00001, entity two cannot have
the same pk.

This can be done in relational db's by having another entity responsible
for the primary key sequence, and have the three original entities
primary keys reference the pk of the sequence entity as a foreign key.
This way I can ensure that the primary keys in my three entities are in
the sequence specified in the sequence entity.

I know how to do this in relational databases, but I dont know if this
is possible in EJB or in JBoss 3.0.8.

Olve
Marek Lange - 31 Oct 2003 22:24 GMT
Olve Hansen schrieb:

>>> I am using MySQL as db, and want to make a bean that has a primary
>>> key that references the primary key of another bean through a one -
[quoted text clipped - 26 lines]
> I know how to do this in relational databases, but I dont know if this
> is possible in EJB or in JBoss 3.0.8.

I think it is only supported in JBoss 3.2.x.

-marek


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.