openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ioan Domsa <domsai...@gmail.com>
Subject Sequencer
Date Wed, 08 Nov 2017 22:20:33 GMT
Hello,

I am using OPENJPA 2.4.2  (in Eclipse RCP) with Postgresql 10and I have the
following entity:
*@Entity*
*@Table(name = "bom")*
*@Access(AccessType.FIELD)*
*public class Bom {*

* @Id*
* @SequenceGenerator(name = "testing", sequenceName = "test1",
allocationSize = 1)*
* @GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"testing")*
* private long id;*

*//getter,//setter*

When I create a new entity and
*em.getTransaction().begin();*
*em.persist(main);*
*em.flush();*

I get
the InvalidStateException(_loc2.get("existing-value-override-excep",..)
from Util.ApplicationIds, because the line
 *  if (!sm.isDefaultValue(pks[i].getIndex()))*
does not check if the value which is not the default one is the one
generated using the sequencer.
This happens because it passes 2 times in the same code when em.Flush() is
called. Once it gets the generated value using the sequencer and assigns it
here
*  // Assign the generated value*
*                if (store.assignField(sm, pks[i].getIndex(), preFlush))*
*                    pks[i].setValueGenerated(true); *
then it comes the second time through* private static boolean
assign(OpenJPAStateManager sm, StoreManager store,*
*        FieldMetaData[] pks, boolean preFlush) *and rechecks if it is a
default value.

Is this a bug ? Or am I missing something ?

Best regards,
Ioan

Ioan Domsa

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message