[TEXO] Generated code for lists [message #721647] |
Fri, 02 September 2011 08:28  |
Eclipse User |
|
|
|
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 #721670 is a reply to message #721661] |
Fri, 02 September 2011 09:34  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.09185 seconds