[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Using several collection mapping of the same type
|
Hello Pierre-Yves,
The JPA specification mandated that relation table names default to
CLASSA_CLASSB, causing problems when using defaults and having more than
one collection mapping requiring a relation table (M:M or
uni-directional 1:M mappings).
I don't remember off hand how EclipseLink will remove an entire
collection, but if you null out one collection and not the other, you
might get into problems where the provider might use Delete from
CLIENT_ORDER where (CLIENT_UNIQUEID = x).
Best Regards,
Chris
Pierre-Yves SAUMONT wrote:
Hello Chris,
Thanks for the info. It's difficult to understand why Eclipselink does
this (create a multicolumn join table) if it can't work!
While testing it (after modifying the table to have a default value of
""), the result is that deleting works fine except for the last item
in the table (whatever the order of creation).
Beside using separate tables (which I am going to try asap), could you
please elaborate on the reason why removing is causing problems ?
Thanks,
Pierre-Yves
christopher delahunt wrote:
Hello,
They should not be using the same relation table. You need to define
atleast one of the OntToMany mappings to use different table using
the JoinTable annotation or you will get into problems when it tries
to remove from the table as well.
Best Regards,
Chris
Pierre-Yves SAUMONT wrote:
Hi,
I could not find information about the following case: An entity as
several properties that are collection of another same entity.
For example, a Client entity has a collection of Order called
executedOrderList and a second called pendingOrderList.
This is declared in Client as :
@OneToMany(cascade = CascadeType.ALL)
List<Order> executedOrderList;
@OneToMany(cascade = CascadeType.ALL)
Lsit<Order> pendingOrderList;
This results is an table called CLIENT_ORDER with three columns:
CLIENT_UNIQUEID, EXECUTEDORDERLIST_UNIQUEID, PENDINGORDERLIST_UNIQUEID
with a composite primary key:
PRIMARY KEY CLIENT_UNIQUEID, EXECUTEDORDERLIST_UNIQUEID,
PENDINGORDERLIST_UNIQUEID
so far, so good.
The problem is that all three columns in that table must be non null
and have no default value which result in an error as soon as one
entry is added since it automatically have one of the two last
column null.
I can workaround this by editing the create.sql generated file and
either adding DEFULT "" or removing NOT NULL.
My question is how can I make eclipselink generate this correctly,
so that I do not need to edit the generated SQL manually ?
Pierre-Yves
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users