Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Addtional Foreign Key
Addtional Foreign Key [message #704300] Thu, 28 July 2011 13:28 Go to next message
Michal  is currently offline Michal Friend
Messages: 3
Registered: July 2011
Junior Member
Hi,
I am working on some project and have such situation:

I have Entity Service:


@Entity
public class Service implements Serializable {
@Id
private Long id;
@ManyToMany
Collection<Language> language;
}


And entity Language:


@Entity
public class Language implements Serializable {
@Id
@Column(length=4)
private String id;
}


Thanks to it I have Entity Service which contains collection of available languages in DB it creates table: Service, Language and Service_Language for many to many mapping.

Now I want to add subscription entity:



@Entity
public class Subscription implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@ManyToOne(optional=false)
private Service service;
@ManyToOne
private User user;

@ManyToOne
private Language language;
}


Now it creates table Subscription with service_id field which is foreign key to Service.id and field language_id which is foreign key to Language.id

OK but in this situation I can create subscription entity with some service id and language which is not on that service list.

I need one more foreign key contraint: foreign key (service_id,language_id) references Service_Language(service_id,language_id)

Ive tried some methods but it does not work and I cannot find anything in Google.

Maybe some of you can help me.

Cheers
Mike
Re: Addtional Foreign Key [message #704340 is a reply to message #704300] Thu, 28 July 2011 14:14 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
This was answered in post at
http://www.eclipse.org/forums/index.php/t/222554/
(no subject) [message #704365 is a reply to message #704300] Thu, 28 July 2011 14:14 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
This was answered in post at
http://www.eclipse.org/forums/index.php/t/222554/
Previous Topic:(no subject)
Next Topic:SELECT and CONCAT
Goto Forum:
  


Current Time: Thu Apr 25 16:11:11 GMT 2024

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

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

Back to the top