jakkamma wrote:
I am just wondering how are people doing it and how is the Database specific Adapter doing it.
Most people don't use triggers for this, however sometimes people have to work with a legacy database which has triggers in place. (or are forced to use them through corporate policies, like your situation)
Thanx and I will appreciate you posting without fail.
Just a request as I started using 2-3 ORMappers for this projects and failing in every instance.
I'll add a .config setting to the upcoming 1.0.2004.2 version, which allows you to signal the Oracle DQE what kind of sequence queries to execute. This was first scheduled to be a gui setting, but that was postponed, though a .config setting is easily added.
If you open the sourcecode of the Oracle DQE's DynamicQueryEngine.cs, and look in the CreateInsertDQ routine you'll see:
// line 184
if(persistenceInfo.IsIdentity)
{
insertQuery.AddParameterFieldRelation(new ParameterFieldRelation(field, newParameter));
// create SequenceRetrievalQuery
ISequenceRetrievalQuery sequenceQuery = new SequenceRetrievalQuery();
sequenceQuery.SequenceRetrievalCommand = CreateCommand();
sequenceQuery.SequenceRetrievalCommand.Connection = connectionToUse;
sequenceQuery.ExecuteSequenceCommandFirst = true;
sequenceQuery.SequenceRetrievalCommand.CommandText = String.Format("SELECT {0}.NEXTVAL FROM DUAL", persistenceInfo.IdentityValueSequenceName);
sequenceQuery.SequenceParameters.Add(newParameter);
insertQuery.SequenceRetrievalQueries.Add(sequenceQuery);
}
This creates for every sequenced field a sequence query and sets its flag to execute it before the actual query. You should change this code into
if(persistenceInfo.IsIdentity)
{
insertQuery.AddParameterFieldRelation(new ParameterFieldRelation(field, newParameter));
// create SequenceRetrievalQuery
ISequenceRetrievalQuery sequenceQuery = new SequenceRetrievalQuery();
sequenceQuery.SequenceRetrievalCommand = CreateCommand();
sequenceQuery.SequenceRetrievalCommand.Connection = connectionToUse;
sequenceQuery.ExecuteSequenceCommandFirst = false;
sequenceQuery.SequenceRetrievalCommand.CommandText = String.Format("SELECT {0}.CURRVAL FROM DUAL", persistenceInfo.IdentityValueSequenceName);
sequenceQuery.SequenceParameters.Add(newParameter);
insertQuery.SequenceRetrievalQueries.Add(sequenceQuery);
}
Change the assemblyinfo.cs files (there are 2) so that the strong key isn't referenced and build the source with the makefile (first execute vsvars32.bat):
nmake /nologo /f makefile_11 clean
nmake /nologo /f makefile_11
The .cmd file builds all 3 versions so you probably don't want that