Supported Primary Key Types
Could someone please help as I haven't been able to find the answer from the TopLink doc?
In the TopLink's implementation of JDO Spec, what are the allowed the primary key types for a Persistence class?
I appreciate your information.
Haiwei
Doug, thanks very much for your response.
My immediate problem is this:
I am getting an exception (see below) while trying to use Byte[] as the primary key type in my testing. I wonder whether TopLink supports Byte[] primary key type.
I use TopLinks' getObjectById method.
A more general question, does TopLink support other data types for primary key (java.util.Date, java.sql.Date, java.sql.Time, java.sql.Timestamp, java.util.GregorianCalendar, etc.)? Your response seems to say Yes. Could you please confirm?
Here is the exception. The input Byte[] has value 25, with length of 1.
[4/19/04 12:26:26:126 EDT] 78c09b9c SystemOut O ServerSession(2046122932)--Exception [TOPLINK-3001] (OracleAS TopLink - 10g (9.0.4) (Build 031126)): oracle.toplink.exceptions.ConversionException
Exception Description: The object [[Ljava.lang.Byte;@4ffd9b9f], of class [class [Ljava.lang.Byte;], could not be converted to [class [B].Local Exception Stack:
Exception [TOPLINK-3001] (OracleAS TopLink - 10g (9.0.4) (Build 031126)): oracle.toplink.exceptions.ConversionException
Exception Description: The object [[Ljava.lang.Byte;@4ffd9b9f], of class [class [Ljava.lang.Byte;], could not be converted to [class [B].
at oracle.toplink.exceptions.ConversionException.couldNotBeConverted(ConversionException.java:35)
at oracle.toplink.internal.helper.ConversionManager.convertObjectToByteArray(ConversionManager.java:278)
at oracle.toplink.internal.helper.ConversionManager.convertObject(ConversionManager.java:129)
at oracle.toplink.internal.databaseaccess.DatabasePlatform.convertObject(DatabasePlatform.java:556)
at oracle.toplink.internal.databaseaccess.DatabasePlatform.convertToDatabaseType(DatabasePlatform.java:581)
at oracle.toplink.internal.databaseaccess.DatabasePlatform.appendParameter(DatabasePlatform.java:182)
at oracle.toplink.internal.databaseaccess.DatabaseCall.appendParameter(DatabaseCall.java:110)
at oracle.toplink.queryframework.SQLCall.translate(SQLCall.java:343)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(CallQueryMechanism.java:129)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(CallQueryMechanism.java:111)
at oracle.toplink.internal.queryframework.CallQueryMechanism.selectOneRow(CallQueryMechanism.java:584)
at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.selectOneRowFromTable(ExpressionQueryMechanism.java:792)
at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.selectOneRow(ExpressionQueryMechanism.java:763)
at oracle.toplink.queryframework.ReadObjectQuery.execute(ReadObjectQuery.java:340)
at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:498)
at oracle.toplink.queryframework.ReadQuery.execute(ReadQuery.java:111)
at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:1968)
at oracle.toplink.threetier.ServerSession.internalExecuteQuery(ServerSession.java:629)
at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1096)
at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1048)
at com.ford.it.persistence.jdo.toplink.PersistenceManagerWrapper.getObjectById(PersistenceManagerWrapper.java:130)
at com.ford.it.persistence.jdo.toplink.unittest.PersistenceManagerWrapperTest.testGetObjectById13(PersistenceManagerWrapperTest.java:423)
at java.lang.reflect.Method.invoke(Native Method)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at org.apache.cactus.ServletTestCase.runCactusTest(ServletTestCase.java:291)
at org.apache.cactus.ServletTestCase.runBare(ServletTestCase.java:263)
at org.apache.cactus.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:156)
at org.apache.cactus.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:130)
at org.apache.cactus.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:158)
at org.apache.cactus.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java)
at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:138)
at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:158)
at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java)
at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:109)
at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:158)
at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:948)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:530)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
Haiwei
Similar Messages
-
GeoMedia - Primary key types are not matching
I'm working on converting Access Spatial layers into Oracle Spatial layers using the Locator in Oracle 9i.
I have the Access PK as Long Interger
and the Oracle PK as Number (10,0).
I can't get around this error : Primary key types are not matchingHi,
please refer to
http://www.oracle.com/technology/pub/notes/technote_access_migration.html
You may try the OWM (Oracle Migration Workbench), if your data are more complex than one or two tables.
regards, Andreas
long integer(access) Number(11,0)(default) Number(11,0) (recommended)
----- -
Error While Deploying A CMP Entity Bean With A Composite Primary Key
Hello all,
I have a problem deploying CMP Entity beans with composite primary keys. I have a CMP Entity Bean, which contains a composite primary key composed of two local stubs. If you know more about this please respond to my post on the EJB forum (subject: CMP Bean Local Stub as a Field of a Primary Key Class).
In the mean time, can you please tell me what following error message means and how to resolve it? From what I understand it might be a problem with Sun ONE AS 7, but I would like to make sure it's not me doing something wrong.
[05/Jan/2005:12:49:03] WARNING ( 1896): Validation error in bean CustomerSubscription: The type of non-static field customer of the key class
test.subscription.CustomerSubscriptionCMP_1530383317_JDOState$Oid must be primitive or must implement java.io.Serializable.
Update the type of the key class field.
Warning: All primary key columns in primary table CustomerSubscription of the bean corresponding to the generated class test.subscription.CustomerSubscriptionCMP_1530383317_JDOState must be mapped to key fields.
Map the following primary key columns to key fields: CustomerSubscription.CustomerEmail,CustomerSubscription.SubscriptionType. If you already have fields mapped to these columns, verify that they are key fields.Is it enough that a primary key class be serializable or all fields have to implement Serializable or be a primitive?
Please let me know if you need more information to answer my question.
Thanks.
NikolaHi Nikola,
There are several problems with your CMP bean.
1. Fields of a Primary Key Class must be a subset of CMP fields, so yes, they must be either a primitive or a Serializable type.
2. Sun Application Server does not support Primary Key fields of an arbitrary Serializable type (i.e. those that will be stored
as BLOB in the database), but only primitives, Java wrappers, String, and Date/Time types.
Do you try to use stubs instead of relationships or for some other reason?
If it's the former - look at the CMR fields.
If it's the latter, I suggest to store these fields as regular CMP fields and use some other value as the PK. If you prefer that
the CMP container generates the PK values, use the Unknown
PrimaryKey feature.
Regards,
-marina -
Creation of CMP bean for a Composite Primary key????
Hi
i am having a composite primary keys in one of my table in the database.
I am trying to create a new entity bean for this table but i don't know how to create one in case when there is a composite primary key for a table.
Can anybody let me know is it possible to do it.
what is the procedure to be followed for the creation of the Entity bean in case of a composite primary key.
I am using MySql as the database .Creating CMP type of Entity bean.
Any help in this regard will be greatly useful to me as this is very urgent.
Thanks & Regards
Vikram KHi Nikola,
There are several problems with your CMP bean.
1. Fields of a Primary Key Class must be a subset of CMP fields, so yes, they must be either a primitive or a Serializable type.
2. Sun Application Server does not support Primary Key fields of an arbitrary Serializable type (i.e. those that will be stored
as BLOB in the database), but only primitives, Java wrappers, String, and Date/Time types.
Do you try to use stubs instead of relationships or for some other reason?
If it's the former - look at the CMR fields.
If it's the latter, I suggest to store these fields as regular CMP fields and use some other value as the PK. If you prefer that
the CMP container generates the PK values, use the Unknown
PrimaryKey feature.
Regards,
-marina -
Primary key and relevant not null check constraints....
Hi ,
There are some constraints of primary key type and not null check constraints on columns which constitute each primary key....
Should I/Do I have to drop them....????
Do they burden the db at the time of data validation....????
Thanks...
SimHi,
>>There are some constraints of primary key type and not null check constraints on columns which constitute each primary key..
In fact, a column that constitutes a primary key, by default cannot accept NULL values. In this case, defines a PK column as NOT NULL would not be necessary.
LEGATTI@ORACLE10> create table x (id number constraint pk_x primary key);
Table created.
LEGATTI@ORACLE10> desc x
Name Null? Type
ID NOT NULL NUMBER
LEGATTI@ORACLE10> select constraint_name,constraint_type,table_name,search_condition from user_constraints where table_name='X';
CONSTRAINT_NAME C TABLE_NAME SEARCH_CONDITION
PK_X P X
LEGATTI@ORACLE10> create table y (id number not null constraint pk_y primary key);
Table created.
LEGATTI@ORACLE10> desc y
Name Null? Type
ID NOT NULL NUMBER
LEGATTI@ORACLE10> select constraint_name,constraint_type,table_name,search_condition from user_constraints where table_name='Y';
CONSTRAINT_NAME C TABLE_NAME SEARCH_CONDITION
SYS_C006327381 C Y "ID" IS NOT NULL
PK_Y P Y
LEGATTI@ORACLE10> alter table y drop constraint SYS_C006327381;
Table altered.
LEGATTI@ORACLE10> desc y
Name Null? Type
ID NOT NULL NUMBER
LEGATTI@ORACLE10> insert into y values (NULL);
insert into y values (NULL)
ERROR at line 1:
ORA-01400: cannot insert NULL into ("LEGATTI"."Y"."ID")
LEGATTI@ORACLE10> insert into y values (1);
1 row created.
LEGATTI@ORACLE10> insert into y values (1);
insert into y values (1)
ERROR at line 1:
ORA-00001: unique constraint (LEGATTI.PK_Y) violated
>>Should I/Do I have to drop them....????
I don't see any problem, otherwise, drop the NOT NULL constraint is the same with alter the column table like below:
LEGATTI@ORACLE10> create table z (id number not null constraint pk_z primary key);
Table created.
LEGATTI@ORACLE10> select constraint_name,constraint_type,table_name,search_condition from user_constraints where table_name='Z';
CONSTRAINT_NAME C TABLE_NAME SEARCH_CONDITION
SYS_C006328420 C Z "ID" IS NOT NULL
PK_Z P Z
LEGATTI@ORACLE10> desc z
Name Null? Type
ID NOT NULL NUMBER
LEGATTI@ORACLE10> alter table z modify id NULL;
Table altered.
LEGATTI@ORACLE10> select constraint_name,constraint_type,table_name,search_condition from user_constraints where table_name='Z';
CONSTRAINT_NAME C TABLE_NAME SEARCH_CONDITION
PK_Z P Z
LEGATTI@ORACLE10> desc z
Name Null? Type
ID NOT NULL NUMBERCheers
Legatti -
How can I use a mySQL database schema with numeric auto increment primary key instead of GUID?
Hello!
I'm using the TestStand "MySQL Insert (NI)" database schema with GUID as primary key. So everything works fine.
But I prever using numeric values as primary key, because the database is in conjunction with another database which uses numeric values as primary key.
Is this possible?
Has anyone an idea how I can modify the "Generic Recordset (NI)" for use with MySQL?
Thanks!
Configuration:
Microsoft Windows XP
TestStand 3.1
MySQL 4.1.12a
MySQL ODBC 3.51 Driver
BrosigAdam -
The TestStand Database Logging feature does not allow you to run a separate SQL command after executing the command for a statement(table), so I do not think that you can use an auto incrementing column for the tables. There is just no way to get it back in a generic way. One option that I tried is something similar to the Oracle schema where you call a store procedure to return a sequence ID for each record that you want to add.
So you would have to create the following sequence table in MySQL:
CREATE TABLE sequence (id INT NOT NULL);
INSERT INTO sequence VALUES (0);
Then create a stored procedure as shown below that will increment the sequence value and return it in a recordset:
CREATE PROCEDURE `getseqid`()
BEGIN
UPDATE sequence SET id=LAST_INSERT_ID(id+1);
SELECT LAST_INSERT_ID();
END
Then update the MySQL tables to use INT primary and foreign key values, so the TestStand MySQL SQL file to create all tables would have text like this:
CREATE TABLE UUT_RESULT
ID INT PRIMARY KEY,
~
CREATE TABLE STEP_RESULT
ID INT PRIMARY KEY,
UUT_RESULT INT NOT NULL,
~
Then update the schema primary and foreign key columns in the TestStand Database Options dialog box to be INT to match the table. For the primary key columns, you will have to set the Primary Key Type to "Get Value from Recordset" and set the Primary Key Command Text to "call getseqid()". This will call the stored procedure to determine the next value to use as the ID value.
Hope this helps...
Scott Richardson
National Instruments -
Here is my scenario:
I have inserted 5 rows in mobile client with primary key 1, 2, 3, 4,5
Then deleted 3rd row and updated the primary key for 4th and 5th row to make the primary key sequential.
But when I sync, I get conflict error with DML Operation update
Does oracle lite support primary key update or primary key reshuffle?
ThanksHi,
can you apply this one-off patch 7337669 Oracle Database Lite: Patch
CONSOLIDATED ONEOFF FOR CUSTOMER BUGS TILL AUG 19 2008 10.3.0.1.0 19-AUG-2008
and tell me if you are still able to reproduce this behavior?
The Patch is available on metakink.oracle.com
Regards.
Marc -
No primary key attribute and does not support rowId -- URGENT : ADF Swing
Hi , i have created a view and while create Entity Object through Business Components wizard for that view i am getting following error.
ENTITY CREATION FAILED FOR THE FOLLOWING DATABASE OBJECT
NO PRIMARY KEY ATTRIBUTES AND DOES NOT SUPPORT ROWID . USE ENTITY WIZARD TO CREATE THE ENTITY OBJECT.
very urgent.
Jdeveloper version :: 10.1.3.1.0
oracle version :: 10g
view script is :
SELECT
oh.order_number||'- ('||ol.line_number||'-'||ol.shipment_number||')' so_line,
oh.cust_po_number customer_po,
ol.flow_status_code status,
ol.shipping_method_code carrier,
ol.ordered_item item_no,
nvl(xxapplication_express_pkg.getcustomerpart(ol.inventory_item_id, hca.cust_account_id), ' ') customer_item_number,
nvl(mtl.description , 'na') description,
nvl(org.organization_name , 'oak park') ship_from,
hcsu.location||' ('||hl.city||' '||hl.state||' '||hl.postal_code||')' ship_to,
nvl(ol.promise_date, sysdate) promised_date,
nvl(ol.ordered_quantity, 0) order_quality ,
xxapps.xx_eg_calculated_onhand(ol.line_id) available_qty,
nvl(ol.shipped_quantity, 0) shipped_quality ,
ol.order_quantity_uom uom,
hp.party_name customer_name,
jrs.name sales_person_name,
0 refer
FROM
oe_order_headers_all oh,
oe_order_lines_all ol,
hz_cust_accounts hca,
hz_parties hp ,
hz_cust_site_uses_all hcsu,
hz_cust_acct_sites_all hcas,
hz_party_sites hps,
hz_locations hl,
org_organization_definitions org ,
mtl_system_items_b mtl ,
jtf_rs_salesreps jrs
WHERE
oh.header_id = ol.header_id and
oh.org_id = ol.org_id and
oh.sold_to_org_id = hca.cust_account_id and
hca.party_id = hp.party_id and
hcas.cust_account_id = hca.cust_account_id and
hcsu.cust_acct_site_id = hcas.cust_acct_site_id and
hcas.party_site_id = hps.party_site_id and
hps.location_id = hl.location_id and
hcsu.site_use_id = oh.ship_to_org_id and
hcsu.site_use_code = 'SHIP_TO' and
org.organization_id = ol.ship_from_org_id and
org.organization_id = mtl.organization_id and
ol.inventory_item_id = mtl.inventory_item_id and
ol.ship_from_org_id = mtl.organization_id and
ol.salesrep_id = jrs.salesrep_id and
ol.org_id = jrs.org_id
can i know will it check for any constraints while correlation multiple table or whether this type of exception can be sorted out .
need help looking forward to reply...
Regards
bhanu prakash
Message was edited by:
user579125
Message was edited by:
user579125User,
I assume that this is for read-only activity. If so, don't create an EO from the database view; create a read-only view object instead. The only reason you'd want to use an Entity Object is if you were going to insert/update through the EO; unless you have an instead-of trigger, this database view is non-insertable/non-updatable.
Short answer: I think what you want to do is a read-only View Object (not EO) - put "select x, y, z (your columns) from view_name" as the SQL.
John -
Table creation from type - Primary key with 2 columns
Hello,
I have to create a table from a type that I created.
The thing is that I want to create a primary key using two column.
Because this table is junction table.
How can I do this ?
CREATE TABLE CONTENT OF CONTENT_T (ID_COMP primary key, ID_CHAR_J NOT NULL PRIMAR
Y KEY);
Oracle return:
CREATE TABLE CONTENT OF CONTENT_T (ID_COMP primary key,ID_CHAR_J NOT NULL PRIMARY KEY)
ERROR at line 1:
ORA-02260: table can have only one primary key
So I tried:
CREATE TABLE CONTENT OF CONTENT_T (ID_COMP,ID_CHAR_J NOT NULL PRIMARY KEY)
ERROR at line 1:
ORA-02338: missing or invalid column constraint specification
Tahnk's in advance.
Edited by: user8266437 on 29 avr. 2009 13:56
Edited by: user8266437 on 29 avr. 2009 13:56SCOTT@orcl_11g> CREATE OR REPLACE TYPE content_t AS OBJECT
2 (id_comp NUMBER,
3 id_char_j VARCHAR2 (10),
4 other_cols VARCHAR2 (10));
5 /
Type created.
SCOTT@orcl_11g> CREATE TABLE CONTENT OF CONTENT_T (PRIMARY KEY (ID_COMP, ID_CHAR_J))
2 /
Table created.
SCOTT@orcl_11g> INSERT INTO content VALUES (content_t (1, 'A', 'WHATEVER'))
2 /
1 row created.
SCOTT@orcl_11g> COMMIT
2 /
Commit complete.
SCOTT@orcl_11g> INSERT INTO content VALUES (content_t (1, 'A', 'DUPLICATE'))
2 /
INSERT INTO content VALUES (content_t (1, 'A', 'DUPLICATE'))
ERROR at line 1:
ORA-00001: unique constraint (SCOTT.SYS_C0062057) violated
SCOTT@orcl_11g> COMMIT
2 /
Commit complete.
SCOTT@orcl_11g> SELECT * FROM content
2 /
ID_COMP ID_CHAR_J OTHER_COLS
1 A WHATEVER
SCOTT@orcl_11g> -
Problem with type conversion and primary key during row fetch
[Note, this error occurs in Oracle XE, APEX 2.1.0.00.39]
I have been having a problem with Automatic Row Fetch:
ORA-01460: unimplemented or unreasonable conversion requested
So in an effort to resolve this, I created a PL/SQL process with the query below and was able to isolate the same error. The problem seems to come from one of the primary keys being a "number" type (APP_ID). The error occurs on the line:
where u.app_id=:P5_APP_ID
I have tried the following variations on this line in an effort to resolve this, but all generate the same error:
1) where to_char(u.app_id) = :P5_APP_ID
2) where u.app_id = to_number(:P5_APP_ID)
3) where to_char(u.app_id) = to_char(:P5_APP_ID)
I've also tried the laternate syntax "&__." and "#__#", but these don't function in the Source field and show up as syntax errors.
Any suggestions are welcome.
begin
for r in (
select app_name, apptype, appcreator, appurl
from application_users u, application_info i
where u.app_id=:P5_APP_ID
and i.app_id=u.app_id
and u.username=:P5_USERNAME)
loop
begin
:P5_APP_NAME := r.app_name;
:P5_APPURL := r.appurl;
exception
when others then
raise_application_error(-20000,'In Loop Failure',true);
end;
end loop;
exception
when others then
raise_application_error(-20000,'Out of Loop Failure',true);
end;
Thanks in advance,
BarneyI found a prior post referencing a similar issue and it was solved by using the "v(__)" syntax. This did resolve my issue, however, I have a quick follow-on which I'm hoping someone can answer quickly...
Since the "v(__)" syntax won't work for the Automatic Row Fetch (at least to the best of my knowledge), I have to do a manual process. However, the manual query as shown above doesn't actually populate any of the form values through the bind variables. They all remain at their cached values from prior data entry on the form.
Is using the bind variables for assignment incorrect, or is there something that must be done to get the updates to show up in the form (ordering of processes, etc.).
My manual process is running in the Load: Before Header state so I would have expected it to update all of the fields.
Thanks in advance,
Barney -
How to change the source type for a primary key on a form?
Hi,
At the time of creating a form, I had set the source type for the primary key to an existing sequence.
Now I want to change the source to a trigger.
Can anyone suggest how to do it?
Thanks in advance,
AnnieAnnie:
Define the trigger and then delete the page process named 'Get PK'
Varad -
Primary key based on multiple fields which are of a custom class type
Hello!
I have the following two classes.
public class Application
protected String appName;
protected Set moduleOptions = new HashSet(); //Set<ModuleOption>
public class Option
protected String name;
protected Application application;
Now, I need for Option to have a composite primary key based on both its
fields. How do I do this?
For starters, I just need a few hints on how this should be done in Kodo
because I already have this thing working in JPOX and that solution does
not map directly to Kodo. JPOX defines the OptionPK (primary key class)
to contain field ApplicationPK, and not Application. But Kodo does not
accept this because of a mismatch between fields in class and its primary
key class. (Not implying that Kodo should accept the same kind of
solution.)
Btw, I'm evaluating version 3.2.3.
Thanks in advance!Viktor,
The typical Kodo pattern for doing this is to create a private field in
Option for each primary key in Application, map those fields as
primary-key (but not the field of type Application), and therefore put
those fields in the OptionPK. These fields should then be mapped to the
same columns as the Application reference. Then, set the primary key
fields to the same value as they are in the related object.
Kodo allows multiple fields to be mapped to the same column in the
database, and throws an exception if your actions would set the column
to different values. So, typically, this might look like:
public class Application
protected String appName; // I'm assuming that this is the PK
protected Set moduleOptions = new HashSet ();
public class Option
protected String name; // pk
protected Application application; // not pk
private String applicationAppName; // pk
public Option (String n, Application a)
name = n;
application = a;
applicationAppName = a.appName;
-Patrick
Viktor Matic wrote:
Hello!
I have the following two classes.
public class Application
protected String appName;
protected Set moduleOptions = new HashSet(); //Set<ModuleOption>
public class Option
protected String name;
protected Application application;
Now, I need for Option to have a composite primary key based on both its
fields. How do I do this?
For starters, I just need a few hints on how this should be done in Kodo
because I already have this thing working in JPOX and that solution does
not map directly to Kodo. JPOX defines the OptionPK (primary key class)
to contain field ApplicationPK, and not Application. But Kodo does not
accept this because of a mismatch between fields in class and its primary
key class. (Not implying that Kodo should accept the same kind of
solution.)
Btw, I'm evaluating version 3.2.3.
Thanks in advance! -
Primary Key supported by a non-unique index?
Encountered a weird situation today. A utility we setup which allows Analysts to restore data into their tables, started failing when it attempted to drop an index. The index was supporting a Primary Key. Makes sense. But our script was supposed to only be attempting to drop/recreate non-unique indexes. Turns out the supporting index on the Primary Key was non-unique, and to the best of my knowledge came about as follows:
SQL> create table junk (f number(1));
Table created.
SQL> create index junk_ix on junk(f);
Index created.
SQL> select UNIQUENESS from DBA_INDEXES where index_name = 'JUNK_IX';
UNIQUENES
NONUNIQUE
SQL> alter table forbesc.junk add constraint junk_pk primary key (f) using index junk_ix;
Table altered.
SQL> select UNIQUENESS from DBA_INDEXES where index_name = 'JUNK_IX';
UNIQUENES
NONUNIQUE
SQL> insert into junk values (1);
1 row created.
SQL> insert into junk values (1);
insert into junk values (1)
ERROR at line 1:
ORA-00001: unique constraint (FORBESC.JUNK_PK) violated
SQL> select index_name from dba_constraints where constraint_name = 'JUNK_PK';
INDEX_NAME
JUNK_IXWhat I can't figure out is how a non-unique index is enforcing uniqueness. I thought that it was the key in that very same process. I thought that perhaps an index with the 'SYS_123456' was getting created, perhaps, but I couldn't find one:
SQL> select object_name, object_type from dba_objects order by created desc;
OBJECT_NAME OBJECT_TYPE
JUNK_IX INDEX
JUNK TABLE
...How is the uniqueness getting enforced in this case? This is in Oracle 11.1.0.7
Thanks,
--=ChuckIt has always been that way. Oracle can, and will, use a non-unique index to enforce a PK constraint, The existing index just needs to have the PK column(s) as the leading column(s) of the index:
SQL> create table t (id number, id1 number, descr varchar2(10));
Table created.
SQL> create index t_ids on t(id, id1);
Index created.
SQL> select index_name from user_indexes
2 where table_name = 'T';
INDEX_NAME
T_IDS
SQL> alter table t add constraint t_pk
2 primary key (id);
Table altered.
SQL> select index_name from user_indexes
2 where table_name = 'T';
INDEX_NAME
T_IDS
SQL> insert into t values (1, 1, 'One');
1 row created.
SQL> insert into t values (1, 2, 'Two');
insert into t values (1, 2, 'Two')
ERROR at line 1:
ORA-00001: unique constraint (OPS$ORACLE.T_PK) violatedJohn -
How to Create process of Type : Get Next or Previous Primary Key Value
Hi,
Can anybody give the steps how to create the page process for type Get Next or Previous Primary Key Value in oracle Express database
Ramesh j c.Hi Justin,
In oracle 10g XE , we have sample application v2.0
1. Do you have any Document to create step by step the sample application v2.0 and Is it possible to create all the pages of this sample application v2.0 b by wizard. To recreate or create the demo app, start from the home area,
next go to application builder,
then click the create button,
next choose "demonstration application"
and then you can choose "Run | Edit | Re-install" the "Sample Application" along with a few other apps.
2. When we install this sample application v2.0 , which is the sql script is executed or how it is installed. If you want the sample application you can export it after you create it if you want the SQL associated with it.
3. Whenever the sample application v2.0 is installed, how the encrypted pass word is created for the user demo and admin. This is setup with the application install. I don't believe it is encrypted either. If your wanting SSL there are some threads on here that talk about encrypting content.
Justin thanks for to create process Get Next or Previous Primary Key Value -
Primary Key Data type in Time Dimension????
I have to create a Time dimension with day grain in a Datawarehouse system and I donât know what is the best data type for the primary key...
For example
1) I could put Number(8) datatype, then the dates will be: 20050114, 20050115, 20050116.... Then in the fact tables I put the Number(8) datatype in the date fields... But in my reporting tools I have to put the to_date function to show the dates in the right format.
2) Or I could put Date datatype, then the dates will be: 01/14/2005, 01/15/2005, 01/16/2005.... Then in the fact tables I put the Date datatype in the date fields...
Itâs the Date primary key a bad datatype? (Very slow)
What is the best Primary Key Data type in Time Dimension???
Thanks!<quote>I have to create a Time dimension with day grain</quote>
OK.
<quote>But in my reporting tools I have to put the to_date function to show the dates in the right format</quote>
Why? ... if youâve decided to have a Day dimension table what is stopping you from having the day represented as a DATE column in there? (plus all the other "right formats" you may need). The join keys should only be used for ⦠joining.
<quote> Itâs the Date primary key a bad datatype? (Very slow)</quote>
No ⦠DATE or NUMBER wonât make any noticeable difference when used as the join key between the time dimension and the fact table.
Some see advantages in having the DATE FK in the fact table â¦
1. One can have range partitioning in the fact using real DATEs
2. One can get Day-derived info right from the fact table ⦠that is, the join to the Day dimension is not needed
I donât (see them as advantages) ⦠for #1, range partitioning by some measure of time is still achievable as long as the PK values on the Day dimension are immutable (as they should) ⦠and I donât see #2 as an advantage for the DW end-users.
Personally, I prefer a surrogate numeric PK ⦠but not things like 20050129.
<William>If you need dates then use dates. They are more robust, you can never accidentally have November 43rd</William>
Of course this can not be about the fact table ⦠since there the column is constrained ⦠so this is about accidentally getting "November 43rd, 2004" into the Day dimensions when the PK is numeric 20041143; true, but is a DATE PK more robust in this case? ⦠No ⦠one could accidentally insert to_date('29-Jan-2005','DD-Mon-YYYY') and to_date('29-Jan-2005 00:00:01','DD-Mon-YYYY HH24:MI:SS') and that won't be very good, would it? In both cases, one would need something extra to 100% protect the integrity of the Day dimension (mind you, loading the Day dimension probably happens once a year under the supervision of the most technical people on the project).
There is no best PK data type for the Day dimension (between NUMBER and DATE) ⦠they are both workable solutions ... go with what youâre comfortable.
Maybe you are looking for
-
How do i tell if my iphone is a 3G or 3GS?
how do I tell if my iphone is a 3G or 3GS?
-
Enter scheduling Key - BAPI_MATERIAL_SAVEREPLICA
I am using BAPI_MATERIAL_SAVEREPLICA to create new Material Header in a reference plant. The reference plant does not have a scheduling margin key. I am getting error 'Enter the scheduling margin key'. The BAPI is expecting the plantdata-sm_key. I ha
-
Aperture will no longer sync with itunes! Iphone 4, Itunes 10, iOS 4.1
This is very odd and bothersome. I have some 13K photos in Aperture 3, and have been successfully syncing a small subset of those with my iphone 4 via itunes 10. No problems mostly so far. Today I added a few photos to aperture, and then synced my ip
-
I converted a PDF to a Word Document with barcodes #39 on them. The barcodes didn't convert? Any ideas???
-
Hi; I have an order.It has three operations 0010-0020 and 0030. Operation 0010 has a trigger point which TRIG1 I choise; - Release succeeding operations is activated - System status : PCNF-Partially confirmed - Change: * - Activate: 2 I release opera