Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » (no subject)
(no subject) [message #708063] Tue, 02 August 2011 12:00 Go to next message
Alexander Orlov is currently offline Alexander Orlov
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),
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**.
(no subject) [message #708162 is a reply to message #708063] Tue, 02 August 2011 14:11 Go to previous message
James is currently offline James
Messages: 272
Registered: July 2009
Senior Member
Defining the classes would be best. Otherwise just map the foreign keys using @Basic and Integer or other basic type.

--
James : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/
Previous Topic:Entities with Foreign Key references to phantom tables & entities
Next Topic:(no subject) duplicate, please ignore topic
Goto Forum:
  


Current Time: Fri Oct 31 14:26:18 GMT 2014

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

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