|(no subject) [message #708063]
||Tue, 02 August 2011 08:00
| Alexander Orlov
Registered: July 2009
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**.
Powered by FUDForum
. Page generated in 0.03161 seconds