/**
* Copyright (C) 2001-2005 France Telecom R&D
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.objectweb.speedo.pm.ejb.lib;
import org.objectweb.perseus.persistence.api.PersistenceException;
import org.objectweb.speedo.mim.api.FetchPlanItf;
import org.objectweb.speedo.mim.api.PersistentObjectItf;
import org.objectweb.speedo.mim.lib.SpeedoFetchPlan;
import org.objectweb.speedo.pm.ejb.api.EJBPOManagerItf;
import org.objectweb.speedo.pm.lib.AbstractPOManager;
import java.util.Collection;
import java.util.Map;
import javax.persistence.EntityTransaction;
import javax.persistence.FlushModeType;
import javax.persistence.LockModeType;
import javax.persistence.Query;
import javax.persistence.TransactionRequiredException;
/**
*
* TODO: runtimeException thrown by the methods will cause the current
* transaction to rollback
* @author S.Chassande-Barrioz
*/
public class EJBPOManager extends AbstractPOManager implements EJBPOManagerItf {
private FlushModeType flushMode;
/**
*
*/
public EJBPOManager() {
super();
}
public FetchPlanItf speedoGetFetchPlan() {
if (fetchPlan == null) {
fetchPlan = new SpeedoFetchPlan();
}
return fetchPlan;
}
/**
* Make an instance managed and persistent
* @param entity
* @throws java.lang.IllegalArgumentException if not an entity or entity
* is detached
* @throws javax.persistence.TransactionRequiredException if there is no
* transaction
* @see javax.persistence.EntityManager#persist(java.lang.Object)
*/
public void persist(Object entity) {
//TODO implement EJBPOM.persist(Object)
}
/**
* Merge the state of the given entry into the current persistence context
* @param entity
* @return the instance that the state was merge to
* @throws java.lang.IllegalArgumentException if instance is not an entity
* or is a removed instance
* @throws javax.persistence.TransactionRequiredException if there is no
* transaction
* @see javax.persistence.EntityManager#merge(java.lang.Object)
*/
public Object merge(Object entity) {
//TODO implement EJBPOM.merge(Object)
return null;
}
/**
* Remove the instance
* @param entity
* @throws java.lang.IllegalArgumentException if not an entity or if
* a detached entity
* @throws javax.persistence.TransactionRequiredException if there is no
* transaction
* @see javax.persistence.EntityManager#remove(java.lang.Object)
*/
public void remove(Object entity) {
//TODO implement EJBPOM.remove(Object)
}
/**
* Find by primary key
* @param entityClass
* @param primaryKey
* @return the found entity instance or null if the entity does not exist
* throws
* @throws java.lang.IllegalArgumentException if the first argument does not
* denote an entity type or the second argument is not a valid type for that
* entity'primary key
* @see javax.persistence.EntityManager#find(java.lang.Class, java.lang.Object)
*/
public Object find(Class entityClass, Object primaryKey) {
//TODO implement EJBPOM.find(Class, Object)
return null;
}
/**
* Get an instance, whoose state may be lazily fetched. If the requested
* instance does not exist in the database, throws
* javax.persistence.EntityNotFoundException when the instance state is
* first accessed. (The container is permitted to throw
* EntityNotFoundException when get is called.)
* The application shoud not expect that the instance state will be
* availlable upon detachment, unless it was accessed by the application
* while the entity manager was open.
* @param entityClass
* @param primaryKey
* @return the found entity instance
* @throws java.lang.IllegalArgumentException if the first argument does not
* denote an entity type or the second argument is not a valid type for that
* entity'primary key
* @throws javax.persistence.EntityNotFoundException if the entity state
* cannot be accessed
* @see javax.persistence.EntityManager#getReference(java.lang.Class, java.lang.Object)
*/
public Object getReference(Class entityClass, Object primaryKey) {
//TODO implement EJBPOM.getReference(Class, Object)
return null;
}
/**
* Synchronize the persistence context to the underlying database.
* @throws javax.persistence.TransactionRequiredException if there is no
* transaction
* @throws javax.persistence.PersistenceException if there the flush fails
* @see javax.persistence.EntityManager#flush()
*/
public void flush() {
if (!tx.isActive()) {
throw new TransactionRequiredException(
"transaction required for the flush operation");
}
try {
speedoFlush();
} catch (PersistenceException e) {
throw new javax.persistence.PersistenceException(e);
}
}
/**
* Refresh the state of the instanc from the database overwriting chages
* mades to the entity, if any.
* @param entity
* @throws java.lang.IllegalArgumentException if not an entity or entity is
* not managed.
* @throws javax.persistence.TransactionRequiredException if there is no
* transaction
* @throws javax.persistence.EntityNotFoundException if there is no longer
* exists in the database
* @see javax.persistence.EntityManager#refresh(java.lang.Object)
*/
public void refresh(Object entity) {
//TODO implement EJBPOM.refresh(Object)
}
/**
* Check if the instance belongs to the current persistence context
* @param entity
* @throws java.lang.IllegalArgumentException if not an entity
* @see javax.persistence.EntityManager#contains(java.lang.Object)
*/
public boolean contains(Object entity) {
//TODO implement EJBPOM.contains(Object)
return false;
}
/**
* closes an application-managed EntityManager. This method can only be
* called when the EntityManaged is not associated with an active
* transaction. After an EntityManager has been closed, all methodes on the
* EntityManager instance will throw the IllegalStateException except for
* isOpen, which will return false;
* @throws java.lang.IllegalStateException if the EntityManager is
* associated with an active transaction or if the EntityManager is
* container-managed.
* @see javax.persistence.EntityManager#close()
*/
public void close() {
closePOManager();
}
/**
* Indicates whether the EntityManager is open.
* @return true until the EntityManager has been closed.
* @see javax.persistence.EntityManager#isOpen()
*/
public boolean isOpen() {
return !isPOMClosed();
}
/**
* Returns the resource-level transaction object. The EntityTransaction
* instance may be used serially to bein and commit multiple transactions.
* @return EntityTransaction instance
* @throws java.lang.IllegalStateException if invoked on a JTA EntityManager
* or an EntityManager that has been closed.
* @see javax.persistence.EntityManager#getTransaction()
*/
public EntityTransaction getTransaction() {
return (EntityTransaction) tx;
}
/**
* @see javax.persistence.EntityManager#setFlushMode(javax.persistence.FlushModeType)
*/
public void setFlushMode(FlushModeType fmt) {
this.flushMode = fmt;
}
/**
* Create an instance of Query for executing an EJB QL statement
* @param ejbqlString an EJB QL query string
* @return the new query instance
* @throws IllegalArgumentException if query string is not valid
* @see javax.persistence.EntityManager#createQuery(java.lang.String)
*/
public Query createQuery(String ejbqlString) {
//TODO implement EJBPOM.createQuery(String)
return null;
}
/**
* Create an instance of Query for executing a named query (EJB QL or
* native SQL).
* @param name the name of a query defined in metadata
* @return the new query instance
* @throws IllegalArgumentException if query string is not valid
* @see javax.persistence.EntityManager#createNamedQuery(java.lang.String)
*/
public Query createNamedQuery(String name) {
//TODO implement EJBPOM.createNamedQuery(String)
return null;
}
/**
* Create an instance of Query for executing a native SQL statement.
* @param sqlString an EJB QL query string
* @return the new query instance
* @throws IllegalArgumentException if query string is not valid
* @see javax.persistence.EntityManager#createNativeQuery(java.lang.String)
*/
public Query createNativeQuery(String sqlString) {
//TODO implement EJBPOM.createNativeQuery(String)
return null;
}
/**
* Create an instance of Query for executing a native SQL statement.
* @param sqlString an EJB QL query string
* @param resultClass the class of the resulting instances
* @return the new query instance
* @throws IllegalArgumentException if query string is not valid
* @see javax.persistence.EntityManager#createNativeQuery(java.lang.String, java.lang.Class)
*/
public Query createNativeQuery(String sqlString, Class resultClass) {
//TODO implement EJBPOM.createNativeQuery(String, Class)
return null;
}
/**
* Create an instance of Query for executing a native SQL statement.
* @param sqlString an EJB QL query string
* @param resultSetMapping the class of the resulting instances
* @return the new query instance
* @throws IllegalArgumentException if query string is not valid
* @see javax.persistence.EntityManager#createNativeQuery(java.lang.String, java.lang.String)
*/
public Query createNativeQuery(String sqlString, String resultSetMapping) {
//TODO implement EJBPOM.createNativeQuery(String, String)
return null;
}
public void clear() {
// TODO Auto-generated method stub
}
public FlushModeType getFlushMode() {
// TODO Auto-generated method stub
return null;
}
public void lock(Object arg0, LockModeType arg1) {
// TODO Auto-generated method stub
}
public void speedoDeletePersistent(Object o) {
//TODO implement EJBPOM.speedoDeletePersistent(Object)
}
public void speedoDeletePersistent(Object oid, Class pc) {
//TODO implement EJBPOM.speedoDeletePersistent(Object,class)
}
public Object speedoAttachCopy(Object detached, Map map) {
//TODO implement EJBPOM.speedoAttachCopy(Object, boolean, map)
return null;
}
public Object speedoDetachCopy(PersistentObjectItf sp, Map map, Collection fgHints) {
//TODO implement EJBPOM.speedoDetachCopy(PersistentObjectItf, Map, Collection)
return null;
}
public Object speedoMakePersistent(PersistentObjectItf sp, Map map) {
//TODO implement EJBPOM.speedoDeletePersistent(Object)
return null;
}
public void speedoRefresh(PersistentObjectItf sp, Map map, Collection fgHints) {
//TODO implement EJBPOM.speedoMakePersistent(PersistentObjectItf, Map)
}
public void speedoRetrieve(PersistentObjectItf sp, Map map, Collection fgHints) {
//TODO implement EJBPOM.speedoRetrieve(PersistentObjectItf, Map, Collection)
}
}