copyright notice

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@17267 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2009-08-11 20:30:32 +00:00
parent ed6346174d
commit a1b6e3f243
16 changed files with 377 additions and 30 deletions

View File

@ -1,7 +1,23 @@
// $Id$
/* /*
* JBoss, the OpenSource EJB server Distributable under LGPL license. See terms of license at * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* gnu.org. * indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/ */
package org.hibernate.ejb; package org.hibernate.ejb;
@ -11,7 +27,6 @@ import java.io.ObjectOutputStream;
import java.io.Serializable; import java.io.Serializable;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityNotFoundException; import javax.persistence.EntityNotFoundException;
import javax.persistence.EntityTransaction; import javax.persistence.EntityTransaction;
import javax.persistence.FlushModeType; import javax.persistence.FlushModeType;
@ -395,7 +410,9 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
public abstract Session getSession(); public abstract Session getSession();
/** /**
* Return a Session (even if the entity manager is closed * Return a Session (even if the entity manager is closed).
*
* @return A session.
*/ */
protected abstract Session getRawSession(); protected abstract Session getRawSession();
@ -465,15 +482,6 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
else if ( mode == FlushMode.COMMIT ) { else if ( mode == FlushMode.COMMIT ) {
this.flushModeType = FlushModeType.COMMIT; this.flushModeType = FlushModeType.COMMIT;
} }
// else if ( mode == FlushMode.NEVER ) {
// if ( PersistenceContextType.EXTENDED == persistenceContextType && !isTransactionInProgress() ) {
// //we are in flushMode none for EXTENDED
// return flushMode;
// }
// else {
// return null; //TODO exception?
// }
// }
else { else {
return null; //TODO exception? return null; //TODO exception?
} }
@ -689,8 +697,6 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
return getSession(); return getSession();
} }
;
private void writeObject(ObjectOutputStream oos) throws IOException { private void writeObject(ObjectOutputStream oos) throws IOException {
oos.defaultWriteObject(); oos.defaultWriteObject();
} }

View File

@ -1,4 +1,24 @@
//$Id$ /*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.ejb; package org.hibernate.ejb;
import java.util.Map; import java.util.Map;
@ -6,7 +26,6 @@ import javax.persistence.PersistenceContextType;
import javax.persistence.spi.PersistenceUnitTransactionType; import javax.persistence.spi.PersistenceUnitTransactionType;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.SessionImplementor; import org.hibernate.engine.SessionImplementor;
import org.hibernate.util.JTAHelper; import org.hibernate.util.JTAHelper;

View File

@ -1,3 +1,25 @@
/*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
//$Id$ //$Id$
package org.hibernate.ejb; package org.hibernate.ejb;

View File

@ -1,4 +1,24 @@
//$Id$ /*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.ejb; package org.hibernate.ejb;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;

View File

@ -1,4 +1,24 @@
//$Id$ /*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.ejb; package org.hibernate.ejb;
import java.util.Map; import java.util.Map;
@ -19,8 +39,11 @@ import org.hibernate.ejb.criteria.QueryBuilderImpl;
import org.hibernate.ejb.metamodel.MetamodelImpl; import org.hibernate.ejb.metamodel.MetamodelImpl;
/** /**
* Actual Hiberate implementation of {@link javax.persistence.EntityManagerFactory}.
*
* @author Gavin King * @author Gavin King
* @author Emmanuel Bernard * @author Emmanuel Bernard
* @author Steve Ebersole
*/ */
public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory { public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory {
private final SessionFactory sessionFactory; private final SessionFactory sessionFactory;

View File

@ -1,3 +1,25 @@
/*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
//$Id$ //$Id$
package org.hibernate.ejb; package org.hibernate.ejb;
@ -17,6 +39,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* Hibernate implementation of {@link javax.persistence.EntityManager}.
*
* @author Gavin King * @author Gavin King
*/ */
public class EntityManagerImpl extends AbstractEntityManagerImpl { public class EntityManagerImpl extends AbstractEntityManagerImpl {
@ -33,13 +57,14 @@ public class EntityManagerImpl extends AbstractEntityManagerImpl {
PersistenceUnitTransactionType transactionType, PersistenceUnitTransactionType transactionType,
boolean discardOnClose, boolean discardOnClose,
Class sessionInterceptorClass, Class sessionInterceptorClass,
Map properties Map properties) {
) {
super( entityManagerFactory, pcType, transactionType, properties ); super( entityManagerFactory, pcType, transactionType, properties );
this.open = true; this.open = true;
this.discardOnClose = discardOnClose; this.discardOnClose = discardOnClose;
Object localSessionInterceptor = null; Object localSessionInterceptor = null;
if (properties != null) localSessionInterceptor = properties.get( HibernatePersistence.SESSION_INTERCEPTOR ); if (properties != null) {
localSessionInterceptor = properties.get( HibernatePersistence.SESSION_INTERCEPTOR );
}
if ( localSessionInterceptor != null ) { if ( localSessionInterceptor != null ) {
if (localSessionInterceptor instanceof Class) { if (localSessionInterceptor instanceof Class) {
sessionInterceptorClass = (Class) localSessionInterceptor; sessionInterceptorClass = (Class) localSessionInterceptor;
@ -62,7 +87,9 @@ public class EntityManagerImpl extends AbstractEntityManagerImpl {
} }
public Session getSession() { public Session getSession() {
if ( !open ) throw new IllegalStateException( "EntityManager is closed" ); if ( !open ) {
throw new IllegalStateException( "EntityManager is closed" );
}
return getRawSession(); return getRawSession();
} }
@ -92,8 +119,9 @@ public class EntityManagerImpl extends AbstractEntityManagerImpl {
} }
public void close() { public void close() {
if ( !open ) {
if ( !open ) throw new IllegalStateException( "EntityManager is closed" ); throw new IllegalStateException( "EntityManager is closed" );
}
if ( !discardOnClose && isTransactionInProgress() ) { if ( !discardOnClose && isTransactionInProgress() ) {
//delay the closing till the end of the enlisted transaction //delay the closing till the end of the enlisted transaction
getSession().getTransaction().registerSynchronization( getSession().getTransaction().registerSynchronization(
@ -120,7 +148,9 @@ public class EntityManagerImpl extends AbstractEntityManagerImpl {
} }
else { else {
//close right now //close right now
if ( session != null ) session.close(); if ( session != null ) {
session.close();
}
} }
open = false; open = false;
} }
@ -128,7 +158,9 @@ public class EntityManagerImpl extends AbstractEntityManagerImpl {
public boolean isOpen() { public boolean isOpen() {
//adjustFlushMode(); //don't adjust, can't be done on closed EM //adjustFlushMode(); //don't adjust, can't be done on closed EM
try { try {
if ( open ) getSession().isOpen(); //to force enlistment in tx if ( open ) {
getSession().isOpen(); //to force enlistment in tx
}
return open; return open;
} }
catch (HibernateException he) { catch (HibernateException he) {

View File

@ -1,3 +1,25 @@
/*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
//$Id$ //$Id$
package org.hibernate.ejb; package org.hibernate.ejb;

View File

@ -1,4 +1,24 @@
//$Id$ /*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.ejb; package org.hibernate.ejb;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
@ -6,8 +26,15 @@ import javax.persistence.EntityManager;
import org.hibernate.Session; import org.hibernate.Session;
/** /**
* Additional contract for Hibernate implementations of {@link EntityManager} providing access to various Hibernate
* specific functionality.
*
* @author Gavin King * @author Gavin King
*/ */
public interface HibernateEntityManager extends EntityManager { public interface HibernateEntityManager extends EntityManager {
/**
* Retrieve a reference to the Hibernate {@link Session} used by this {@link EntityManager}.
* @return
*/
public Session getSession(); public Session getSession();
} }

View File

@ -1,3 +1,25 @@
/*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
//$Id$ //$Id$
package org.hibernate.ejb; package org.hibernate.ejb;

View File

@ -1,3 +1,25 @@
/*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
//$Id$ //$Id$
package org.hibernate.ejb; package org.hibernate.ejb;

View File

@ -1,3 +1,25 @@
/*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
//$Id$ //$Id$
package org.hibernate.ejb; package org.hibernate.ejb;
@ -32,7 +54,7 @@ public class HibernatePersistence implements javax.persistence.spi.PersistencePr
*/ */
public static final String PROVIDER = "javax.persistence.provider"; public static final String PROVIDER = "javax.persistence.provider";
/** /**
* В * <EFBFBD>
* transaction type * transaction type
*/ */
public static final String TRANSACTION_TYPE = "javax.persistence.transactionType"; public static final String TRANSACTION_TYPE = "javax.persistence.transactionType";

View File

@ -1,3 +1,25 @@
/*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
//$Id$ //$Id$
package org.hibernate.ejb; package org.hibernate.ejb;

View File

@ -1,3 +1,25 @@
/*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
//$Id$ //$Id$
package org.hibernate.ejb; package org.hibernate.ejb;

View File

@ -1,3 +1,25 @@
/*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
//$Id$ //$Id$
package org.hibernate.ejb; package org.hibernate.ejb;

View File

@ -1,3 +1,25 @@
/*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
//$Id$ //$Id$
package org.hibernate.ejb; package org.hibernate.ejb;

View File

@ -1,3 +1,25 @@
/*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
//$Id$ //$Id$
package org.hibernate.ejb; package org.hibernate.ejb;