Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » (no subject)
(no subject) [message #699820] Fri, 22 July 2011 11:12
Michal is currently offline MichalFriend
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:How to handle "null primary key encountered" exception?
Next Topic:eclipselink maven repository 404
Goto Forum:
  


Current Time: Tue Apr 23 09:42:54 GMT 2024

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

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

Back to the top