001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package javax.persistence;
031:
032: /**
033: * The main application interface to the persistence context.
034: */
035: public interface EntityManager {
036: /**
037: * Makes an object managed and persistent.
038: */
039: public void persist(Object entity);
040:
041: /**
042: * Merge the state of the entity to the current context.
043: */
044: public <T> T merge(T entity);
045:
046: /**
047: * Removes the instance.
048: */
049: public void remove(Object entity);
050:
051: /**
052: * Find based on the primary key.
053: */
054: public <T> T find(Class<T> entityCLass, Object primaryKey);
055:
056: /**
057: * Gets an instance whose state may be lazily fetched.
058: */
059: public <T> T getReference(Class<T> entityClass, Object primaryKey);
060:
061: /**
062: * Synchronize the context with the database.
063: */
064: public void flush();
065:
066: /**
067: * Sets the flush mode for all objects in the context.
068: */
069: public void setFlushMode(FlushModeType flushMode);
070:
071: /**
072: * Returns the flush mode for the objects in the context.
073: */
074: public FlushModeType getFlushMode();
075:
076: /**
077: * Sets the lock mode for an entity.
078: */
079: public void lock(Object entity, LockModeType lockMode);
080:
081: /**
082: * Update the state of the instance from the database.
083: */
084: public void refresh(Object entity);
085:
086: /**
087: * Clears the context, causing all entities to become detached.
088: */
089: public void clear();
090:
091: /**
092: * Check if the instance belongs to the current context.
093: */
094: public boolean contains(Object entity);
095:
096: /**
097: * Creates a new query.
098: */
099: public Query createQuery(String ql);
100:
101: /**
102: * Creates a named query.
103: */
104: public Query createNamedQuery(String name);
105:
106: /**
107: * Creates a native SQL query.
108: */
109: public Query createNativeQuery(String sql);
110:
111: /**
112: * Creates a native SQL query.
113: */
114: public Query createNativeQuery(String sql, Class resultClass);
115:
116: /**
117: * Creates a query for SQL.
118: */
119: public Query createNativeQuery(String sql, String resultSEtMapping);
120:
121: /**
122: * Joins the transaction.
123: */
124: public void joinTransaction();
125:
126: /**
127: * Gets the delegate.
128: */
129: public Object getDelegate();
130:
131: /**
132: * Closes the entity manager.
133: */
134: public void close();
135:
136: /**
137: * Returns true if the entity manager is open.
138: */
139: public boolean isOpen();
140:
141: /**
142: * Returns the transaction manager object.
143: */
144: public EntityTransaction getTransaction();
145: }
|