473,473 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Inverse uniqueness in EJB 3.0 many-to-many relation

168 New Member
Hello.

I have an @Entity class, Person, with a @ManyToMany relation with itself. This relation is the friend association. The code of the class is as follows:

@Entity
@Table(name = "PERSON", uniqueConstraints={@UniqueConstraint(columnNames={ "PERSON_NAME"})})
public class Person {

@Id
@GeneratedValue
@Column(name = "PERSON_ID")
private Long id;

@Column(name = "PERSON_NAME")
private String name;

@ManyToMany
@JoinTable(name = "FRIENDS",
joinColumns = @JoinColumn(name = "PERSON_A"),
inverseJoinColumns = @JoinColumn(name = "PERSON_B"))
private Set<Person> friends = new HashSet<Person>();

/*contructors, getters, setters, etc*/
}

The way the class is defined right now allows for the simultaneous existence of <peter, john> and <john, peter> relations when there should only be one (because john and peter are friends implies peter an john are friends). Does the Java Persistence API supply a mechanism to enforce this type of behaviour?

Any help would be apreciated.

Thanks in advance,
Feb 7 '07 #1
0 1199

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: David C. Fox | last post by:
Is there a function which takes a list of tuples and returns a list of lists made up of the first element of each tuple, the second element of each tuple, etc.? In other words, the the inverse...
1
by: Robert Ludewig | last post by:
<LinkList> <Link ID="A01" /> <Link ID="A02" /> <Link ID="A03" /> <Link ID="A01" /> </LinkList> How can I specify in a xmlschema that in the linklist are no occurences with same ID ? (Last...
1
by: Robert Ludewig | last post by:
<LinkList> <Link ID="A01" /> <Link ID="A02" /> <Link ID="A03" /> <Link ID="A01" /> </LinkList> How can I specify in a xmlschema that in the linklist are no occurences with same ID ? (Last...
2
by: thijs.kupers | last post by:
Hi I want to define a schema for my xml. I want to transform the xml in java-code by xslt, so it is important (for naming conflicts) that the values of the name-attributes in the xml been...
1
by: jt | last post by:
Looking up into Crypto.PublicKey.RSA, I see there is a computed value named "u" for which I can't see the use. The value of "u" is the inverse of p modulo q, in the code: obj.u =...
2
by: Edward Hua | last post by:
Hi, I'm wondering if there is a function written in C that computes the inverse hypergeometric distribution (i.e., not the density function, but the cumulative distribution) that's been written...
5
by: Mario | last post by:
How do I get the inverse of a cosine, that is, cos(a) = x, I have x and I need to know a? I don't need the hyperbolic inverse, unless I can use it to get the cosine inverse. Greetings, Mario
7
by: ajeetbaraskar | last post by:
can any one send me the codining for finding out inverse of a 6x6 matrix
1
by: dazzler | last post by:
Hi! I have problem with numpy, multiplying with an inversed matrix will crash python :( this works fine: from numpy import matrix A = matrix(,]) B = matrix(,]) print A.I #inverse matrix
3
by: drsunil | last post by:
I need c++ code for inverse of nxn matrix ,if available please help me
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.