You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by "Trudgett, Glen" <Gl...@det.nsw.edu.au> on 2003/02/27 01:24:33 UTC
RE: obtaining native primary keys problem
To All,
I currently have an Oracle DB that I am using for my data.
I have set my tables to have natively generated primary keys, which works
fine.
I do an insert of information into a table, and the table happily accepts
the data, as expected.
test.insert("blah");
Table
1, blah
When I try to obtain the primary key for this new entry, which I want to use
to populate a foreign key link table, using
Test.getPrimaryKey();
I receive a value of 0. (Not the value of 1 or whatever number it is
allocated!!)
I can not work out why I can not get these values. I have tried a number of
ways e.g. getbyname(), getPrimaryKey().
Also I have noticed that the getPrimaryKeyas* functions are not available.
Has anybody run into a similar scenario?
TIA
Glen Trudgett
Unix system administration
Information Technology Bureau
Department of Education and Training
Level 2, 39A Herbert St, St Leonards, NSW 2065 Australia
Tel: 61+ (2) 99429970 Fax: 61+ (2) 99429600
**********************************************************************
This message is intended for the addressee named and may contain
privileged information or confidential information or both. If you
are not the intended recipient please delete it and notify the sender.
**********************************************************************
**********************************************************************
This message is intended for the addressee named and may contain
privileged information or confidential information or both. If you
are not the intended recipient please delete it and notify the sender.
**********************************************************************
Inheritance - restricting access to irrelevant columns
Posted by Travis McCauley <tw...@virginia.edu>.
Hi,
Is there any way for Torque to understand the relationship between
specific columns and specific subclasses?
I studied the generated code from the schema below (simplified). It
builds the class hierarchy correctly but the subclasses seem to be
different in name only. Is there any way to specify in the schema
which columns are relevant to which subclasses?
In this example, each of the columns in the last block should be
unique to one the three subclasses: Person, Project, Organization.
The generated code would let a Person object have an organization
name. If Torque can't specify these relationships, how have people
been restricting access to irrelevant attributes? Do you just
override the accessors and throw exceptions in the body?
Thanks for any ideas,
Travis McCauley
University of Virginia
<table name="RosterMember">
<!--metadata-->
<column name="id" primaryKey="true" required="true" type="INTEGER"/>
<column name="created_by" required="true" type="INTEGER"/>
<column name="modified_by" required="true" type="INTEGER"/>
<column name="created_on" required="true" type="TIMESTAMP"/>
<column name="modified_on" required="true" type="TIMESTAMP"/>
<column name="deleted" required="true" size="5" type="CHAR"/>
<!--inheritance key-->
<column name="member_class" inheritance="single" type="VARCHAR" size="24">
<inheritance key="person" class="Person" extends="RosterMember"/>
<inheritance key="project" class="Project" extends="RosterMember"/>
<inheritance key="organization" class="Organization" extends="RosterMember"/>
</column>
<!--columns unique to subclasses-->
<column name="person_name" type="LONGVARCHAR"/>
<column name="project_name" type="LONGVARCHAR"/>
<column name="organization_name" type="LONGVARCHAR"/>
</table>
Re: obtaining native primary keys problem
Posted by Richard Grossman <ri...@goldmail.net.il>.
How do you made the insert ??
How this key is generated do you use sequence object ?
Richard
----- Original Message -----
From: "Trudgett, Glen" <Gl...@det.nsw.edu.au>
To: "'Turbine Torque Users List'" <to...@db.apache.org>
Sent: Thursday, February 27, 2003 02:24
Subject: RE: obtaining native primary keys problem
> To All,
>
>
> I currently have an Oracle DB that I am using for my data.
>
> I have set my tables to have natively generated primary keys, which works
> fine.
>
> I do an insert of information into a table, and the table happily accepts
> the data, as expected.
>
> test.insert("blah");
>
> Table
> 1, blah
>
> When I try to obtain the primary key for this new entry, which I want to
use
> to populate a foreign key link table, using
>
> Test.getPrimaryKey();
>
> I receive a value of 0. (Not the value of 1 or whatever number it is
> allocated!!)
>
> I can not work out why I can not get these values. I have tried a number
of
> ways e.g. getbyname(), getPrimaryKey().
>
> Also I have noticed that the getPrimaryKeyas* functions are not available.
>
> Has anybody run into a similar scenario?
>
> TIA
>
>
>
> Glen Trudgett
> Unix system administration
> Information Technology Bureau
> Department of Education and Training
> Level 2, 39A Herbert St, St Leonards, NSW 2065 Australia
> Tel: 61+ (2) 99429970 Fax: 61+ (2) 99429600
>
> **********************************************************************
> This message is intended for the addressee named and may contain
> privileged information or confidential information or both. If you
> are not the intended recipient please delete it and notify the sender.
> **********************************************************************
>
> **********************************************************************
> This message is intended for the addressee named and may contain
> privileged information or confidential information or both. If you
> are not the intended recipient please delete it and notify the sender.
> **********************************************************************
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>
Re: obtaining native primary keys problem
Posted by Jim Schneider <js...@kjinteractive.com>.
Glen,
I haven't tried the methods you mention. I usually just call the
accessor for the primary key field.
That is,
test.insert();
int pk = test.getId(); // assuming the primary key field name is "id"
in the schema.xml file
I'm assuming that this is not what you're looking for, but I thought I'd
just mention it anyway.
Jim
Trudgett, Glen wrote:
>To All,
>
>
>I currently have an Oracle DB that I am using for my data.
>
>I have set my tables to have natively generated primary keys, which works
>fine.
>
>I do an insert of information into a table, and the table happily accepts
>the data, as expected.
>
>test.insert("blah");
>
>Table
>1, blah
>
>When I try to obtain the primary key for this new entry, which I want to use
>to populate a foreign key link table, using
>
>Test.getPrimaryKey();
>
>I receive a value of 0. (Not the value of 1 or whatever number it is
>allocated!!)
>
>I can not work out why I can not get these values. I have tried a number of
>ways e.g. getbyname(), getPrimaryKey().
>
>Also I have noticed that the getPrimaryKeyas* functions are not available.
>
>Has anybody run into a similar scenario?
>
>TIA
>
>
>
>Glen Trudgett
>Unix system administration
>Information Technology Bureau
>Department of Education and Training
>Level 2, 39A Herbert St, St Leonards, NSW 2065 Australia
>Tel: 61+ (2) 99429970 Fax: 61+ (2) 99429600
>
>**********************************************************************
>This message is intended for the addressee named and may contain
>privileged information or confidential information or both. If you
>are not the intended recipient please delete it and notify the sender.
>**********************************************************************
>
>**********************************************************************
>This message is intended for the addressee named and may contain
>privileged information or confidential information or both. If you
>are not the intended recipient please delete it and notify the sender.
>**********************************************************************
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>For additional commands, e-mail: torque-user-help@db.apache.org
>
>
>
>
--
Jim Schneider
KJ Interactive, Inc.
303-765-1357
www.kjinteractive.com