persistence@glassfish.java.net

Re: (TopLink Essentials) bogus _at_JoinTable default value

From: Guy Pelletier <guy.pelletier_at_oracle.com>
Date: Tue, 30 Oct 2007 09:29:29 -0400

Klaus,

Notice that a mappedBy for a OneToMany is required otherwise it will default
to a uni-directional mapping that uses a JoinTable.

See the following sections 9.1.24 and 2.1.8.5 from the spec for more
information.

Cheers,
Guy

----- Original Message -----
From: "Klaus Unger" <UngerKlaus_at_gmx.de>
To: <persistence_at_glassfish.dev.java.net>
Sent: Monday, October 29, 2007 4:33 PM
Subject: Re: (TopLink Essentials) bogus @JoinTable default value


> On Friday 26 October 2007 14:18:38 Gordon Yorke wrote:
>> Can you post the source for the mapping along with the SQL that TopLink
>> is generating?
>> --Gordon
>
> I don't have the SQL here right now but the code is like this:
> Do not hesitate to contact me if you are unable to reproduce the problem!
> ------------------------------
> @Entity
> public class Element{
> @Id
> @GeneratedValue
> protected Long id;
>
> @Basic
> protected String name;
>
> protected Element() {
> super();
> }
>
> public Element(String name) {
> this.name = name;
> }
>
> public String getName() {
> return name;
> }
> }
>
> @Entity
> public class Container {
> @Id
> @GeneratedValue
> protected Long id;
>
> @OneToMany
> protected Collection<Element> elements = new LinkedList<Element>();
>
> public Container() {
> super();
> }
>
> public Element newElement(String name) {
> Element e = new Element(name);
> elements.add(u);
> EntityManagerSingleton.get().persist(u);
> return e;
> }
>
> public Collection<Element> getElements() {
> return elements;
> }
> }
>