rename create->persist
git-svn-id: https://svn.jboss.org/repos/hibernate/trunk/Hibernate3/doc@5834 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
8eafe41c7e
commit
4ccd277fdc
|
@ -32,7 +32,7 @@
|
|||
Notice how we initialized the instance variable with an instance of
|
||||
<literal>HashSet</literal>. This is the best way to initialize collection
|
||||
valued properties of newly instantiated (non-persistent) instances. When
|
||||
you make the instance persistent - by calling <literal>create()</literal>,
|
||||
you make the instance persistent - by calling <literal>persist()</literal>,
|
||||
for example - Hibernate will actually replace the <literal>HashSet</literal>
|
||||
with an instance of Hibernate's own implementation of <literal>Set</literal>.
|
||||
Watch out for errors like this:
|
||||
|
@ -44,7 +44,7 @@ Cat kitten = new DomesticCat();
|
|||
Set kittens = new HashSet();
|
||||
kittens.add(kitten);
|
||||
cat.setKittens(kittens);
|
||||
session.create(cat);
|
||||
session.persist(cat);
|
||||
kittens = cat.getKittens(); // Okay, kittens collection is a Set
|
||||
(HashSet) cat.getKittens(); // Error!]]></programlisting>
|
||||
|
||||
|
@ -779,8 +779,8 @@ kittens = cat.getKittens(); // Okay, kittens collection is a Set
|
|||
category.getItems().add(item); // The category now "knows" about the relationship
|
||||
item.getCategories().add(category); // The item now "knows" about the relationship
|
||||
|
||||
session.create(item); // The relationship won't be saved!
|
||||
session.create(category); // The relationship will be saved]]></programlisting>
|
||||
session.persist(item); // The relationship won't be saved!
|
||||
session.persist(category); // The relationship will be saved]]></programlisting>
|
||||
|
||||
<para>
|
||||
The non-inverse side is used to save the in-memory representation to the database.
|
||||
|
|
|
@ -229,7 +229,7 @@ public class BlogMain {
|
|||
Transaction tx = null;
|
||||
try {
|
||||
tx = session.beginTransaction();
|
||||
session.create(blog);
|
||||
session.persist(blog);
|
||||
tx.commit();
|
||||
}
|
||||
catch (HibernateException he) {
|
||||
|
|
|
@ -92,7 +92,7 @@ Long generatedId = (Long) sess.save(fritz);]]></programlisting>
|
|||
is called. If <literal>Cat</literal> has an <literal>assigned</literal>
|
||||
identifier, or a composite key, the identifier should be assigned to
|
||||
the <literal>cat</literal> instance before calling <literal>save()</literal>.
|
||||
You may also use <literal>create()</literal> instead of <literal>save()</literal>,
|
||||
You may also use <literal>persist()</literal> instead of <literal>save()</literal>,
|
||||
with the semantics defined in the EJB3 early draft.
|
||||
</para>
|
||||
|
||||
|
@ -1062,7 +1062,7 @@ tx.commit(); // flush occurs]]></programlisting>
|
|||
</para>
|
||||
|
||||
<para>
|
||||
For each basic operation of the Hibernate session - including <literal>create(), merge(),
|
||||
For each basic operation of the Hibernate session - including <literal>persist(), merge(),
|
||||
saveOrUpdate(), delete(), lock(), refresh(), evict(), replicate()</literal> - there is a
|
||||
corresponding cascade style. Respectively, the cascade styles are named <literal>create,
|
||||
merge, save-update, delete, lock, refresh, evict, replicate</literal>. If you want an
|
||||
|
@ -1138,8 +1138,8 @@ tx.commit(); // flush occurs]]></programlisting>
|
|||
<itemizedlist spacing="compact">
|
||||
<listitem>
|
||||
<para>
|
||||
If a parent is passed to <literal>create()</literal>, all children are passed to
|
||||
<literal>create()</literal>
|
||||
If a parent is passed to <literal>persist()</literal>, all children are passed to
|
||||
<literal>persist()</literal>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
modification you make to the tree automatically synchronized to the
|
||||
database. You can even take an XML document, parse it using dom4j, and
|
||||
write it to the database with any of Hibernate's basic operations:
|
||||
<literal>create(), saveOrUpdate(), merge(), replicate()</literal> (merge
|
||||
is not yet supported in Hibernate 3.0rc1).
|
||||
<literal>persist(), saveOrUpdate(), merge(), delete(), replicate()</literal>
|
||||
(merge is not yet supported in Hibernate 3.0rc1).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
|
|
Loading…
Reference in New Issue