Skip to main content



      Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [TEXO] Generated code for lists
[TEXO] Generated code for lists [message #721647] Fri, 02 September 2011 08:28 Go to next message
Eclipse UserFriend
I have a problem with the code generated for lists:

    /**
     * Adds to the <em>positionen</em> feature.
     * 
     * @generated
     */
    public void addToPositionen(DossierPosition value) {
        if (!positionen.contains(value)) {
            positionen.add(value);
            value.setDossierTeil(this);
        }
    }


My domain objects (like DossierPosition) have an id property storing the database primary key and are considered equal when they have the same ids.

When adding new objects with uninitialized (i.e. 0) ids to the collection, only the first object gets inserted.

What's the best way to solve the problem? I would like to keep id generation in the database.

Thanks,
Peter
Re: [TEXO] Generated code for lists [message #721661 is a reply to message #721647] Fri, 02 September 2011 08:56 Go to previous messageGo to next message
Eclipse UserFriend
I probably should not implement equals/hashcode to be based on the id property. Exactly because of this problem. Aparently JPA doesn't require that equals is compatible with the database ids.
Re: [TEXO] Generated code for lists [message #721670 is a reply to message #721661] Fri, 02 September 2011 09:34 Go to previous message
Eclipse UserFriend
Hi Peter,
Yes, or change your equals a bit, so that if the id is not set that you compare on the object instance itself.

Btw, I think in Texo I should make use of the unique property of the estructuralfeature. If it is false then it should
allow duplicates and not do this .contains check. I will see if I can change that on the short term.

gr. Martin

On 09/02/2011 02:56 PM, Peter Kullmann wrote:
> I probably should not implement equals/hashcode to be based on the id property. Exactly because of this problem.
> Aparently JPA doesn't require that equals is compatible with the database ids.


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:[EMFClient] Disable creation of specific child in navigator & editor
Next Topic:I am trying to use EMF/teneo to persist my instance and I get this error
Goto Forum:
  


Current Time: Fri Jul 04 23:36:30 EDT 2025

Powered by FUDForum. Page generated in 0.09185 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top