Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » (no subject)
(no subject) [message #704323] Thu, 28 July 2011 13:28
Michal is currently offline Michal
Messages: 5
Registered: July 2009
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
Previous Topic:Invalid column name problem
Next Topic:Addtional Foreign Key
Goto Forum:
  


Current Time: Fri Oct 24 18:15:02 GMT 2014

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

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