I want to bring a new discussion about standard way of implementing PK in ADF. I always use DBSEquece for primary key but many are using another way that is: uncheck the mandatory field for the attribute with primary-key in the EO,and ADF in working with null value in pk and suprisingly it is working! Is the second method ok? I test it and it seems that it is working! if the second method is ok! so why adf has DBSequence??. In both way of course the generated pk is from Pre-Insert trigger in the Oracle. Can anybody tell me what is the cons and pros of each method?
Hi,
DBSequence pre-populates new record with negative key value. If you will
have Master-Detail, and will create records in Detail same time, this
temporary value will be assigned to Detail records. After commit, temporary
values will be refreshed with sequence value.
If you uncheck mandatory field for primary key attribute, its a bad practice
- key attribute will not be validated in ADF BC Model.
Andrejus
2009/10/7 amir hosein khanof <amir.kha...@gmail.com>
> I want to bring a new discussion about standard way of implementing PK in
> ADF.
> I always use DBSEquece for primary key but many are using another way that
> is:
> uncheck the mandatory field for the attribute with primary-key in the
> EO,and ADF in working with null value in pk and suprisingly it is working!
> Is the second method ok? I test it and it seems that it is working!
> if the second method is ok! so why adf has DBSequence??.
> In both way of course the generated pk is from Pre-Insert trigger in the
> Oracle.
> Can anybody tell me what is the cons and pros of each method?
Subject: Re: [ADF Enterprise Methodology Group] Re: which method is standard for primary-key in ADF 11g? (DBSequence or uncheck mandatory for PK in EO)
andrejus.baranovs...@gmail.com> wrote:
> Hi,
> DBSequence pre-populates new record with negative key value. If you will
> have Master-Detail, and will create records in Detail same time, this
> temporary value will be assigned to Detail records. After commit, temporary
> values will be refreshed with sequence value.
> If you uncheck mandatory field for primary key attribute, its a bad
> practice - key attribute will not be validated in ADF BC Model.
> Andrejus
> 2009/10/7 amir hosein khanof <amir.kha...@gmail.com>
> Dear All,
>> I want to bring a new discussion about standard way of implementing PK in
>> ADF.
>> I always use DBSEquece for primary key but many are using another way that
>> is:
>> uncheck the mandatory field for the attribute with primary-key in the
>> EO,and ADF in working with null value in pk and suprisingly it is working!
>> Is the second method ok? I test it and it seems that it is working!
>> if the second method is ok! so why adf has DBSequence??.
>> In both way of course the generated pk is from Pre-Insert trigger in the
>> Oracle.
>> Can anybody tell me what is the cons and pros of each method?
Subject: Re: [ADF Enterprise Methodology Group] Re: which method is standard for primary-key in ADF 11g? (DBSequence or uncheck mandatory for PK in EO)
Hi Amir,
That right - it works. But if you remove Mandatory option, action will
propogate to DB level and only DB will return error about missing primary
key value (in a case if someone will try to commit empty key). So, its bad
design, this should be catched in Model layer.
There is another alternative to DBSequence - you can access DB sequence in
overriden Entity create (method). You can assign negative sequence there and
on actual commit in doDML change it to real positive sequence. There is no
need in DB triggers then. But, I would recommend to use DBSequence - its
especially good in Master-Detail CRUD.
Andrejus
2009/10/7 amir hosein khanof <amir.kha...@gmail.com>
> Thanks for your reply, in the second way is there any case that does not
> fit or result in error?
> As I have tested in all cases it is ok.
> Thanks
> Amir
> On Wed, Oct 7, 2009 at 2:20 PM, Andrejus Baranovskis <
> andrejus.baranovs...@gmail.com> wrote:
>> Hi,
>> DBSequence pre-populates new record with negative key value. If you will
>> have Master-Detail, and will create records in Detail same time, this
>> temporary value will be assigned to Detail records. After commit, temporary
>> values will be refreshed with sequence value.
>> If you uncheck mandatory field for primary key attribute, its a bad
>> practice - key attribute will not be validated in ADF BC Model.
>> Andrejus
>> 2009/10/7 amir hosein khanof <amir.kha...@gmail.com>
>> Dear All,
>>> I want to bring a new discussion about standard way of implementing PK in
>>> ADF.
>>> I always use DBSEquece for primary key but many are using another way
>>> that is:
>>> uncheck the mandatory field for the attribute with primary-key in the
>>> EO,and ADF in working with null value in pk and suprisingly it is working!
>>> Is the second method ok? I test it and it seems that it is working!
>>> if the second method is ok! so why adf has DBSequence??.
>>> In both way of course the generated pk is from Pre-Insert trigger in the
>>> Oracle.
>>> Can anybody tell me what is the cons and pros of each method?
If you have null PK value on Entity you will have problems.
Try the following
have a Master-detail view objects
Create 2 rows on master and dont post (use optimistic locking)
navigate to 1 row and create a detail row
You will have problem for sure since the detail cannot distinguish to
which master it belongs.
I also dont like DBSequence since it works only for Oracle Database
(SQL server dont have sequence)
I prefer to use a method in the base view object class to populate the
primary key either from DBSequence for oracle or other objects for
other databases/
On 7 Οκτ, 14:22, amir hosein khanof <amir.kha...@gmail.com> wrote:
> Thanks for your reply, in the second way is there any case that does not fit
> or result in error?
> As I have tested in all cases it is ok.
> Thanks
> Amir
> On Wed, Oct 7, 2009 at 2:20 PM, Andrejus Baranovskis <
> andrejus.baranovs...@gmail.com> wrote:
> > Hi,
> > DBSequence pre-populates new record with negative key value. If you will
> > have Master-Detail, and will create records in Detail same time, this
> > temporary value will be assigned to Detail records. After commit, temporary
> > values will be refreshed with sequence value.
> > If you uncheck mandatory field for primary key attribute, its a bad
> > practice - key attribute will not be validated in ADF BC Model.
> > Andrejus
> > 2009/10/7 amir hosein khanof <amir.kha...@gmail.com>
> > Dear All,
> >> I want to bring a new discussion about standard way of implementing PK in
> >> ADF.
> >> I always use DBSEquece for primary key but many are using another way that
> >> is:
> >> uncheck the mandatory field for the attribute with primary-key in the
> >> EO,and ADF in working with null value in pk and suprisingly it is working!
> >> Is the second method ok? I test it and it seems that it is working!
> >> if the second method is ok! so why adf has DBSequence??.
> >> In both way of course the generated pk is from Pre-Insert trigger in the
> >> Oracle.
> >> Can anybody tell me what is the cons and pros of each method?
Shouldn't the logic be in the entity object rather than the view
object though? That would be the logical place from an abstraction
perspective (and why there is the DBsequence option in the EO
settings) IMO. I don't know about other databases though.
Simon
On Oct 7, 5:39 pm, Michael Koniotiakis <mko...@hotmail.com> wrote:
> I prefer to use a method in the base view object class to populate the
> primary key either from DBSequence for oracle or other objects for
> other databases/
Just to be specific here, the issue isn't that DBSequence requires
such a thing as a database sequence (it doesn't; nowhere in the code
does it check to make sure a Sequence exists, and the Sequence
metadata you can enter is only for forward-generation; it's not used
by the runtime) but rather that standard SQL doesn't have a RETURNING
clause for DML, and that ADF BC therefore doesn't support *any*
Refresh After... settings for non-Oracle DBs.
In some deep sense, the "right" place to override this is in a
SQLBuilder implementation, specifically
SQLBuilder.supportsReturningClause(), SQLBuilder.buildInsertStatement
(), SQLBuilder.bindInsertStatement(), and
SQLBuilder.doLoadFromStatement(). That would let you support arbitrary
refresh on insert attributes.
On Oct 7, 9:39 am, Michael Koniotiakis <mko...@hotmail.com> wrote:
> If you have null PK value on Entity you will have problems.
> Try the following
> have a Master-detail view objects
> Create 2 rows on master and dont post (use optimistic locking)
> navigate to 1 row and create a detail row
> You will have problem for sure since the detail cannot distinguish to
> which master it belongs.
> I also dont like DBSequence since it works only for Oracle Database
> (SQL server dont have sequence)
> I prefer to use a method in the base view object class to populate the
> primary key either from DBSequence for oracle or other objects for
> other databases/
> On 7 Οκτ, 14:22, amir hosein khanof <amir.kha...@gmail.com> wrote:
> > Dear Andrejus,
> > Thanks for your reply, in the second way is there any case that does not fit
> > or result in error?
> > As I have tested in all cases it is ok.
> > Thanks
> > Amir
> > On Wed, Oct 7, 2009 at 2:20 PM, Andrejus Baranovskis <
> > andrejus.baranovs...@gmail.com> wrote:
> > > Hi,
> > > DBSequence pre-populates new record with negative key value. If you will
> > > have Master-Detail, and will create records in Detail same time, this
> > > temporary value will be assigned to Detail records. After commit, temporary
> > > values will be refreshed with sequence value.
> > > If you uncheck mandatory field for primary key attribute, its a bad
> > > practice - key attribute will not be validated in ADF BC Model.
> > > Andrejus
> > > 2009/10/7 amir hosein khanof <amir.kha...@gmail.com>
> > > Dear All,
> > >> I want to bring a new discussion about standard way of implementing PK in
> > >> ADF.
> > >> I always use DBSEquece for primary key but many are using another way that
> > >> is:
> > >> uncheck the mandatory field for the attribute with primary-key in the
> > >> EO,and ADF in working with null value in pk and suprisingly it is working!
> > >> Is the second method ok? I test it and it seems that it is working!
> > >> if the second method is ok! so why adf has DBSequence??.
> > >> In both way of course the generated pk is from Pre-Insert trigger in the
> > >> Oracle.
> > >> Can anybody tell me what is the cons and pros of each method?
> Shouldn't the logic be in the entity object rather than the view
> object though? That would be the logical place from an abstraction
> perspective (and why there is the DBsequence option in the EO
> settings) IMO. I don't know about other databases though.
> Simon
> On Oct 7, 5:39 pm, Michael Koniotiakis <mko...@hotmail.com> wrote:
> > I prefer to use a method in the base view object class to populate the
> > primary key either from DBSequence for oracle or other objects for
> > other databases/- Απόκρυψη κειμένου σε παράθεση -