Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » Entities with Foreign Key references to phantom tables & entities
Entities with Foreign Key references to phantom tables & entities [message #708059] Tue, 02 August 2011 08:00 Go to next message
Eclipse UserFriend
I have an existent legacy DDL which I've to map onto JPA.

I've already mapped the USERS SQL table to an USERS JPA @Entity.

create table USERS (
-- a bunch of fields
primary key (id),
foreign key FK_USERS_CONTACT (CONTACT_ID) references CONTACTS(ID),
foreign key USER_SPEAKS_NATIVE_LANGUAGE (NATIVE_LANGUAGE) references LANGUAGES(ID),
foreign key USER_HAS_PREFERRED_TIMEZONE (PREF_TIMEZONE_ID) references TIME_ZONES(ID),
foreign key USER_OWNS_USAGE (USAGE_OWNER_ID) references USAGE_OWNERS(ID)
);

But there are those FKs to existent SQL tables that I don't want to depict in any JPA classes. The best solution would be to do the following:

@OneToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
@JoinColumn(nullable = false, name = "USAGE_OWNER_ID")
private Object usageOwners;

...basically to use a **dummy/phantom Object** that could reflect any table reference. But the raw Object type isn't allowed in JPA.

So how can *I depict & fulfill the Foreign Key constraints of the USERS table without depicting any SQL tables in JPA*. I just want to **depict the FK references to those tables but not the actual SQL tables**.
Re: Entities with Foreign Key references to phantom tables & entities [message #708154 is a reply to message #708059] Tue, 02 August 2011 10:11 Go to previous message
Eclipse UserFriend
Defining the classes would be best. Otherwise just map the foreign keys using @Basic and Integer or other basic type.
Previous Topic:ConcurrencyManager deadlock
Next Topic:(no subject)
Goto Forum:
  


Current Time: Wed Jul 23 09:42:16 EDT 2025

Powered by FUDForum. Page generated in 0.10470 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top