[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.rt.eclipselink] Re: Database generated primary key - problems with insert

Doug Clarke wrote:

Bill,

The database platform dictates how primary key sequencing is performed. If the platform supports identity sequencing where the value is generated by the database then the PK value will not be included in the INSERT statement but will be read back into the application after the INSERT.

The DB2 platform does support identity sequencing and the value is read back in using "SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1", as defined in DB2Platform.buildSelectQueryForIdentity().

How are you configuring your entity to have identity sequencing used?

Doug

Doug:

I tried this to configure the identity sequence:

session.getLogin().addSequence(new TableSequence("XFRCTRL_SEQ"));
session.getDescriptor(Xfrctl00.class).setSequenceNumberFieldName("XFRCTRLKEY"); // primary key field
session.getDescriptor(Xfrctl00.class).setSequenceNumberName("XFRCTRL_SEQ");


(see http://wiki.eclipse.org/Configuring_a_Relational_Descriptor_%28ELUG%29#Configuring_a_Sequence_by_Name )

Failed again.  Drat.

the error is at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.insertObject(DatasourceCallQueryMechanism.java:300)

I ran it under debug and the problem is the DatabaseSessionImpl class is returning a SequenceManger whose getSequenceing() method is returning null.

Looks like I still haven't got the sequence set up right.

Any thoughts???

Thanks
Bill Blalock


java.lang.NullPointerException
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.insertObject(DatasourceCallQueryMechanism.java:300)
at org.eclipse.persistence.internal.queries.StatementQueryMechanism.insertObject(StatementQueryMechanism.java:163)
at org.eclipse.persistence.internal.queries.StatementQueryMechanism.insertObject(StatementQueryMechanism.java:178)
at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.insertObjectForWrite(DatabaseQueryMechanism.java:465)
at org.eclipse.persistence.queries.InsertObjectQuery.executeCommit(InsertObjectQuery.java:80)
at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.executeWrite(DatabaseQueryMechanism.java:243)
at org.eclipse.persistence.queries.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:60)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:666)
at org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:2207)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1178)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1162)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1108)
at org.eclipse.persistence.internal.sessions.AbstractSession.insertObject(AbstractSession.java:2196)
at eclipselinkrcp1.Application.start(Application.java:90)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
at org.eclipse.equinox.launcher.Main.main(Main.java:1148)