<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Deleting Entity Objects</title>
<link rel="stylesheet" href="gettingStarted.css" type="text/css" />
<meta name="generator" content="DocBook XSL Stylesheets V1.62.4" />
<link rel="home" href="index.html" title="Getting Started with Berkeley DB" />
<link rel="up" href="persist_access.html" title="Chapter 5. Saving and Retrieving Objects" />
<link rel="previous" href="dpl_entityjoin.html" title="Join Cursors" />
<link rel="next" href="dpl_replace.html" title="Replacing Entity Objects" />
</head>
<body>
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">Deleting Entity Objects</th>
</tr>
<tr>
<td width="20%" align="left"><a accesskey="p" href="dpl_entityjoin.html">Prev</a> </td>
<th width="60%" align="center">Chapter 5. Saving and Retrieving Objects</th>
<td width="20%" align="right"> <a accesskey="n" href="dpl_replace.html">Next</a></td>
</tr>
</table>
<hr />
</div>
<div class="sect1" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both"><a id="dpl_delete"></a>Deleting Entity Objects</h2>
</div>
</div>
<div></div>
</div>
<p>
The simplest way to remove an object from your entity store
is to delete it by its primary index. For example,
using the <tt class="classname">SimpleDA</tt> class that we
created earlier in this document
(see <a href="simpleda.html">SimpleDA.class</a>),
you can delete the <tt class="classname">SimpleEntityClass</tt>
object with a primary key of <tt class="literal">keyone</tt> as
follows:
</p>
<pre class="programlisting">sda.pIdx.delete("keyone");</pre>
<p>
You can also delete objects by their secondary keys. When
you do this, all objects related to the secondary key are
deleted, unless the key is a foreign object.
</p>
<p>
For example, the following deletes all
<tt class="classname">SimpleEntityClass</tt> with a secondary
key of <tt class="literal">skeyone</tt>:
</p>
<pre class="programlisting">sda.sIdx.delete("skeyone");</pre>
<p>
Finally, if you are indexing by foreign key, then the
results of deleting the key is determined by the foreign
key constraint that you have set for the index. See
<a href="dplindexcreate.html#foreignkey">Foreign Key Constraints</a>
for more information.
</p>
</div>
<div class="navfooter">
<hr />
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"><a accesskey="p" href="dpl_entityjoin.html">Prev</a> </td>
<td width="20%" align="center">
<a accesskey="u" href="persist_access.html">Up</a>
</td>
<td width="40%" align="right"> <a accesskey="n" href="dpl_replace.html">Next</a></td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Join Cursors </td>
<td width="20%" align="center">
<a accesskey="h" href="index.html">Home</a>
</td>
<td width="40%" align="right" valign="top"> Replacing Entity Objects</td>
</tr>
</table>
</div>
</body>
</html>
Copyright 2K16 - 2K18 Indonesian Hacker Rulez