Creation of Index for Primary & Foreign Key required?
hi,
i would like to find out if a column is defined as the primary key, do i need to create a separate index for it? or defining a primary key will tell the db to automatically create an index for it?
does foreign key have the same behavior as the primary key constraint?
thanks!
i would like to find out if a column is defined as the primary key, do i need to create a separate index for it? No
or defining a primary key will tell the db to automatically create an index for it? Yes
See
http://download-uk.oracle.com/docs/cd/B10501_01/appdev.920/a96590/adg05itg.htm#7265
does foreign key have the same behavior as the primary key constraint?No. See http://download-uk.oracle.com/docs/cd/B10501_01/appdev.920/a96590/adg05itg.htm#1574
Similar Messages
-
Query Builder recognizing primary/foreign key
Is there a way to have Query Builder recogninze the primary/foreign keys of the tables when they are selected? Right now it looks like you have to manually join the tables together by selected the column(s) to join.
ThanksYou can define a query key[1] 'planId' on InvestmentOption for the PLAN_OID column. That'll let you write an expression like the one below which does not produce a join. The nice part about the query key is that it does not require you to add attributes to your object in order to query o them.
Expression plan = new ExpressionBuilder();
Expression where = plan.get("planId").equal(somePlanId);--Shaun
[1] http://www.oracle.com/technology/products/ias/toplink/doc/10131/main/_html/descfg010.htm#sthref3039 -
Missing primary foreign key in grandchild table
I have a model with a two inheritance generations.
https://www.dropbox.com/s/4rghqcmxx24bgvt/pf_logical.png
When I engineer all entities everything is fine. The child tables get their primary foreign keys:
https://www.dropbox.com/s/t4v5bexxwdrn5y1/pf_engineered.png
But when I do not engineer the child generation the grandchildren have no primary foreign keys anymore.
https://www.dropbox.com/s/ofl436sm8dua3w8/pf_missing.png
I have expected, that the grandchildren get a primary foreign key to the grandfather. But that is not the case. How can I tell the modeler to engineer such a foreign key?Hi,
thanks for reporting the problem. I logged a bug for that.
Philip -
Normal Indexes created for Primary/Unique Keys in Oracle8/8i
I remeber prior to Oracle8, when we create a Primary/Unique Key constraints, an unique index will be created by default. But I am noticing now in 8/8i when we create either Primary or Unique key, only normal/simple index is created. We are not able to override this normal index either by dropping and recreating the index alone. I believe it would be pretty much better in case of performance if we have a unique index for this columns. Can anybody help why is it changed so in 8/8i??
Thanks,
R. M.Dear Rob,
since your answer was helpful and since it was the only one I will grant you full points on that.
Thanks again for your input. In case other developers should look this thread up being confronted
with the same kind of problem, here is how we solved it:
We added an artificial primary key (a number of type NUMC 8) to the table which is supposed to
include the structure. This key alone takes care of the uniqueness of eacht entry.
All the others fields that we want to have available for a fast direct access, including the ones
from the included structure, are put together in a secondary index.
best regards
Andreas -
Detect the fields which are primary/foreign keys for each schema's tables
Hello everybody,
I'd like to know if it's possible to select a field in one of the dictionary tables to identify the fields of a table which are PK or FK in this one. I'd like to do this to generate the fields that I need to put in a technical design.
Actually I have this (if it can help you to understand what I'd like to do) :
select table_name "Table name",
column_name "Physical field name",
case when data_type = 'NUMBER' then data_type || '(' || NVL(data_precision,0) || ',' || NVL(data_scale,0) || ')'
when data_type = 'VARCHAR2' then data_type || '(' || data_length || ')'
else data_type
end "Datatype",
case when nullable = 'Y' then 'FALSE'
when nullable = 'N' then 'TRUE'
end "Not null",
/* Here I'd like to retrieve TRUE or FALSE if the field to display is a primary key or not and the same for foreign keys*/
from all_tab_columns
where table_name in (select table_name
from all_tables
where table_name like '%project_name%'
and table_name not like '%TMP%');
Thanks a lot for your help,
FlorentPlease investigate all_constraints and all_cons_colums.
http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14237/toc.htm -
Caching problem w/ primary-foreign key mapping
I have seen this a couple of times now. It is not consistent enough to
create a simple reproducible test case, so I will have to describe it to you
with an example and hope you can track it down. It only occurs when caching
is enabled.
Here are the classes:
class C1 { int id; C2 c2; }
class C2 { int id; C1 c1; }
Each class uses application identity using static nested Id classes: C1.Id
and C2.Id. What is unusual is that the same value is used for both
instances:
int id = nextId();
C1 c1 = new C1(id);
C2 c2 = new C2(id);
c1.c2 = c2;
c2.c1 = c1;
This all works fine using optimistic transactions with caching disabled.
Although the integer values are the same, the oids are unique because each
class defines its own unique oid class.
Here is the schema and mapping (this works with caching disabled but fails
with caching enabled):
table t1: column id integer, column revision integer, primary key (id)
table t2: column id integer, column revision integer, primary key (id)
<jdo>
<package name="test">
<class name="C1" objectid-class="C1$Id">
<extension vendor-name="kodo" key="jdbc-class-map" value="base">
<extension vendor-name="kodo" key="table" value="t1"/>
</extension>
<extension vendor-name="kodo" key="jdbc-version-ind"
value="version-number">
<extension vendor-name="kodo" key="column" value="revision"/>
</extension>
<field name="id" primary-key="true">
<extension vendor-name="kodo" key="jdbc-field-map" value="value">
<extension vendor-name="kodo" key="column" value="id"/>
</extension>
</field>
<field name="c2">
<extension vendor-name="kodo" key="jdbc-field-map" value="one-one">
<extension vendor-name="kodo" key="column.id" value="id"/>
</extension>
</field>
</class>
<class name="C2" objectid-class="C2$Id">
<extension vendor-name="kodo" key="jdbc-class-map" value="base">
<extension vendor-name="kodo" key="table" value="t2"/>
</extension>
<extension vendor-name="kodo" key="jdbc-version-ind"
value="version-number">
<extension vendor-name="kodo" key="column" value="revision"/>
</extension>
<field name="id" primary-key="true">
<extension vendor-name="kodo" key="jdbc-field-map" value="value">
<extension vendor-name="kodo" key="column" value="id"/>
</extension>
</field>
<field name="c1">
<extension vendor-name="kodo" key="dependent" value="true"/>
<extension vendor-name="kodo" key="inverse-owner" value="c2"/>
<extension vendor-name="kodo" key="jdbc-field-map" value="one-one">
<extension vendor-name="kodo" key="table" value="t1"/>
<extension vendor-name="kodo" key="ref-column.id" value="id"/>
<extension vendor-name="kodo" key="column.id" value="id"/>
</extension>
</field>
</class>
</package>
</jdo>
Because the ids are known to be the same, the primary key values are also
used as foreign key values. Accessing C2.c1 is always non-null when caching
is disabled. With caching is enabled C2.c1 is usually non-null but sometimes
null. When it is null we get warnings about dangling references to deleted
instances with id values of 0 and other similar warnings.
The workaround is to add a redundant column with the same value. For some
reason this works around the caching problem (this is unnecessary with
caching disabled):
table t1: column id integer, column id2 integer, column revision integer,
primary key (id), unique index (id2)
table t2: column id integer, column revision integer, primary key (id)
<jdo>
<package name="test">
<class name="C1" objectid-class="C1$Id">
<extension vendor-name="kodo" key="jdbc-class-map" value="base">
<extension vendor-name="kodo" key="table" value="t1"/>
</extension>
<extension vendor-name="kodo" key="jdbc-version-ind"
value="version-number">
<extension vendor-name="kodo" key="column" value="revision"/>
</extension>
<field name="id" primary-key="true">
<extension vendor-name="kodo" key="jdbc-field-map" value="value">
<extension vendor-name="kodo" key="column" value="id"/>
</extension>
</field>
<field name="c2">
<extension vendor-name="kodo" key="jdbc-field-map" value="one-one">
<extension vendor-name="kodo" key="column.id" value="id2"/>
</extension>
</field>
</class>
<class name="C2" objectid-class="C2$Id">
<extension vendor-name="kodo" key="jdbc-class-map" value="base">
<extension vendor-name="kodo" key="table" value="t2"/>
</extension>
<extension vendor-name="kodo" key="jdbc-version-ind"
value="version-number">
<extension vendor-name="kodo" key="column" value="revision"/>
</extension>
<field name="id" primary-key="true">
<extension vendor-name="kodo" key="jdbc-field-map" value="value">
<extension vendor-name="kodo" key="column" value="id"/>
</extension>
</field>
<field name="c1">
<extension vendor-name="kodo" key="dependent" value="true"/>
<extension vendor-name="kodo" key="inverse-owner" value="c2"/>
<extension vendor-name="kodo" key="jdbc-field-map" value="one-one">
<extension vendor-name="kodo" key="table" value="t1"/>
<extension vendor-name="kodo" key="ref-column.id" value="id2"/>
<extension vendor-name="kodo" key="column.id" value="id"/>
</extension>
</field>
</class>
</package>
</jdo>
Needless to say, the extra column adds a lot of overhead, including the
addition of a second unique index, for no value other than working around
the caching defect.Tom-
The first thing that I think of whenever I see a problem like this is
that the equals() and hashCode() methods of your application identity
classes are not correct. Can you check them to ensure that they are
written in accordance to the guidelines at:
http://docs.solarmetric.com/manual.html#jdo_overview_pc_identity_application
If that doesn't help address the problem, can you post the code for your
application identity classes so we can double-check, and we will try to
determine what might be causing the problem.
In article <[email protected]>, Tom Landon wrote:
I have seen this a couple of times now. It is not consistent enough to
create a simple reproducible test case, so I will have to describe it to you
with an example and hope you can track it down. It only occurs when caching
is enabled.
Here are the classes:
class C1 { int id; C2 c2; }
class C2 { int id; C1 c1; }
Each class uses application identity using static nested Id classes: C1.Id
and C2.Id. What is unusual is that the same value is used for both
instances:
int id = nextId();
C1 c1 = new C1(id);
C2 c2 = new C2(id);
c1.c2 = c2;
c2.c1 = c1;
This all works fine using optimistic transactions with caching disabled.
Although the integer values are the same, the oids are unique because each
class defines its own unique oid class.
Here is the schema and mapping (this works with caching disabled but fails
with caching enabled):
table t1: column id integer, column revision integer, primary key (id)
table t2: column id integer, column revision integer, primary key (id)
<jdo>
<package name="test">
<class name="C1" objectid-class="C1$Id">
<extension vendor-name="kodo" key="jdbc-class-map" value="base">
<extension vendor-name="kodo" key="table" value="t1"/>
</extension>
<extension vendor-name="kodo" key="jdbc-version-ind"
value="version-number">
<extension vendor-name="kodo" key="column" value="revision"/>
</extension>
<field name="id" primary-key="true">
<extension vendor-name="kodo" key="jdbc-field-map" value="value">
<extension vendor-name="kodo" key="column" value="id"/>
</extension>
</field>
<field name="c2">
<extension vendor-name="kodo" key="jdbc-field-map" value="one-one">
<extension vendor-name="kodo" key="column.id" value="id"/>
</extension>
</field>
</class>
<class name="C2" objectid-class="C2$Id">
<extension vendor-name="kodo" key="jdbc-class-map" value="base">
<extension vendor-name="kodo" key="table" value="t2"/>
</extension>
<extension vendor-name="kodo" key="jdbc-version-ind"
value="version-number">
<extension vendor-name="kodo" key="column" value="revision"/>
</extension>
<field name="id" primary-key="true">
<extension vendor-name="kodo" key="jdbc-field-map" value="value">
<extension vendor-name="kodo" key="column" value="id"/>
</extension>
</field>
<field name="c1">
<extension vendor-name="kodo" key="dependent" value="true"/>
<extension vendor-name="kodo" key="inverse-owner" value="c2"/>
<extension vendor-name="kodo" key="jdbc-field-map" value="one-one">
<extension vendor-name="kodo" key="table" value="t1"/>
<extension vendor-name="kodo" key="ref-column.id" value="id"/>
<extension vendor-name="kodo" key="column.id" value="id"/>
</extension>
</field>
</class>
</package>
</jdo>
Because the ids are known to be the same, the primary key values are also
used as foreign key values. Accessing C2.c1 is always non-null when caching
is disabled. With caching is enabled C2.c1 is usually non-null but sometimes
null. When it is null we get warnings about dangling references to deleted
instances with id values of 0 and other similar warnings.
The workaround is to add a redundant column with the same value. For some
reason this works around the caching problem (this is unnecessary with
caching disabled):
table t1: column id integer, column id2 integer, column revision integer,
primary key (id), unique index (id2)
table t2: column id integer, column revision integer, primary key (id)
<jdo>
<package name="test">
<class name="C1" objectid-class="C1$Id">
<extension vendor-name="kodo" key="jdbc-class-map" value="base">
<extension vendor-name="kodo" key="table" value="t1"/>
</extension>
<extension vendor-name="kodo" key="jdbc-version-ind"
value="version-number">
<extension vendor-name="kodo" key="column" value="revision"/>
</extension>
<field name="id" primary-key="true">
<extension vendor-name="kodo" key="jdbc-field-map" value="value">
<extension vendor-name="kodo" key="column" value="id"/>
</extension>
</field>
<field name="c2">
<extension vendor-name="kodo" key="jdbc-field-map" value="one-one">
<extension vendor-name="kodo" key="column.id" value="id2"/>
</extension>
</field>
</class>
<class name="C2" objectid-class="C2$Id">
<extension vendor-name="kodo" key="jdbc-class-map" value="base">
<extension vendor-name="kodo" key="table" value="t2"/>
</extension>
<extension vendor-name="kodo" key="jdbc-version-ind"
value="version-number">
<extension vendor-name="kodo" key="column" value="revision"/>
</extension>
<field name="id" primary-key="true">
<extension vendor-name="kodo" key="jdbc-field-map" value="value">
<extension vendor-name="kodo" key="column" value="id"/>
</extension>
</field>
<field name="c1">
<extension vendor-name="kodo" key="dependent" value="true"/>
<extension vendor-name="kodo" key="inverse-owner" value="c2"/>
<extension vendor-name="kodo" key="jdbc-field-map" value="one-one">
<extension vendor-name="kodo" key="table" value="t1"/>
<extension vendor-name="kodo" key="ref-column.id" value="id2"/>
<extension vendor-name="kodo" key="column.id" value="id"/>
</extension>
</field>
</class>
</package>
</jdo>
Needless to say, the extra column adds a lot of overhead, including the
addition of a second unique index, for no value other than working around
the caching defect.
Marc Prud'hommeaux [email protected]
SolarMetric Inc. http://www.solarmetric.com -
Syntax for creating foreign key across users in a database
There are two user present A,B.They are granted all privileges.Now in USER A, there is a table PARENT whose primary key is PARENT_NO.In USER B I have created a table CHILD whose primary key is CHILD_NO.
In the CHILD table of USER B, I want to create a foreign key relation to the PARENT table of USER A.For this I have created a column CHILD_PARENT_NO in the CHILD table.If anybody knows the syntax please post the syntax for creating the required foreign key relationship?Please post your code. Cut'n'paste from SQL*Plus like this...
SQL> conn a/a
Connected.
SQL> desc t1
Name Null? Type
COL1 NUMBER
COL2 VARCHAR2(10)
SQL> grant references on t1 to b;
Grant succeeded.
SQL> conn b/b
SQL> create synonym a_t for a.t1;
Synonym created.
SQL> alter table test add constraint fk foreign key (n) references a_t(col1);
Table altered.
SQL> Note that Oracle will translate the synonym anyway...
SQL> select constraint_name, r_owner, r_constraint_name
2 from user_constraints
3 where table_name = 'TEST'
4 /
CONSTRAINT_NAME R_OWNER R_CONSTRAINT_NAME
FK A T1_PK
SQL> By the way, this ...
GRANT ALL PRIVILEGES TO B;... is a mindbendingly unsafe way of proceeding. In real life you would have given user B the power to utterly destroy your database. It's always easier to start with good habits than to break bad ones so please get used to granting only the minimum set of privileges necessary.
Cheers, APC -
hi
oracle 10.2.0.1.0
when there is foreign key then there should be corresponding column with either primary key / unique key constraint. Why is this rule aprt from normalization rules to make one Relational-DB
please help
like sample
customer table - customer id.
Account table - account id , customer id .
Address table - Adress id , address line1.for sake of unique identification of an unique tuple ? is it all to sum up ?
Edited by: 804282 on Feb 27, 2011 9:41 PM804282 wrote:
hi
oracle 10.2.0.1.0
when there is foreign key then there should be corresponding column with either primary key / unique key constraint. Why is this rule aprt from normalization rules to make one Relational-DB
please help
like sample
customer table - customer id.
Account table - account id , customer id .
Address table - Adress id , address line1.for sake of unique identification of an unique tuple ? is it all to sum up ?
Edited by: 804282 on Feb 27, 2011 9:41 PMAlso to improve query performance. You usually want to put indexes on join columns. -
ODI not able to detect primary/foreign keys from XML- user lacks privilege or object not found
Hi Guys,
Im trying to load an xml file with two entities address and employee as below. The topology reverse engineering everything works fine. Im even able to view the xml data in ODI, but when i try to load the data from these two entities joining by the schema primary keys and foreign keys which odi created on reverse engineering process for xml, im getting the below error. Im able to load data from one entity, error only occurs when i use the join odi creates internally to identify the xml components employee and address
XML File:
<?xml version="1.0" encoding="UTF-8" ?>
<EMP>
<Empsch>
<Employee>
<EmployeeID>12345</EmployeeID>
<Initials>t</Initials>
<LastName>john</LastName>
<FirstName>doe</FirstName>
</Employee>
<Address>
<WorkPhone>12345</WorkPhone>
<WorkAddress>Test 234</WorkAddress>
</Address>
</Empsch>
</EMP>
Topology: jdbc:snps:xml?f=C:/Temp/RR/Empsch.xml&s=Empsch&re=EMP&dod=true&nobu=false
Error Message:
-5501 : 42501 : java.sql.SQLException: user lacks privilege or object not found: EMPSCH.EMPSCHPK
java.sql.SQLException: user lacks privilege or object not found: EMPSCH.EMPSCHPK
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source)
at com.sunopsis.jdbc.driver.xml.SnpsXmlConnection.prepareStatement(SnpsXmlConnection.java:1232)
at sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at oracle.odi.core.datasource.dwgobject.support.OnConnectOnDisconnectDataSourceAdapter$OnDisconnectCommandExecutionHandler.invoke(OnConnectOnDisconnectDataSourceAdapter.java:200)
at $Proxy2.prepareStatement(Unknown Source)
at oracle.odi.runtime.agent.execution.sql.SQLCommand.doInitializeStatement(SQLCommand.java:83)
at oracle.odi.runtime.agent.execution.sql.SQLCommand.getStatement(SQLCommand.java:117)
at oracle.odi.runtime.agent.execution.sql.SQLCommand.getStatement(SQLCommand.java:111)
at oracle.odi.runtime.agent.execution.sql.SQLDataProvider.readData(SQLDataProvider.java:81)
at oracle.odi.runtime.agent.execution.sql.SQLDataProvider.readData(SQLDataProvider.java:1)
at oracle.odi.runtime.agent.execution.DataMovementTaskExecutionHandler.handleTask(DataMovementTaskExecutionHandler.java:70)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2913)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2625)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:577)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:468)
at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:2128)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:366)
at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:216)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:300)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:292)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:855)
at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:126)
at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:82)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: EMPSCH.EMPSCHPK
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.ExpressionColumn.checkColumnsResolved(Unknown Source)
at org.hsqldb.QueryExpression.resolve(Unknown Source)
at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatement(Unknown Source)
at org.hsqldb.Session.compileStatement(Unknown Source)
at org.hsqldb.StatementManager.compile(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 27 more
Please advice
Thanks
RevanthThats obvious from the xml file contents you have given here. In this xml file You have four complex type. Two of them are employee and address. However the employee doesnot have any relation with address as you have not added the relationship. Thats why its failing. Its not the fault of ODI.
Also I would suggest not to use auto generated dtd by ODI as you might face problem in future. For example the address type of XML has 8 attributes and 4 of them are not mandatory. That means each of your xml file may have attributes between 4 to 8. This is where ODI auto generated DTD fails.
XML Schema complexType Element
Thanks
Bhabani -
Primary&foreign key rerlation ship
hi folks,
i am going to pick material in mm03 transaction after that i selected classification tab choose batches for class type it displays values and clisifications
now i want to find tables which is having the relation ship (primary key and foreign key)between material number and class type
so could plz clarify my doubt
regards,
sreeHi
Check table DD05S.
Award points if found useful.
Regards
Inder -
How to insert value for composed foreign key?
My problem when I update or insert to table Ffclient which has link 1-1 with other table ClientLoan by composes primary key loanId and clienId (break table). I auto mapping by Jdeveloper 10g version 10.1.2. In FfClient table has two fields compose foreign key of ClientLoan as loanId and clienId not nullable. In toplink object Ffclient it only has one reference ClientLoan object by clientLoan field, not has two fields loanId and clienId . When I insert or update to database, I can't set value for these two fields direct so I have created new ClientLoan object and set value for composed primary key loanId and clienId, after that set it to object Ffclient. But when I update or insert to database it occurs exception about insert null for two not nullable fields: loanId and clienId.
Any one has error as mime? Any one help me correct my error.
Thanks in advance.
Mapping is:
â¦.
<database-mapping>
<attribute-name>ffclientCollection</attribute-name>
<read-only>false</read-only>
<get-method-name>getFfclientCollection</get-method-name>
<set-method-name>setFfclientCollection</set-method-name>
<reference-class>uk.co.lsb.elb.toplink.Ffclient</reference-class>
<relationship-partner-attribute-name>clientLoan</relationship-partner-attribute-name>
<is-private-owned>false</is-private-owned>
<uses-batch-reading>false</uses-batch-reading>
<indirection-policy>
<mapping-indirection-policy>
<type>oracle.toplink.internal.indirection.TransparentIndirectionPolicy</type>
</mapping-indirection-policy>
</indirection-policy>
<container-policy>
<mapping-container-policy>
<container-class>oracle.toplink.indirection.IndirectList</container-class>
<type>oracle.toplink.internal.queryframework.ListContainerPolicy</type>
</mapping-container-policy>
</container-policy>
<source-key-fields>
<field>LSB.CLIENT_LOAN.CLIENT_ID</field>
<field>LSB.CLIENT_LOAN.LOAN_ID</field>
</source-key-fields>
<target-foreign-key-fields>
<field>LSB.FFCLIENT.CLIENT_ID</field>
<field>LSB.FFCLIENT.LOAN_ID</field>
</target-foreign-key-fields>
<type>oracle.toplink.mappings.OneToManyMapping</type>
</database-mapping>
â¦..
<database-mapping>
<attribute-name>clientLoan</attribute-name>
<read-only>false</read-only>
<reference-class>uk.co.lsb.elb.toplink.ClientLoan</reference-class>
<relationship-partner-attribute-name>ffclientCollection</relationship-partner-attribute-name>
<is-private-owned>false</is-private-owned>
<uses-batch-reading>false</uses-batch-reading>
<indirection-policy>
<mapping-indirection-policy>
<type>oracle.toplink.internal.indirection.BasicIndirectionPolicy</type>
</mapping-indirection-policy>
</indirection-policy>
<uses-joining>false</uses-joining>
<foreign-key-fields>
<field>LSB.FFCLIENT.CLIENT_ID</field>
<field>LSB.FFCLIENT.LOAN_ID</field>
</foreign-key-fields>
<source-to-target-key-field-associations>
<association>
<association-key>LSB.FFCLIENT.LOAN_ID</association-key>
<association-value>LSB.CLIENT_LOAN.LOAN_ID</association-value>
</association>
<association>
<association-key>LSB.FFCLIENT.CLIENT_ID</association-key>
<association-value>LSB.CLIENT_LOAN.CLIENT_ID</association-value>
</association>
</source-to-target-key-field-associations>
<type>oracle.toplink.mappings.OneToOneMapping</type>
</database-mapping>Yes, many thanks for you reply.
My project has many layer (include DAO + EJB + BO + WEB).
Toplink objects which are auto created by TopLink has only using in DAO and EJB layer, then toplink objects are transfer to Bean objects (valueObject) which are contain primitive java type as int, long, double... not java wrapper object as Integer, Long, Double... Bean objects are using from EJB to WEB layer. So when set value to bean object from toplink object I sometime don't set all reference toplink object to reference object of bean (although bean has references bean object as toplink object) because there are too big. So when I update data from WEB layer to EJB layer, before update to database, I must get fill all data for foreign key of update object by create new reference toplink object, add reference_id to this object and set it to update object. I waste a lot of time, its very handwork and tire. Are you has any solution about this problem?
Thank in advanced.
ThangNQ -
Primary / foreign key replication
Good Day,
Suppose we have a Warm Standby , ASE 15.5, RS 15.6 with several databases pairs and table cross reference between these different databases, i.e:
Pdb1 -> Stdby1
Pdb2 -> Stdby2
PdbN -> StdbyN
Table T1 is at Pdb1 , table T2 is at Pdb2
T1 has a Pkey , T2 has a Fkey to PKey on T1( for example a master / detail relation ship)
and so on
Some times due to network latency (or other event) table T2 gets replicated before than T1 and replcation stops due to primary constraint violation, even though the PK exists on T1 ( but hasn't been replicated yet).
Q: Is there any way to ensure that T1 would get replicated first in order to avoid the error?
Thank you
Regards
Jose-MiguelHmmmm, doesn't work for me ... what am I missing?
===================================
select @@version
go
Adaptive Server Enterprise/15.7/EBF 22230 SMP SP121
sp_displaylogin
go
... snip ...
Configured Authorization:
sa_role (default ON)
sso_role (default ON)
replication_role (default ON)
mon_role (default ON)
Locked: NO
... snip ...
use tempdb
go
create table t1 (a int, b int)
go
alter table t1 add primary key (a)
go
create table t2 (a int references t1(a), c int)
go
insert t2 values (1,5)
go
Msg 546, Level 16, State 1:
Server 'WLP_STAGINGREP', Line 1:
Foreign key constraint violation occurred, dbname = 'tempdb', table name = 't2', constraint name = 't2_a_345657311'.
Command has been aborted.
set disable_ri_check on
go
insert t2 values(1,5)
go
Msg 546, Level 16, State 1:
Server 'WLP_STAGINGREP', Line 1:
Foreign key constraint violation occurred, dbname = 'tempdb', table name = 't2', constraint name = 't2_a_345657311'.
Command has been aborted.
insert t1 values (1,5)
insert t2 values (1,7)
go
set disable_ri_check on
go
delete t1
go
Msg 547, Level 16, State 1:
Server 'WLP_STAGINGREP', Line 1:
Dependent foreign key constraint violation in a referential integrity constraint. dbname = 'tempdb', table name = 't1', constraint name = 't2_a_345657311'.
Command has been aborted.
-- and just in case the logic is reversed
set disable_ri_check off
go
delete t1
go
Msg 547, Level 16, State 1:
Server 'WLP_STAGINGREP', Line 1:
Dependent foreign key constraint violation in a referential integrity constraint. dbname = 'tempdb', table name = 't1', constraint name = 't2_a_345657311'.
Command has been aborted.
=================================== -
SQL for self foreign key has me baffled
Hi guys,
This is probably really simple. I am wanting to write an sql
for a dropdown menu for my top nav in my application. What it is,
is I have one column for ID ( primary ) and another for subID and a
page name ( txt) - seems like it would be simple , but I can't seem
to get it to work.
<cfquery name="getNav2" datasource="#application.db#">
SELECT ID, subID, pagetype, dapage, menuText, title, dasorter
FROM masterPager
ORDER by ID, subID, dasorter, menuText, dapage
</cfquery>
I have tried a where statement ( WHERE ID = subID ) and that
brings up nothing.
There is a diagram of what I want here -
http://www.interaktonline.com/Products/Dreamweaver-Extensions/MXCSSMenus/Documentation/Art icles/Design+Your+Database-Databases+By+Example.html?id_art=24&id_asc=222
( all one line ) They show the table, but not the SQL
The group on the output ( am a little confused )
What I want is for it to look like a tree - then I can apply
my CSS dropdown code.
Home
About Us
About_sub1
About_sub2
Contact
Contact_sub1
Contact_sub2
Products
Products_sub1
Products_sub2
Products_sub3
Disclaimer
Privacy
Any help would surely be appreciated.
Thanks in advanceI'm not sure what database you are using, but assuming SQL
Server, the query below will select all rows and order them either
by their sub_ID, or if the subID is NULL, the ID field would be
used in its place. Items with a NULL subID would be the "primary"
(top level) menu items. This would output your items in the proper
order. In the output, you would group by subID then loop through
and check to see if the ID=subID (which woud indicate the top level
menu items) and the ones following them would be the sub-menu
items.
<cfquery name="getNav2" datasource="#application.db#">
SELECT ID, ISNULL(subID, ID) AS sub_id, pagetype, dapage,
menuText, title, dasorter
FROM masterPager
ORDER by 2, 1, 3, 4, 5, 6
</cfquery>
Phil -
No join predicate for this foreign key -error while importing the EUL
Hello
Anyone getting this error?I am trying to import 11i business areas into R12 EUL and I am getting this
appreciate any feedback
thanks
kpAlso check metalink note 1082644.1, this problem can be caused when importing into an Apps mode EUL using the EUL owner database account, rather than an eBusiness Suite user account.
We've just had this exact problem, which was caused by something slightly different - an id column that was used in a join had been deleted. Discoverer does not cascade the delete, so the join was still in place, but with a blank formula. Disco reported no errors until an attempt was made to migrate this EUL from one environment to another. Deleting the join fixed the problem.
HTH
Matt -
Question on indexing foreign key for replicated table
Hi everybody,
I have 2 tables with following script
create table
parent(parent_id number(2) not null,
parent_name varchar(20),
constraint parent_pk primary key(parent_id))
create table child(child_id number(2) not null,
parent_id number(2) not null,
child_name varchar2(20),
constraint pk_child primary key(child_id,parent_id),
constraint fk_child foreign key (parent_id) references parenr(parent_id)
I want to replicate them and I know to replicate these 2 tables i should add them to my replication group, my question is that the child_id has foreign key so as below link says
http://dbataj.blogspot.com/2007/11/advance-replication-part-ii-master.html
I should put an index on the foreign key.What type of index should it be and is the following script correct for my purpose?
CREATE BITMAP
INDEX "fk_child"
ON child ("PARENT_ID")
TABLESPACE "USERS"
I would appreciate your help in advance.
MeryA bitmap index is almost certainly not the sort of index you'd want to create. You would normally want just a normal index, i.e.
CREATE INDEX fk_child
ON child( parent_id )on the master database just to support normal DML operations (otherwise, deleting a row from the parent table requires doing a full table scan on the child table to see if there are any orphaned child records).
If you are trying to set up a multi-master replication environment, you would also need to replicate this index, since you'll want to support basic DML on both nodes.
Justin
Maybe you are looking for
-
Itunes shows less memory than on my Ipod
I just purchased an Ipod picture/video 30gb, I have loaded 3376 songs into Itunes and Ipod so far, no pic's or videos, which comes out to 12.13gb. One day I received a "corrupt file" message in the bottom of my computer related to my Ipod. Itunes and
-
Problems with ppc 10.4.11 & Logic Pro
Hey guys, hope someone here can help... A few days ago I decided to clean re-install OS X 10.4 on my Mac Mini. Previous to this re-install Logic Pro was on the system and working fine so I re-installed the system and installed LP and now the app won'
-
I cannot print to postscript or print at all in Illustrator CS4.
Using CS4 Illustrator and I cannot print a 388 MB file. Computer freezes or sometimes the program crashes all together. Can anyone tell me how to fix this issue?
-
Hi All, we are in the process of setting a single client environment via client merge (SLO) we are merging three clients to one client I am not able to arrive at any decision on the SOPR and SXADMINTAB tables which are client dependent tables. SOPR t
-
For those of you who have gone on or given an interview for a labview programming position, what kind of questions can someone expect? Any suggestions for tips would greatly be appreciated. Thanks, Brian CLAD Brian