Skip to main content

Transient attributes as Primary Key for a View Object, a bad idea?

Answer is YES for certain use cases where
1. Recalculation of transient attributes are expensive and
2. If the run time needs to touch PK attribute multiple times while serving requests from a client. An example for this scenario may be expanding multiple level of tree node. Please note that in this case the value of transient attributes are getting recalculated each time. In such scenarios, better go for other option like SQL derived attributes, if feasible.

Thanks to Blaise Ribet who shared this point!

Comments

subu said…
hi jobinesh,

i had doubt. pls clear this.

i had a table in my db.

let us,

for eg : table1:
two fields id1 and desc1.

this table1 has no primary key.

i cant maintain primary key in table 1 n for anyone of the column. because the lot duplicates may sit on the table particular column id .

but adf by default takes rowid as pk. i remove that. but adf eo needed some pk it's mandatory also.

my question is simple . i can t maintain pk in table level.

so i make a transiest attribute in eo n vo and make it pk. pass some default or may some sequence value to that create method.

is it possible.?
subu said…
hi you leav out it;s bad idea.

but u may think y he is asking.

i cant alter the table. with the existing things(table) i want to work out.

i create a transiest attr in eo and also vo.

while running the application module.

oracle.jbo.PersistenceException: JBO-26028: View object ApplUsersView does not include a primary key attribute ViewAttr of entity base ApplUsers.
at oracle.jbo.server.RowReference.verifyPrimaryKeys(RowReference.java:880)
at oracle.jbo.server.RowReference.verifyReference(RowReference.java:783)
at oracle.jbo.server.ViewDefImpl.resolveRowReferences(ViewDefImpl.java:8066)
at oracle.jbo.server.ViewDefImpl.resolveAttrs(ViewDefImpl.java:7780)

y it happening. can give me explanation.
Jobinesh said…
Adding a transient attribute doesn't treat it as PK. You may need to mark it as PK or you can work around with pseudo column RowID as PK. In general a table without PK is not considered as good design
subu said…
Adding a transient attribute doesn't treat it as PK.

u misunderstud that.

i made a transient attr in my eo . and make it as pk.

and then am runnig. error throws.
infantafdo said…
HI,
I have a doubt, I am trying to create entity based view object. But query is little complicated. It has a union of 8 different queries.

Say for example, I am trying to create view object based on A, B.
A has - 5 columns,
B has - 5 columns.

I am joining these tables based on 3 columns. While creating VO, I want to select only 1 attribute from B which is not present in A entity.I am not able to do this. Is there any way to achieve this?

- Infanta
adfsanthosh said…
http://adfnote.blogspot.in/

Popular posts from this blog

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…