[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] none of the @OneToMany fields are being persisted in an @Embeddable class
|
Hi Chris,
on setting the collection (mm) the testcase works ;-) - however, I realised that my test case had one difference from my real case, which had orphanRemoval = true - I have updated the test case by adding a fourth class (Another) that is mapped with a @OneToMany with orphanRemoval = true and although the "Many" objects are persisted the "Another" objects are not - I might be misunderstanding the meaning of orphanRemoval, but it seems to me that eclipselink is being over-zealous in removing the Another objects before they have a chance to be persisted.
I have updated the bug with the new version of the testcase and the log when running.
Regards,
Paul
On 2011-06 -22, at 17:23, Christopher Delahunt wrote:
> Hi Paul,
>
> A quick scan of the test case shows it doesn't seem to be setting the collection of Many entities (mm) into the Embeddable (emb).
> Can you correct this and upload the log as well?
>
> Regards,
> Chris
>
>
> On 22/06/2011 11:53 AM, Paul Harrison wrote:
>> On 2011-06 -22, at 13:47, James Sutherland wrote:
>>
>>
>>
>>> Can you include the code you use to persist the object, and the log on finest
>>> of the transaction.
>>>
>>>
>>
>>
>> I have submitted this as a bug
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=349483
>> and included a test case as an attachment to this bug.
>>
>>
>>> Do any errors or warnings occur on startup?
>>>
>>>
>>
>> No - and note that eclipselink has no problem creating the table structure - it is just silently fails to persist the fields.
>>
>> create table Container (
>> id integer not null auto_increment,
>> simple varchar(255),
>> incnt varchar(255),
>> primary key (id)
>> );
>>
>> create table Many (
>> id integer not null auto_increment,
>> name varchar(255),
>> other integer not null,
>> CONT_IDENTIFIER integer,
>> primary key (id)
>> );
>>
>> alter table Many
>> add index FK247A7F38FF7A25 (CONT_IDENTIFIER),
>> add constraint FK247A7F38FF7A25
>> foreign key (CONT_IDENTIFIER)
>> references Container (id);
>>
>>
>>
>>> It is odd to have a OneToMany in an Embeddable as they have no id, and note
>>> that the embeddable is not mapping the ID column that is being used in the
>>> join.
>>>
>>>
>>
>> Surely the point of the embeddable is that it has the id of the object in which it is embedded - I can see nothing wrong logically with what I am trying to do - though I admit that it is a fairly advanced usage... The embeddable is not mapping the id column because it is the "many" side that is using a foreign key.
>>
>>
>>
>>
>>> If you move the OneToMany to the parent, or change it to use a JoinTable
>>> instead of a JoinColumn does it work?
>>>
>>>
>>>
>>
>> the OneToMany works fine in the parent - using a JoinTable in the embeddable does not work either.
>>
>>
>>> Paul Harrison-8 wrote:
>>>
>>>
>>>> Hi,
>>>>
>>>> I have a problem using eclipselink 2.2.0 in that none of the @OneToMany
>>>> fields are being persisted in and @Embeddable class. The partial source is
>>>> below with Container being the container class for the Emb class - The
>>>> tables are created as I would expect, but on trying to persist a Container
>>>> object none of Many objects are written to the database. Is this a bug or
>>>> am I doing something wrong?
>>>>
>>>> @Entity
>>>> public class Container implements Serializable {
>>>>
>>>> @Id
>>>> @GeneratedValue
>>>> private int id;
>>>> private String incnt;
>>>> @Embedded
>>>> private Emb em;
>>>> }
>>>>
>>>> @Embeddable
>>>> public class Emb implements Serializable {
>>>>
>>>>
>>>> protected String simple;
>>>>
>>>> @JoinColumn(name = "CONT_IDENTIFIER", referencedColumnName = "ID")
>>>> @OneToMany(cascade = PERSIST, orphanRemoval = false)
>>>> protected List<Many> lots;
>>>> }
>>>>
>>>> @Entity
>>>> public class Many implements Serializable {
>>>>
>>>> @Id
>>>> @GeneratedValue
>>>> protected int id;
>>>> protected String name;
>>>> protected int other;
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>>
>>> -----
>>>
>>> http://wiki.eclipse.org/User:James.sutherland.oracle.com
>>> James Sutherland
>>>
>>> http://www.eclipse.org/eclipselink/
>>>
>>> EclipseLink ,
>>> http://www.oracle.com/technology/products/ias/toplink/
>>>
>>> TopLink
>>> Wiki:
>>> http://wiki.eclipse.org/EclipseLink
>>> EclipseLink ,
>>>
>>> http://wiki.oracle.com/page/TopLink
>>> TopLink
>>> Forums:
>>> http://forums.oracle.com/forums/forum.jspa?forumID=48
>>> TopLink ,
>>>
>>> http://www.nabble.com/EclipseLink-f26430.html
>>> EclipseLink
>>> Book:
>>> http://en.wikibooks.org/wiki/Java_Persistence
>>> Java Persistence
>>> Blog:
>>> http://java-persistence-performance.blogspot.com/
>>> Java Persistence
>>> Performance
>>> --
>>> View this message in context:
>>> http://old.nabble.com/none-of-the-%40OneToMany-fields-are-being-persisted-in-an-%40Embeddable-class-tp31851258p31902914.html
>>>
>>> Sent from the EclipseLink - Users mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> 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