I have a couple way to map the object base of different database. 
For PostgreSQL I'm new to it so I try to use oid + object name
as a handle. and object name converted to table name which in my 
scheme is the same key as oid+tableoid that according to calcualtion
I should have 4 billion row in each table....( correct me if I'm wrong ) 
and I don't think I'm going to push that limit. But the problem is 
I'm not able to get an object by another object id. e.g 
I get base object id 1234 that is in table child, how is that possible to 
be compare in the WHERE clause.

SELECT * from child WHERE myfather=1234::base; 

will case error because of miss = operation
I try to build internal function for it but the return type is a int4 run
after by a function seteval with the oid SET datatype in cache? 
( not sure about how this actually work, if someone write the in 
out function for the default table type, please let me know I
can give it a hack ) 

I know I can always roll back to the generic serial as pkey link as
reference key in other table but I really really like to see the 
this object casting work for postgresql. 
Thanks alot guys. 
Alex :) 

Dave Cramer wrote:

Alex,

Most of the Object Relation Mapping I have seen get the id from a
special mechanism, so they know it before hand?

FYI oid's are not guaranteed to be unique in Postgres.

Dave

-----Original Message-----
From: pgsql-hackers-owner@postgresql.org
[mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of Debian User
Sent: Friday, March 08, 2002 3:42 PM
To: pgsql-hackers@postgresql.org
Subject: [HACKERS] Object ID reference


Hi I'm new to the list, and I'm new to the PostgreSQL also. But I have
been using Object Relation Mapping for a period of time. I would like to
put native binding with PostgreSQL . It is fairly easy to read and write
Object into the relayed table e.g.

create table base (
myname text,
unique( myname )
);

create table child (
myfather base,
myname text
);

INSERT INTO base ( myname ) Values ( 'alex' ) ;
INSERT 56578 1  <<---- oid
INSERT INTO child ( myfather, myname ) values ( 56578::base, 'alexbaby'
); INSERT 56579 1  <<---- oid

However, there is no way to get the value back in the WHERE clause.
because the return type is 'base' but the value output ( correct me if
I'm wrong from digging the source by hand )  is actually oid returns
int4 from internal seteval() function. select * from child; myfather
myname
-------------------
56578      alexbaby

It could be a easy fix in the jdbc, or c  to match the seteval(base.oid)
with int4.[string, string] compare,  but then I need to loop through the
full Record Set by hand to get the data. is there a possible way to do
some function to convert the TYPE 'base' to oid or int4 or string? so I
can do something like this

SELECT * from child where myfather=56578::base;

or how am I getting internal seteval to work right with the return set
from a custom function. I really want to see this coming out right...
thanks a lot. Alex



Fri, 8 Mar 2002 15:53:13 -0600
alex@AvengerGear.com (Debian User)
Re: Object ID reference