Oracle C++ Call Interface Programmer's Guide Release 2 (9.2) Part Number A96583-01 |
|
OCCI Classes and Methods, 15 of 22
OCCI provides object navigational calls that enable applications to perform any of the following on objects:
This class enables the type definer to specify when a class is capable of having persistent or transient instances. Instances of classes derived from PObject
are either persistent or transient. A class (called "A") that is persistent-capable inherits from the PObject
class:
class A : PObject { ... }
Some of the methods provided, such as lock()
and refresh()
, are applicable only for persistent instances, not for transient instances.
To create a null PObject
, use the syntax:
PObject();
The only methods valid on a null PObject
are setNull()
, isNull
, and operator=()
.
To create a copy of a PObject
, use the syntax:
PObject(const PObject& obj);
This method flushes a modified persistent object to the database server.
void flush();
This method returns the connection from which the persistent object was instantiated.
const Connection *getConnection() const;
This method returns a reference to the persistent object.
RefAny getRef() const;
This method test whether the persistent object is locked. If the persistent object is locked, then true is returned; otherwise, false is returned.
bool isLocked() const;
This method tests whether the persistent object is null. If the persistent object is null, then true is returned; otherwise, false is returned.
bool isNull() const;
This method locks a persistent object on the database server.
void lock(PObject::LockOption lock_option);
Specifies whether the lock operation should wait if the object is already locked by another user. The default value is OCCI_LOCK_WAIT
, meaning the operation will wait.
Valid values are:
OCCI_LOCK_WAIT
OCCI_LOCK_NOWAIT
This method marks a persistent object as deleted.
void markDelete();
This method marks a persistent object as modified or dirty.
void mark_Modified();
This method assigns the value of a persistent object this PObject
object. The nature (transient or persistent) of the object is maintained. Null information is copied from the source instance.
PObject& operator=(const PObject& obj);
The object to copy from.
This method is used to delete a persistent or transient object. The delete operator on a persistent object removes the object from the application cache only. To delete the object from the database server, invoke the markDelete()
method.
void operator delete(void *obj, size_t size);
This method is used to create a new object. A persistent object is created if the connection and table name are provided. Otherwise, a transient object is created.
There are variants of syntax:
void *operator new(size_t size);
void *operator new(size_t size, const Connection *x, const string& tablename, const char *type_name);
The connection to the database in which the persistent object is to be created.
The name of the table in the database server.
The SQL type name corresponding to this C++ class. The format is <schemaname>.<typename>
.
This method pins the object and increments the pin count by one. As long as the object is pinned, it will not be freed by the cache even if there are no references to this object instance.
void pin();
This method sets the object value to null.
void setNull();
This method unmarks a persistent object as modified or deleted.
void unmark();
This method unpins a persistent object. In the default mode, the pin count of the object is decremented by one. When this method is invoked with OCCI_PINCOUNT_RESET
, the pin count of the object is reset.
If the pin count is reset, this method invalidates all the references (Ref
) pointing to this object. The cache sets the object eligible to be freed, if necessary, reclaiming memory.
void unpin(UnpinOption mode=OCCI_PINCOUNT_DECR);
Specifies whether the pin count should be decremented or reset to 0.
Valid values are:
OCCI_PINCOUNT_RESET
OCCI_PINCOUNT_DECR
|
Copyright © 2001, 2002 Oracle Corporation. All Rights Reserved. |
|