persistence@glassfish.java.net

Re: Unwanted unique constraint on join table

From: Wonseok Kim <guruwons_at_gmail.com>
Date: Wed, 8 Nov 2006 12:58:13 +0900

No, it was just checked in. So please be patient until b25 or next(08_nov?)
nightly build.
Cheers,
-Wonseok

On 11/8/06, Greg Ederer <greg_at_ergonosis.com> wrote:
>
> Hi Wonseok,
>
> I'm currently running v2-b25-nightly-03_nov_2006. Is 1392 fixed in this
> snapshot?
>
> Thanks,
>
> Greg
>
> Wonseok Kim wrote:
>
> Hi Greg,
> I think this issue is related to the issue 1392.
> https://glassfish.dev.java.net/issues/show_bug.cgi?id=1392
>
> If the column names of the entity table and many-to-many relation table
> are same, this bug occurs.
>
> The issue is fixed in b25(comming soon), can you try after b25 released?
>
> Thanks
> -Wonseok
>
> On 11/8/06, Greg Ederer < greg_at_ergonosis.com> wrote:
> >
> > Hi Marina,
> >
> > This does create a table with the correct structure; however, I lose
> > control over the name of the table, and the column names. I would like
> > these names to match those in a legacy system. I just tried it with
> > @JoinTable(name="user_role"), and I got the correct structure and table
> > name, but the column names do not match those in my legacy table.
> >
> > Any other suggestions?
> >
> > Thanks for the help.
> >
> > Greg
> >
> > Marina Vatkina wrote:
> >
> > Hi Greg,
> >
> > Does it work if you remove @JoinTable annotation? If you use the DDL
> > generation
> > feature, the provider will generate a join table for you automatically.
> >
> > thanks,
> > -marina
> >
> > Greg Ederer wrote:
> >
> > Hi,
> >
> > I have a ManyToMany relationship between two classes, annotated like so
> > at the owning end:
> >
> > @ManyToMany
> > @JoinTable(name = "user_role", joinColumns =
> > {_at_JoinColumn(name = "username", referencedColumnName = "username")},
> >
> > inverseJoinColumns = {_at_JoinColumn(name = "role_name",
> > referencedColumnName = "name")})
> > private List<Role> roles = new ArrayList<Role>();
> >
> > At the other end:
> >
> > @ManyToMany(mappedBy="roles")
> > private List<AppUser> appUsers = new ArrayList<AppUser>();
> >
> > This produces the following join table (PostgreSQL):
> >
> > CREATE TABLE user_role
> > (
> > role_name varchar(255) NOT NULL,
> > username varchar(255) NOT NULL,
> > CONSTRAINT user_role_pkey PRIMARY KEY (role_name, username),
> > CONSTRAINT fk_user_role_role_name FOREIGN KEY (role_name)
> > REFERENCES "role" (name) MATCH SIMPLE
> > ON UPDATE NO ACTION ON DELETE NO ACTION,
> > CONSTRAINT fk_user_role_username FOREIGN KEY (username)
> > REFERENCES app_user (username) MATCH SIMPLE
> > ON UPDATE NO ACTION ON DELETE NO ACTION,
> > CONSTRAINT user_role_username_key UNIQUE (username)
> > )
> >
> > The user_role_username_key is unwanted. How can I prevent it from being
> > generated?
> >
> > Thanks!
> >
> > Greg
> > --
> >
> > | E R G O N O S I S
> > | Greg Ederer
> > | Lead Developer
> > | greg_at_ergonosis.com
> > | 360.379.1157
> > | | OpenDocument - OK <http://openoffice.org/> <http://openoffice.org/>
> > |
> >
> >
> >
> >
> > --
> >
> > | E R G O N O S I S
> > | Greg Ederer
> > | Lead Developer
> > | greg_at_ergonosis.com
> > | 360.379.1157
> > |
> > | OpenDocument - OK <http://openoffice.org/>
> > |
> >
> >
>
>
> --
>
> | E R G O N O S I S
> | Greg Ederer
> | Lead Developer
> | greg_at_ergonosis.com
> | 360.379.1157
> |
> | OpenDocument - OK <http://openoffice.org/>
> |
>
>