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 =
{@JoinColumn(name = "username", referencedColumnName =
"username")},
inverseJoinColumns = {@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@ergonosis.com
| 360.379.1157
| | OpenDocument - OK <http://openoffice.org/>
|