Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 12:00 Go to next message
Alexander Orlov is currently offline Alexander OrlovFriend
Messages: 10
Registered: July 2009
Junior Member
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),

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 14:11 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Defining the classes would be best. Otherwise just map the foreign keys using @Basic and Integer or other basic type.

James : Wiki : Book : Blog : Twitter
Previous Topic:ConcurrencyManager deadlock
Next Topic:(no subject)
Goto Forum:

Current Time: Sat Apr 17 16:05:55 GMT 2021

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

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

Back to the top