[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
|
Thanks Doug:
The pointer helped get me looking in the right place. I've learned a good
bit but I still haven't go it.
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?
This is where I am going wrong! I need some help doing this. Some
background first.
Using Eclipselink workbench with Eclipse 3.3 IDE, DB2Platform and jt0pen
6.1 toolkit JDBC 4.0 driver.
The project has four descriptors for four tables, two of the tables are in
one database and use generated primary keys (IDENTITYS).
The other two tables are in different databases, they are logs and do not
have any sort of key (to satisfy Eclipselink workbench I specified the
timestamp keys in these two tables as primary keys). They will be
accessed with ReadAllQuery.
After I looked at the documentation for "identity sequencing" it seems
that "native sequencing" needs to be specified at session level. Problem,
that selection is not available in the Project or Session.
Is that setting only valid for Oricle? Seems, so. After further study I
came across this page which indicates that "Native Sequencing with a
Non-Oricle Database Platform (sequence type) is only done through Java.
http://wiki.eclipse.org/Introduction_to_Relational_Projects_%28ELUG%29#Sequencing_in_Relational_Projects
After studying these sections of the documentation
http://wiki.eclipse.org/Introduction_to_Relational_Projects_%28ELUG%29#Default_Sequencing
http://wiki.eclipse.org/Configuring_a_Database_Login_%28ELUG%29#Using_the_Platform_Default_Sequence
http://wiki.eclipse.org/Configuring_a_Relational_Descriptor_%28ELUG%29#Configuring_the_Platform_Default_Sequence
I concluded that i needed to associate a noneexistent sequence
(XFRCTRL_SEQ) with the descriptor so the runtime will create a
DefaultSequence using the IDENTIFY field of the database.
session.getDescriptor(Xfrctl00.class).setSequenceNumberFieldName("XFRCTRLKEY");
// primary key field
session.getDescriptor(Xfrctl00.class).setSequenceNumberName("XFRCTRL_SEQ");
That caused session.insertObject() to throw an error.
Oh boo! What am I doing wrong here? Thanks for the pointer but I need a
little more help!
Regards
Bill Blalock
Exception:
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:87)
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)