users@glassfish.java.net

Re: One to one integrity is not maintained

From: <glassfish_at_javadesktop.org>
Date: Wed, 02 May 2007 10:22:53 PDT

Hi Ketan,

Please check, how you mapped the relationship. For instance, as Project owns the relationship, it must not use the mappedBy annotation. Also you are specifying that the relationship is mapped to a join table. Third, you should either annotate fields *or* properties, not both. Assuming your table definitions, the correct mapping would be:

On Project class:
@OneToOne
@JoinColumn(name="appid")
public Application getApplication() { return application; }

On Application class:
@OneToOne(mappedBy="application")
public Project getProject() { return project; }

More examples can be found in the JPA specification on page 184.

Please re-run your example. If the persistence provider doesn't enforce uniqueness, and you are using TopLink-Essentials, you should file a glassfish issue under

https://glassfish.dev.java.net/
[Message sent by forum member 'mf125085' (mf125085)]

http://forums.java.net/jive/thread.jspa?messageID=215203