Hibernate SVN: r10918 - trunk/Hibernate3/test/org/hibernate/test/propertyref
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-12-05 08:26:44 -0500 (Tue, 05 Dec 2006)
New Revision: 10918
Added:
trunk/Hibernate3/test/org/hibernate/test/propertyref/component/
Log:
HHH-2282 : PersistentClass propetty lookups and embedded composite identifiers;
consolidate property-ref tests
18 years, 3 months
Hibernate SVN: r10917 - branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-12-04 15:41:45 -0500 (Mon, 04 Dec 2006)
New Revision: 10917
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java
Log:
no longer hide the underying mapping exception
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/…
[View More]hibernate/cfg/annotations/EntityBinder.java 2006-12-04 20:39:04 UTC (rev 10916)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java 2006-12-04 20:41:45 UTC (rev 10917)
@@ -256,7 +256,7 @@
}
}
catch (MappingException me) {
- throw new AnnotationException( "Use of the same entity name twice: " + name );
+ throw new AnnotationException( "Use of the same entity name twice: " + name, me );
}
}
[View Less]
18 years, 3 months
Hibernate SVN: r10916 - trunk/Hibernate3/src/org/hibernate
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-12-04 15:39:04 -0500 (Mon, 04 Dec 2006)
New Revision: 10916
Modified:
trunk/Hibernate3/src/org/hibernate/Session.java
Log:
javadocs
Modified: trunk/Hibernate3/src/org/hibernate/Session.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/Session.java 2006-12-04 20:38:55 UTC (rev 10915)
+++ trunk/Hibernate3/src/org/hibernate/Session.java 2006-12-04 20:39:04 UTC (rev 10916)
@@ -86,52 +86,…
[View More]71 @@
public Session getSession(EntityMode entityMode);
/**
- * Force the <tt>Session</tt> to flush. Must be called at the end of a
+ * Force this session to flush. Must be called at the end of a
* unit of work, before commiting the transaction and closing the
- * session (<tt>Transaction.commit()</tt> calls this method). <i>Flushing</i>
- * is the process of synchronising the underlying persistent store with
- * persistable state held in memory.
+ * session (depending on {@link #setFlushMode flush-mode},
+ * {@link Transaction#commit()} calls this method).
+ * <p/>
+ * <i>Flushing</i> is the process of synchronizing the underlying persistent
+ * store with persistable state held in memory.
*
- * @throws HibernateException
+ * @throws HibernateException Indicates problems flushing the session or
+ * talking to the database.
*/
public void flush() throws HibernateException;
/**
- * Set the flush mode. The flush mode determines at which points
- * Hibernate automatically flushes the session. For a readonly
- * session, it is reasonable to set the flush mode to
- * <tt>FlushMode.NEVER</tt> at the start of the session (in
+ * Set the flush mode for this session.
+ * <p/>
+ * The flush mode determines the points at which the session is flushed.
+ * <i>Flushing</i> is the process of synchronizing the underlying persistent
+ * store with persistable state held in memory.
+ * <p/>
+ * For a logically "read only" session, it is reasonable to set the session's
+ * flush mode to {@link FlushMode#MANUAL} at the start of the session (in
* order to achieve some extra performance).
*
+ * @param flushMode the new flush mode
* @see FlushMode
- * @param flushMode the FlushMode
*/
public void setFlushMode(FlushMode flushMode);
+
/**
- * Get the current flush mode.
+ * Get the current flush mode for this session.
*
- * @return FlushMode
+ * @return The flush mode
*/
public FlushMode getFlushMode();
-
+
/**
* Set the cache mode.
+ * <p/>
+ * Cache mode determines the manner in which this session can interact with
+ * the second level cache.
+ *
+ * @param cacheMode The new cache mode.
*/
public void setCacheMode(CacheMode cacheMode);
+
/**
* Get the current cache mode.
+ *
+ * @return The current cache mode.
*/
public CacheMode getCacheMode();
/**
- * Get the <tt>SessionFactory</tt> that created this instance.
+ * Get the session factory which created this session.
+ *
+ * @return The session factory.
* @see SessionFactory
+
*/
public SessionFactory getSessionFactory();
/**
* Get the JDBC connection of this Session.<br>
- * <br>
+ * <br>
* If the session is using aggressive collection release (as in a
* CMT environment), it is the application's responsibility to
* close the connection returned by this call. Otherwise, the
@@ -143,49 +162,53 @@
public Connection connection() throws HibernateException;
/**
- * End the <tt>Session</tt> by disconnecting from the JDBC connection and
- * cleaning up. It is not strictly necessary to <tt>close()</tt> the
- * <tt>Session</tt> but you must at least <tt>disconnect()</tt> it.
+ * End the session by releasing the JDBC connection and cleaning up. It is
+ * not strictly necessary to close the session but you must at least
+ * {@link #disconnect()} it.
*
- * @return the connection provided by the application
- * or <tt>null</tt>
- * @throws HibernateException
+ * @return the connection provided by the application or null.
+ * @throws HibernateException Indicates problems cleaning up.
*/
public Connection close() throws HibernateException;
/**
- * Cancel execution of the current query. May be called from one thread
- * to stop execution of a query in another thread. Use with care!
+ * Cancel the execution of the current query.
+ * <p/>
+ * This is the sole method on session which may be safely called from
+ * another thread.
+ *
+ * @throws HibernateException There was a problem canceling the query
*/
public void cancelQuery() throws HibernateException;
/**
- * Check if the <tt>Session</tt> is still open.
+ * Check if the session is still open.
*
* @return boolean
*/
public boolean isOpen();
/**
- * Check if the <tt>Session</tt> is currently connected.
+ * Check if the session is currently connected.
*
* @return boolean
*/
public boolean isConnected();
-
+
/**
- * Does this <tt>Session</tt> contain any changes which must be
- * synchronized with the database? Would any SQL be executed if
+ * Does this session contain any changes which must be synchronized with
+ * the database? In other words, would any DML operations be executed if
* we flushed this session?
*
- * @return boolean
+ * @return True if the session contains pending changes; false otherwise.
+ * @throws HibernateException could not perform dirtying checking
*/
public boolean isDirty() throws HibernateException;
/**
- * Return the identifier of an entity instance cached by the <tt>Session</tt>, or
- * throw an exception if the instance is transient or associated with a different
- * <tt>Session</tt>.
+ * Return the identifier value of the given entity as associated with this
+ * session. An exception is thrown if the given entity instance is transient
+ * or detached in relation to this session.
*
* @param object a persistent instance
* @return the identifier
@@ -193,6 +216,7 @@
* a different session
*/
public Serializable getIdentifier(Object object) throws HibernateException;
+
/**
* Check if this instance is associated with this <tt>Session</tt>.
*
@@ -200,6 +224,7 @@
* @return true if the given instance is associated with this <tt>Session</tt>
*/
public boolean contains(Object object);
+
/**
* Remove this instance from the session cache. Changes to the instance will
* not be synchronized with the database. This operation cascades to associated
@@ -277,8 +302,8 @@
public void load(Object object, Serializable id) throws HibernateException;
/**
- * Persist the state of the given detached instance, reusing the current
- * identifier value. This operation cascades to associated instances if
+ * Persist the state of the given detached instance, reusing the current
+ * identifier value. This operation cascades to associated instances if
* the association is mapped with <tt>cascade="replicate"</tt>.
*
* @param object a detached instance of a persistent class
@@ -286,8 +311,8 @@
public void replicate(Object object, ReplicationMode replicationMode) throws HibernateException;
/**
- * Persist the state of the given detached instance, reusing the current
- * identifier value. This operation cascades to associated instances if
+ * Persist the state of the given detached instance, reusing the current
+ * identifier value. This operation cascades to associated instances if
* the association is mapped with <tt>cascade="replicate"</tt>.
*
* @param object a detached instance of a persistent class
@@ -297,7 +322,7 @@
/**
* Persist the given transient instance, first assigning a generated identifier. (Or
* using the current value of the identifier property if the <tt>assigned</tt>
- * generator is used.) This operation cascades to associated instances if the
+ * generator is used.) This operation cascades to associated instances if the
* association is mapped with <tt>cascade="save-update"</tt>.
*
* @param object a transient instance of a persistent class
@@ -309,7 +334,7 @@
/**
* Persist the given transient instance, first assigning a generated identifier. (Or
* using the current value of the identifier property if the <tt>assigned</tt>
- * generator is used.) This operation cascades to associated instances if the
+ * generator is used.) This operation cascades to associated instances if the
* association is mapped with <tt>cascade="save-update"</tt>.
*
* @param object a transient instance of a persistent class
@@ -319,10 +344,11 @@
public Serializable save(String entityName, Object object) throws HibernateException;
/**
- * Either <tt>save()</tt> or <tt>update()</tt> the given instance, depending upon the value of
- * its identifier property. By default the instance is always saved. This behaviour may be
- * adjusted by specifying an <tt>unsaved-value</tt> attribute of the identifier property
- * mapping. This operation cascades to associated instances if the association is mapped
+ * Either {@link #save(Object)} or {@link #update(Object)} the given
+ * instance, depending upon resolution of the unsaved-value checks (see the
+ * manual for discussion of unsaved-value checking).
+ * <p/>
+ * This operation cascades to associated instances if the association is mapped
* with <tt>cascade="save-update"</tt>.
*
* @see Session#save(java.lang.Object)
@@ -333,14 +359,15 @@
public void saveOrUpdate(Object object) throws HibernateException;
/**
- * Either <tt>save()</tt> or <tt>update()</tt> the given instance, depending upon the value of
- * its identifier property. By default the instance is always saved. This behaviour may be
- * adjusted by specifying an <tt>unsaved-value</tt> attribute of the identifier property
- * mapping. This operation cascades to associated instances if the association is mapped
+ * Either {@link #save(String, Object)} or {@link #update(String, Object)}
+ * the given instance, depending upon resolution of the unsaved-value checks
+ * (see the manual for discussion of unsaved-value checking).
+ * <p/>
+ * This operation cascades to associated instances if the association is mapped
* with <tt>cascade="save-update"</tt>.
*
- * @see Session#save(java.lang.Object)
- * @see Session#update(Object object)
+ * @see Session#save(String,Object)
+ * @see Session#update(String,Object)
* @param object a transient or detached instance containing new or updated state
* @throws HibernateException
*/
@@ -349,7 +376,7 @@
/**
* Update the persistent instance with the identifier of the given detached
* instance. If there is a persistent instance with the same identifier,
- * an exception is thrown. This operation cascades to associated instances
+ * an exception is thrown. This operation cascades to associated instances
* if the association is mapped with <tt>cascade="save-update"</tt>.
*
* @param object a detached instance containing updated state
@@ -360,7 +387,7 @@
/**
* Update the persistent instance with the identifier of the given detached
* instance. If there is a persistent instance with the same identifier,
- * an exception is thrown. This operation cascades to associated instances
+ * an exception is thrown. This operation cascades to associated instances
* if the association is mapped with <tt>cascade="save-update"</tt>.
*
* @param object a detached instance containing updated state
@@ -372,9 +399,9 @@
* Copy the state of the given object onto the persistent object with the same
* identifier. If there is no persistent instance currently associated with
* the session, it will be loaded. Return the persistent instance. If the
- * given instance is unsaved, save a copy of and return it as a newly persistent
- * instance. The given instance does not become associated with the session.
- * This operation cascades to associated instances if the association is mapped
+ * given instance is unsaved, save a copy of and return it as a newly persistent
+ * instance. The given instance does not become associated with the session.
+ * This operation cascades to associated instances if the association is mapped
* with <tt>cascade="merge"</tt>.<br>
* <br>
* The semantics of this method are defined by JSR-220.
@@ -383,14 +410,14 @@
* @return an updated persistent instance
*/
public Object merge(Object object) throws HibernateException;
-
+
/**
* Copy the state of the given object onto the persistent object with the same
* identifier. If there is no persistent instance currently associated with
* the session, it will be loaded. Return the persistent instance. If the
- * given instance is unsaved, save a copy of and return it as a newly persistent
- * instance. The given instance does not become associated with the session.
- * This operation cascades to associated instances if the association is mapped
+ * given instance is unsaved, save a copy of and return it as a newly persistent
+ * instance. The given instance does not become associated with the session.
+ * This operation cascades to associated instances if the association is mapped
* with <tt>cascade="merge"</tt>.<br>
* <br>
* The semantics of this method are defined by JSR-220.
@@ -399,22 +426,22 @@
* @return an updated persistent instance
*/
public Object merge(String entityName, Object object) throws HibernateException;
-
+
/**
- * Make a transient instance persistent. This operation cascades to associated
+ * Make a transient instance persistent. This operation cascades to associated
* instances if the association is mapped with <tt>cascade="persist"</tt>.<br>
* <br>
* The semantics of this method are defined by JSR-220.
- *
+ *
* @param object a transient instance to be made persistent
*/
public void persist(Object object) throws HibernateException;
/**
- * Make a transient instance persistent. This operation cascades to associated
+ * Make a transient instance persistent. This operation cascades to associated
* instances if the association is mapped with <tt>cascade="persist"</tt>.<br>
* <br>
* The semantics of this method are defined by JSR-220.
- *
+ *
* @param object a transient instance to be made persistent
*/
public void persist(String entityName, Object object) throws HibernateException;
@@ -422,8 +449,8 @@
/**
* Remove a persistent instance from the datastore. The argument may be
* an instance associated with the receiving <tt>Session</tt> or a transient
- * instance with an identifier associated with existing persistent state.
- * This operation cascades to associated instances if the association is mapped
+ * instance with an identifier associated with existing persistent state.
+ * This operation cascades to associated instances if the association is mapped
* with <tt>cascade="delete"</tt>.
*
* @param object the instance to be removed
@@ -448,7 +475,7 @@
* Obtain the specified lock level upon the given object. This may be used to
* perform a version check (<tt>LockMode.READ</tt>), to upgrade to a pessimistic
* lock (<tt>LockMode.UPGRADE</tt>), or to simply reassociate a transient instance
- * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
+ * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
* instances if the association is mapped with <tt>cascade="lock"</tt>.
*
* @param object a persistent or transient instance
@@ -461,7 +488,7 @@
* Obtain the specified lock level upon the given object. This may be used to
* perform a version check (<tt>LockMode.READ</tt>), to upgrade to a pessimistic
* lock (<tt>LockMode.UPGRADE</tt>), or to simply reassociate a transient instance
- * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
+ * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
* instances if the association is mapped with <tt>cascade="lock"</tt>.
*
* @param object a persistent or transient instance
@@ -519,7 +546,7 @@
* @see Transaction
*/
public Transaction beginTransaction() throws HibernateException;
-
+
/**
* Get the <tt>Transaction</tt> instance associated with this session.
* The class of the returned <tt>Transaction</tt> object is determined by the
@@ -539,7 +566,7 @@
* @return Criteria
*/
public Criteria createCriteria(Class persistentClass);
-
+
/**
* Create a new <tt>Criteria</tt> instance, for the given entity class,
* or a superclass of an entity class, with the given alias.
@@ -548,7 +575,7 @@
* @return Criteria
*/
public Criteria createCriteria(Class persistentClass, String alias);
-
+
/**
* Create a new <tt>Criteria</tt> instance, for the given entity name.
*
[View Less]
18 years, 3 months
Hibernate SVN: r10915 - branches/Branch_3_2/Hibernate3/src/org/hibernate
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-12-04 15:38:55 -0500 (Mon, 04 Dec 2006)
New Revision: 10915
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/Session.java
Log:
javadocs
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/Session.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/Session.java 2006-12-04 20:34:46 UTC (rev 10914)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/Session.…
[View More]java 2006-12-04 20:38:55 UTC (rev 10915)
@@ -349,8 +349,8 @@
* This operation cascades to associated instances if the association is mapped
* with <tt>cascade="save-update"</tt>.
*
- * @see Session#save(java.lang.Object)
- * @see org.hibernate.classic.Session#update(Object object, Serializable id)
+ * @see Session#save(Object)
+ * @see Session#update(Object)
* @param object a transient or detached instance containing new or updated state
* @throws HibernateException
*/
@@ -364,8 +364,8 @@
* This operation cascades to associated instances if the association is mapped
* with <tt>cascade="save-update"</tt>.
*
- * @see Session#save(java.lang.Object)
- * @see org.hibernate.classic.Session#update(Object object, Serializable id)
+ * @see Session#save(String,Object)
+ * @see Session#update(String,Object)
* @param entityName The name of the entity
* @param object a transient or detached instance containing new or updated state
* @throws HibernateException
[View Less]
18 years, 3 months
Hibernate SVN: r10914 - branches/Branch_3_2/Hibernate3/src/org/hibernate
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-12-04 15:34:46 -0500 (Mon, 04 Dec 2006)
New Revision: 10914
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/Session.java
Log:
javadocs
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/Session.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/Session.java 2006-12-04 20:32:20 UTC (rev 10913)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/Session.…
[View More]java 2006-12-04 20:34:46 UTC (rev 10914)
@@ -24,12 +24,12 @@
* <tt>persist()</tt> or <tt>saveOrUpdate()</tt>. Persistent instances may be made transient
* by calling<tt> delete()</tt>. Any instance returned by a <tt>get()</tt> or
* <tt>load()</tt> method is persistent. Detached instances may be made persistent
- * by calling <tt>update()</tt>, <tt>saveOrUpdate()</tt>, <tt>lock()</tt> or <tt>replicate()</tt>.
+ * by calling <tt>update()</tt>, <tt>saveOrUpdate()</tt>, <tt>lock()</tt> or <tt>replicate()</tt>.
* The state of a transient or detached instance may also be made persistent as a new
* persistent instance by calling <tt>merge()</tt>.<br>
* <br>
* <tt>save()</tt> and <tt>persist()</tt> result in an SQL <tt>INSERT</tt>, <tt>delete()</tt>
- * in an SQL <tt>DELETE</tt> and <tt>update()</tt> or <tt>merge()</tt> in an SQL <tt>UPDATE</tt>.
+ * in an SQL <tt>DELETE</tt> and <tt>update()</tt> or <tt>merge()</tt> in an SQL <tt>UPDATE</tt>.
* Changes to <i>persistent</i> instances are detected at flush time and also result in an SQL
* <tt>UPDATE</tt>. <tt>saveOrUpdate()</tt> and <tt>replicate()</tt> result in either an
* <tt>INSERT</tt> or an <tt>UPDATE</tt>.<br>
@@ -79,59 +79,78 @@
* Session inherits the connection, transaction, and other context
* information from the primary Session. It doesn't need to be flushed
* or closed by the developer.
- *
+ *
* @param entityMode The entity mode to use for the new session.
* @return The new session
*/
public Session getSession(EntityMode entityMode);
/**
- * Force the <tt>Session</tt> to flush. Must be called at the end of a
+ * Force this session to flush. Must be called at the end of a
* unit of work, before commiting the transaction and closing the
- * session (<tt>Transaction.commit()</tt> calls this method). <i>Flushing</i>
- * is the process of synchronising the underlying persistent store with
- * persistable state held in memory.
+ * session (depending on {@link #setFlushMode flush-mode},
+ * {@link Transaction#commit()} calls this method).
+ * <p/>
+ * <i>Flushing</i> is the process of synchronizing the underlying persistent
+ * store with persistable state held in memory.
*
- * @throws HibernateException
+ * @throws HibernateException Indicates problems flushing the session or
+ * talking to the database.
*/
public void flush() throws HibernateException;
/**
- * Set the flush mode. The flush mode determines at which points
- * Hibernate automatically flushes the session. For a readonly
- * session, it is reasonable to set the flush mode to
- * <tt>FlushMode.NEVER</tt> at the start of the session (in
+ * Set the flush mode for this session.
+ * <p/>
+ * The flush mode determines the points at which the session is flushed.
+ * <i>Flushing</i> is the process of synchronizing the underlying persistent
+ * store with persistable state held in memory.
+ * <p/>
+ * For a logically "read only" session, it is reasonable to set the session's
+ * flush mode to {@link FlushMode#MANUAL} at the start of the session (in
* order to achieve some extra performance).
*
+ * @param flushMode the new flush mode
* @see FlushMode
- * @param flushMode the FlushMode
*/
public void setFlushMode(FlushMode flushMode);
+
/**
- * Get the current flush mode.
+ * Get the current flush mode for this session.
*
- * @return FlushMode
+ * @return The flush mode
*/
public FlushMode getFlushMode();
-
+
/**
* Set the cache mode.
+ * <p/>
+ * Cache mode determines the manner in which this session can interact with
+ * the second level cache.
+ *
+ * @param cacheMode The new cache mode.
*/
public void setCacheMode(CacheMode cacheMode);
+
/**
* Get the current cache mode.
+ *
+ * @return The current cache mode.
*/
public CacheMode getCacheMode();
/**
- * Get the <tt>SessionFactory</tt> that created this instance.
+ * Get the session factory which created this session.
+ *
+ * @return The session factory.
* @see SessionFactory
+
*/
public SessionFactory getSessionFactory();
/**
* Get the JDBC connection of this Session.<br>
- * <br>
+ * <br>
* If the session is using aggressive collection release (as in a
* CMT environment), it is the application's responsibility to
* close the connection returned by this call. Otherwise, the
@@ -143,49 +162,53 @@
public Connection connection() throws HibernateException;
/**
- * End the <tt>Session</tt> by disconnecting from the JDBC connection and
- * cleaning up. It is not strictly necessary to <tt>close()</tt> the
- * <tt>Session</tt> but you must at least <tt>disconnect()</tt> it.
+ * End the session by releasing the JDBC connection and cleaning up. It is
+ * not strictly necessary to close the session but you must at least
+ * {@link #disconnect()} it.
*
- * @return the connection provided by the application
- * or <tt>null</tt>
- * @throws HibernateException
+ * @return the connection provided by the application or null.
+ * @throws HibernateException Indicates problems cleaning up.
*/
public Connection close() throws HibernateException;
/**
- * Cancel execution of the current query. May be called from one thread
- * to stop execution of a query in another thread. Use with care!
+ * Cancel the execution of the current query.
+ * <p/>
+ * This is the sole method on session which may be safely called from
+ * another thread.
+ *
+ * @throws HibernateException There was a problem canceling the query
*/
public void cancelQuery() throws HibernateException;
/**
- * Check if the <tt>Session</tt> is still open.
+ * Check if the session is still open.
*
* @return boolean
*/
public boolean isOpen();
/**
- * Check if the <tt>Session</tt> is currently connected.
+ * Check if the session is currently connected.
*
* @return boolean
*/
public boolean isConnected();
-
+
/**
- * Does this <tt>Session</tt> contain any changes which must be
- * synchronized with the database? Would any SQL be executed if
+ * Does this session contain any changes which must be synchronized with
+ * the database? In other words, would any DML operations be executed if
* we flushed this session?
*
- * @return boolean
+ * @return True if the session contains pending changes; false otherwise.
+ * @throws HibernateException could not perform dirtying checking
*/
public boolean isDirty() throws HibernateException;
/**
- * Return the identifier of an entity instance cached by the <tt>Session</tt>, or
- * throw an exception if the instance is transient or associated with a different
- * <tt>Session</tt>.
+ * Return the identifier value of the given entity as associated with this
+ * session. An exception is thrown if the given entity instance is transient
+ * or detached in relation to this session.
*
* @param object a persistent instance
* @return the identifier
@@ -193,6 +216,7 @@
* a different session
*/
public Serializable getIdentifier(Object object) throws HibernateException;
+
/**
* Check if this instance is associated with this <tt>Session</tt>.
*
@@ -200,6 +224,7 @@
* @return true if the given instance is associated with this <tt>Session</tt>
*/
public boolean contains(Object object);
+
/**
* Remove this instance from the session cache. Changes to the instance will
* not be synchronized with the database. This operation cascades to associated
@@ -236,8 +261,7 @@
/**
* Return the persistent instance of the given entity class with the given identifier,
- * assuming that the instance exists. This method might return a proxied instance that
- * is initialized on-demand, when a non-identifier method is accessed.
+ * assuming that the instance exists.
* <br><br>
* You should not use this method to determine if an instance exists (use <tt>get()</tt>
* instead). Use this only to retrieve an instance that you assume exists, where non-existence
@@ -252,8 +276,7 @@
/**
* Return the persistent instance of the given entity class with the given identifier,
- * assuming that the instance exists. This method might return a proxied instance that
- * is initialized on-demand, when a non-identifier method is accessed.
+ * assuming that the instance exists.
* <br><br>
* You should not use this method to determine if an instance exists (use <tt>get()</tt>
* instead). Use this only to retrieve an instance that you assume exists, where non-existence
@@ -277,8 +300,8 @@
public void load(Object object, Serializable id) throws HibernateException;
/**
- * Persist the state of the given detached instance, reusing the current
- * identifier value. This operation cascades to associated instances if
+ * Persist the state of the given detached instance, reusing the current
+ * identifier value. This operation cascades to associated instances if
* the association is mapped with <tt>cascade="replicate"</tt>.
*
* @param object a detached instance of a persistent class
@@ -286,8 +309,8 @@
public void replicate(Object object, ReplicationMode replicationMode) throws HibernateException;
/**
- * Persist the state of the given detached instance, reusing the current
- * identifier value. This operation cascades to associated instances if
+ * Persist the state of the given detached instance, reusing the current
+ * identifier value. This operation cascades to associated instances if
* the association is mapped with <tt>cascade="replicate"</tt>.
*
* @param object a detached instance of a persistent class
@@ -297,7 +320,7 @@
/**
* Persist the given transient instance, first assigning a generated identifier. (Or
* using the current value of the identifier property if the <tt>assigned</tt>
- * generator is used.) This operation cascades to associated instances if the
+ * generator is used.) This operation cascades to associated instances if the
* association is mapped with <tt>cascade="save-update"</tt>.
*
* @param object a transient instance of a persistent class
@@ -309,7 +332,7 @@
/**
* Persist the given transient instance, first assigning a generated identifier. (Or
* using the current value of the identifier property if the <tt>assigned</tt>
- * generator is used.) This operation cascades to associated instances if the
+ * generator is used.) This operation cascades to associated instances if the
* association is mapped with <tt>cascade="save-update"</tt>.
*
* @param object a transient instance of a persistent class
@@ -319,28 +342,31 @@
public Serializable save(String entityName, Object object) throws HibernateException;
/**
- * Either <tt>save()</tt> or <tt>update()</tt> the given instance, depending upon the value of
- * its identifier property. By default the instance is always saved. This behaviour may be
- * adjusted by specifying an <tt>unsaved-value</tt> attribute of the identifier property
- * mapping. This operation cascades to associated instances if the association is mapped
+ * Either {@link #save(Object)} or {@link #update(Object)} the given
+ * instance, depending upon resolution of the unsaved-value checks (see the
+ * manual for discussion of unsaved-value checking).
+ * <p/>
+ * This operation cascades to associated instances if the association is mapped
* with <tt>cascade="save-update"</tt>.
*
* @see Session#save(java.lang.Object)
- * @see Session#update(Object object)
+ * @see org.hibernate.classic.Session#update(Object object, Serializable id)
* @param object a transient or detached instance containing new or updated state
* @throws HibernateException
*/
public void saveOrUpdate(Object object) throws HibernateException;
/**
- * Either <tt>save()</tt> or <tt>update()</tt> the given instance, depending upon the value of
- * its identifier property. By default the instance is always saved. This behaviour may be
- * adjusted by specifying an <tt>unsaved-value</tt> attribute of the identifier property
- * mapping. This operation cascades to associated instances if the association is mapped
+ * Either {@link #save(String, Object)} or {@link #update(String, Object)}
+ * the given instance, depending upon resolution of the unsaved-value checks
+ * (see the manual for discussion of unsaved-value checking).
+ * <p/>
+ * This operation cascades to associated instances if the association is mapped
* with <tt>cascade="save-update"</tt>.
*
* @see Session#save(java.lang.Object)
- * @see Session#update(Object object)
+ * @see org.hibernate.classic.Session#update(Object object, Serializable id)
+ * @param entityName The name of the entity
* @param object a transient or detached instance containing new or updated state
* @throws HibernateException
*/
@@ -349,7 +375,7 @@
/**
* Update the persistent instance with the identifier of the given detached
* instance. If there is a persistent instance with the same identifier,
- * an exception is thrown. This operation cascades to associated instances
+ * an exception is thrown. This operation cascades to associated instances
* if the association is mapped with <tt>cascade="save-update"</tt>.
*
* @param object a detached instance containing updated state
@@ -360,7 +386,7 @@
/**
* Update the persistent instance with the identifier of the given detached
* instance. If there is a persistent instance with the same identifier,
- * an exception is thrown. This operation cascades to associated instances
+ * an exception is thrown. This operation cascades to associated instances
* if the association is mapped with <tt>cascade="save-update"</tt>.
*
* @param object a detached instance containing updated state
@@ -372,9 +398,9 @@
* Copy the state of the given object onto the persistent object with the same
* identifier. If there is no persistent instance currently associated with
* the session, it will be loaded. Return the persistent instance. If the
- * given instance is unsaved, save a copy of and return it as a newly persistent
- * instance. The given instance does not become associated with the session.
- * This operation cascades to associated instances if the association is mapped
+ * given instance is unsaved, save a copy of and return it as a newly persistent
+ * instance. The given instance does not become associated with the session.
+ * This operation cascades to associated instances if the association is mapped
* with <tt>cascade="merge"</tt>.<br>
* <br>
* The semantics of this method are defined by JSR-220.
@@ -383,14 +409,14 @@
* @return an updated persistent instance
*/
public Object merge(Object object) throws HibernateException;
-
+
/**
* Copy the state of the given object onto the persistent object with the same
* identifier. If there is no persistent instance currently associated with
* the session, it will be loaded. Return the persistent instance. If the
- * given instance is unsaved, save a copy of and return it as a newly persistent
- * instance. The given instance does not become associated with the session.
- * This operation cascades to associated instances if the association is mapped
+ * given instance is unsaved, save a copy of and return it as a newly persistent
+ * instance. The given instance does not become associated with the session.
+ * This operation cascades to associated instances if the association is mapped
* with <tt>cascade="merge"</tt>.<br>
* <br>
* The semantics of this method are defined by JSR-220.
@@ -399,22 +425,22 @@
* @return an updated persistent instance
*/
public Object merge(String entityName, Object object) throws HibernateException;
-
+
/**
- * Make a transient instance persistent. This operation cascades to associated
+ * Make a transient instance persistent. This operation cascades to associated
* instances if the association is mapped with <tt>cascade="persist"</tt>.<br>
* <br>
* The semantics of this method are defined by JSR-220.
- *
+ *
* @param object a transient instance to be made persistent
*/
public void persist(Object object) throws HibernateException;
/**
- * Make a transient instance persistent. This operation cascades to associated
+ * Make a transient instance persistent. This operation cascades to associated
* instances if the association is mapped with <tt>cascade="persist"</tt>.<br>
* <br>
* The semantics of this method are defined by JSR-220.
- *
+ *
* @param object a transient instance to be made persistent
*/
public void persist(String entityName, Object object) throws HibernateException;
@@ -422,8 +448,8 @@
/**
* Remove a persistent instance from the datastore. The argument may be
* an instance associated with the receiving <tt>Session</tt> or a transient
- * instance with an identifier associated with existing persistent state.
- * This operation cascades to associated instances if the association is mapped
+ * instance with an identifier associated with existing persistent state.
+ * This operation cascades to associated instances if the association is mapped
* with <tt>cascade="delete"</tt>.
*
* @param object the instance to be removed
@@ -448,7 +474,7 @@
* Obtain the specified lock level upon the given object. This may be used to
* perform a version check (<tt>LockMode.READ</tt>), to upgrade to a pessimistic
* lock (<tt>LockMode.UPGRADE</tt>), or to simply reassociate a transient instance
- * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
+ * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
* instances if the association is mapped with <tt>cascade="lock"</tt>.
*
* @param object a persistent or transient instance
@@ -461,7 +487,7 @@
* Obtain the specified lock level upon the given object. This may be used to
* perform a version check (<tt>LockMode.READ</tt>), to upgrade to a pessimistic
* lock (<tt>LockMode.UPGRADE</tt>), or to simply reassociate a transient instance
- * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
+ * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
* instances if the association is mapped with <tt>cascade="lock"</tt>.
*
* @param object a persistent or transient instance
@@ -519,7 +545,7 @@
* @see Transaction
*/
public Transaction beginTransaction() throws HibernateException;
-
+
/**
* Get the <tt>Transaction</tt> instance associated with this session.
* The class of the returned <tt>Transaction</tt> object is determined by the
@@ -539,7 +565,7 @@
* @return Criteria
*/
public Criteria createCriteria(Class persistentClass);
-
+
/**
* Create a new <tt>Criteria</tt> instance, for the given entity class,
* or a superclass of an entity class, with the given alias.
@@ -548,7 +574,7 @@
* @return Criteria
*/
public Criteria createCriteria(Class persistentClass, String alias);
-
+
/**
* Create a new <tt>Criteria</tt> instance, for the given entity name.
*
@@ -613,8 +639,8 @@
/**
* Return the persistent instance of the given entity class with the given identifier,
- * or null if there is no such persistent instance. (If the instance is already associated
- * with the session, return that instance. This method never returns an uninitialized instance.)
+ * or null if there is no such persistent instance. (If the instance, or a proxy for the
+ * instance, is already associated with the session, return that instance or proxy.)
*
* @param clazz a persistent class
* @param id an identifier
@@ -625,9 +651,8 @@
/**
* Return the persistent instance of the given entity class with the given identifier,
- * or null if there is no such persistent instance. (If the instance is already associated
- * with the session, return that instance. This method never returns an uninitialized instance.)
- * Obtain the specified lock mode if the instance exists.
+ * or null if there is no such persistent instance. Obtain the specified lock mode
+ * if the instance exists.
*
* @param clazz a persistent class
* @param id an identifier
@@ -639,8 +664,8 @@
/**
* Return the persistent instance of the given named entity with the given identifier,
- * or null if there is no such persistent instance. (If the instance is already associated
- * with the session, return that instance. This method never returns an uninitialized instance.)
+ * or null if there is no such persistent instance. (If the instance, or a proxy for the
+ * instance, is already associated with the session, return that instance or proxy.)
*
* @param entityName the entity name
* @param id an identifier
@@ -651,9 +676,8 @@
/**
* Return the persistent instance of the given entity class with the given identifier,
- * or null if there is no such persistent instance. (If the instance is already associated
- * with the session, return that instance. This method never returns an uninitialized instance.)
- * Obtain the specified lock mode if the instance exists.
+ * or null if there is no such persistent instance. Obtain the specified lock mode
+ * if the instance exists.
*
* @param entityName the entity name
* @param id an identifier
@@ -663,10 +687,10 @@
*/
public Object get(String entityName, Serializable id, LockMode lockMode) throws HibernateException;
-
+
/**
* Return the entity name for a persistent entity
- *
+ *
* @param object a persistent entity
* @return the entity name
* @throws HibernateException
@@ -695,17 +719,17 @@
* @param filterName The name of the filter to be disabled.
*/
public void disableFilter(String filterName);
-
+
/**
* Get the statistics for this session.
*/
public SessionStatistics getStatistics();
-
+
/**
* Set an unmodified persistent object to read only mode, or a read only
* object to modifiable mode. In read only mode, no snapshot is maintained
* and the instance is never dirty checked.
- *
+ *
* @see Query#setReadOnly(boolean)
*/
public void setReadOnly(Object entity, boolean readOnly);
[View Less]
18 years, 3 months
Hibernate SVN: r10913 - branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-12-04 15:32:20 -0500 (Mon, 04 Dec 2006)
New Revision: 10913
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/AddressBook.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java
Log:
more tests
Modified: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/AddressBook.java
==============================…
[View More]=====================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/AddressBook.java 2006-12-04 17:10:27 UTC (rev 10912)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/AddressBook.java 2006-12-04 20:32:20 UTC (rev 10913)
@@ -9,6 +9,7 @@
import javax.persistence.Id;
import javax.persistence.MapKey;
import javax.persistence.OneToMany;
+import javax.persistence.JoinTable;
/**
* @author Emmanuel Bernard
@@ -61,6 +62,7 @@
@MapKey(name = "directory")
@OneToMany(mappedBy = "book")
+ @JoinTable(name="Dir_Entry")
public Map<AlphabeticalDirectory, AddressEntry> getDirectoryEntries() {
return directoryEntries;
}
Modified: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java 2006-12-04 17:10:27 UTC (rev 10912)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java 2006-12-04 20:32:20 UTC (rev 10913)
@@ -395,6 +395,32 @@
s.close();
}
+ public void testMapKeyEntityEntity() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ AddressBook book = new AddressBook();
+ s.persist( book );
+ AddressEntry entry = new AddressEntry();
+ entry.setCity( "Atlanta");
+ AddressEntryPk pk = new AddressEntryPk("Coca", "Cola" );
+ entry.setPerson( pk );
+ entry.setBook( book );
+ AlphabeticalDirectory ad = new AlphabeticalDirectory();
+ ad.setName( "C");
+ s.persist( ad );
+ entry.setDirectory( ad );
+ s.persist( entry );
+ book.getDirectoryEntries().put( ad, entry );
+ s.flush();
+ s.clear();
+
+ book = (AddressBook) s.get( AddressBook.class, book.getId() );
+ assertEquals( 1, book.getDirectoryEntries().size() );
+ assertEquals( "C", book.getDirectoryEntries().keySet().iterator().next().getName() );
+ tx.rollback();
+ s.close();
+ }
+
public void testEntityKeyElementTarget() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
[View Less]
18 years, 3 months
Hibernate SVN: r10912 - in branches/Branch_3_2/HibernateExt/ejb: . lib src/java/org/hibernate/ejb src/java/org/hibernate/ejb/packaging src/test/org/hibernate/ejb/test src/test/org/hibernate/ejb/test/pack src/test/org/hibernate/ejb/test/pack/overridenpar src/test-resources src/test-resources/overridenpar src/test-resources/overridenpar/META-INF
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-12-04 12:10:27 -0500 (Mon, 04 Dec 2006)
New Revision: 10912
Added:
branches/Branch_3_2/HibernateExt/ejb/src/test-resources/overridenpar/
branches/Branch_3_2/HibernateExt/ejb/src/test-resources/overridenpar/META-INF/
branches/Branch_3_2/HibernateExt/ejb/src/test-resources/overridenpar/META-INF/persistence.xml
branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/overridenpar/
branches/Branch_3_2/HibernateExt/ejb/src/test/org/…
[View More]hibernate/ejb/test/pack/overridenpar/Bug.java
Modified:
branches/Branch_3_2/HibernateExt/ejb/build.xml
branches/Branch_3_2/HibernateExt/ejb/lib/hibernate-annotations.jar
branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java
branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/PersistenceMetadata.java
branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java
branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/PackagedEntityManagerTest.java
Log:
EJB-254 overriding DS is possible
Modified: branches/Branch_3_2/HibernateExt/ejb/build.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/ejb/build.xml 2006-12-01 21:57:11 UTC (rev 10911)
+++ branches/Branch_3_2/HibernateExt/ejb/build.xml 2006-12-04 17:10:27 UTC (rev 10912)
@@ -109,6 +109,10 @@
<param name="extension" value="par"/>
<param name="jarname" value="cfgxmlpar"/>
</antcall>
+ <antcall target="packjar" inheritall="true">
+ <param name="extension" value="jar"/>
+ <param name="jarname" value="overridenpar"/>
+ </antcall>
<antcall target="packexploded" inheritall="true">
<param name="extension" value="par"/>
Modified: branches/Branch_3_2/HibernateExt/ejb/lib/hibernate-annotations.jar
===================================================================
(Binary files differ)
Modified: branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java
===================================================================
--- branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java 2006-12-01 21:57:11 UTC (rev 10911)
+++ branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java 2006-12-04 17:10:27 UTC (rev 10912)
@@ -174,7 +174,12 @@
}
Properties props = new Properties();
props.putAll( metadata.getProps() );
- if ( overrides != null ) props.putAll( overrides ); //yuk!
+ if ( overrides != null ) {
+ for ( Map.Entry entry : (Set<Map.Entry>) overrides.entrySet() ) {
+ Object value = entry.getValue();
+ props.put( entry.getKey(), value == null ? "" : value ); //alter null, not allowed in properties
+ }
+ }
configure( props, workingVars );
return this;
}
@@ -358,14 +363,14 @@
//datasources
Boolean isJTA = null;
boolean overridenDatasource = false;
- String dataSource = (String) integration.get( HibernatePersistence.JTA_DATASOURCE );
- if ( dataSource != null ) {
+ if ( integration.containsKey( HibernatePersistence.JTA_DATASOURCE ) ) {
+ String dataSource = (String) integration.get( HibernatePersistence.JTA_DATASOURCE );
overridenDatasource = true;
properties.setProperty( Environment.DATASOURCE, dataSource );
isJTA = Boolean.TRUE;
}
- dataSource = (String) integration.get( HibernatePersistence.NON_JTA_DATASOURCE );
- if ( dataSource != null ) {
+ if ( integration.containsKey( HibernatePersistence.NON_JTA_DATASOURCE ) ) {
+ String dataSource = (String) integration.get( HibernatePersistence.NON_JTA_DATASOURCE );
overridenDatasource = true;
properties.setProperty( Environment.DATASOURCE, dataSource );
if (isJTA == null) isJTA = Boolean.FALSE;
Modified: branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/PersistenceMetadata.java
===================================================================
--- branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/PersistenceMetadata.java 2006-12-01 21:57:11 UTC (rev 10911)
+++ branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/PersistenceMetadata.java 2006-12-04 17:10:27 UTC (rev 10912)
@@ -21,7 +21,7 @@
private String nonJtaDatasource;
private String jtaDatasource;
private String provider;
- private PersistenceUnitTransactionType transactionType = PersistenceUnitTransactionType.JTA;
+ private PersistenceUnitTransactionType transactionType;
private List<String> classes = new ArrayList<String>();
private List<String> packages = new ArrayList<String>();
private List<String> mappingFiles = new ArrayList<String>();
Modified: branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java
===================================================================
--- branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java 2006-12-01 21:57:11 UTC (rev 10911)
+++ branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java 2006-12-04 17:10:27 UTC (rev 10912)
@@ -81,22 +81,48 @@
if ( tag.equals( "persistence-unit" ) ) {
PersistenceMetadata metadata = parsePersistenceUnit( element );
//override properties of metadata if needed
- String provider = (String) overrides.get( HibernatePersistence.PROVIDER );
- if ( provider != null ) {
+ if ( overrides.containsKey( HibernatePersistence.PROVIDER ) ) {
+ String provider = (String) overrides.get( HibernatePersistence.PROVIDER );
metadata.setProvider( provider );
}
- String transactionType = (String) overrides.get( HibernatePersistence.TRANSACTION_TYPE );
- if ( StringHelper.isNotEmpty( transactionType ) ) {
+ if ( overrides.containsKey( HibernatePersistence.TRANSACTION_TYPE ) ) {
+ String transactionType = (String) overrides.get( HibernatePersistence.TRANSACTION_TYPE );
metadata.setTransactionType( PersistenceXmlLoader.getTransactionType( transactionType ) );
}
- String dataSource = (String) overrides.get( HibernatePersistence.JTA_DATASOURCE );
- if ( dataSource != null ) {
+ if ( overrides.containsKey( HibernatePersistence.JTA_DATASOURCE ) ) {
+ String dataSource = (String) overrides.get( HibernatePersistence.JTA_DATASOURCE );
metadata.setJtaDatasource( dataSource );
}
- dataSource = (String) overrides.get( HibernatePersistence.NON_JTA_DATASOURCE );
- if ( dataSource != null ) {
+ if ( overrides.containsKey( HibernatePersistence.NON_JTA_DATASOURCE ) ) {
+ String dataSource = (String) overrides.get( HibernatePersistence.NON_JTA_DATASOURCE );
metadata.setNonJtaDatasource( dataSource );
}
+ /*
+ * if explicit => use it
+ * if JTA DS => JTA transaction
+ * if non JTA DA => RESOURCE_LOCAL transaction
+ * else default JavaSE => RESOURCE_LOCAL
+ */
+ PersistenceUnitTransactionType transactionType = metadata.getTransactionType();
+ Boolean isJTA = null;
+ if ( StringHelper.isNotEmpty( metadata.getJtaDatasource() ) ) {
+ isJTA = Boolean.TRUE;
+ }
+ else if ( StringHelper.isNotEmpty( metadata.getNonJtaDatasource() ) ) {
+ isJTA = Boolean.FALSE;
+ }
+ if (transactionType == null) {
+ if (isJTA == Boolean.TRUE) {
+ transactionType = PersistenceUnitTransactionType.JTA;
+ }
+ else if (isJTA == Boolean.FALSE) {
+ transactionType = PersistenceUnitTransactionType.RESOURCE_LOCAL;
+ }
+ else {
+ transactionType = PersistenceUnitTransactionType.RESOURCE_LOCAL;
+ }
+ }
+ metadata.setTransactionType( transactionType );
Properties properties = metadata.getProps();
ConfigurationHelper.overrideProperties( properties, overrides );
units.add( metadata );
@@ -116,7 +142,6 @@
metadata.setName( puName );
}
NodeList children = top.getChildNodes();
- Boolean isJTA = null;
for ( int i = 0; i < children.getLength() ; i++ ) {
if ( children.item( i ).getNodeType() == Node.ELEMENT_NODE ) {
Element element = (Element) children.item( i );
@@ -129,11 +154,9 @@
// else
if ( tag.equals( "non-jta-data-source" ) ) {
metadata.setNonJtaDatasource( XmlHelper.getElementContent( element ) );
- if (isJTA == null) isJTA = Boolean.FALSE;
}
else if ( tag.equals( "jta-data-source" ) ) {
metadata.setJtaDatasource( XmlHelper.getElementContent( element ) );
- isJTA = Boolean.TRUE;
}
else if ( tag.equals( "provider" ) ) {
metadata.setProvider( XmlHelper.getElementContent( element ) );
@@ -169,25 +192,8 @@
}
}
}
- /*
- * if explicit => use it
- * if JTA DS => JTA transaction
- * if non JTA DA => RESULRCE_LOCAL transaction
- * else default JavaSE => RESOURCE_LOCAL
- */
PersistenceUnitTransactionType transactionType = getTransactionType( top.getAttribute( "transaction-type" ) );
- if (transactionType == null) {
- if (isJTA == Boolean.TRUE) {
- transactionType = PersistenceUnitTransactionType.JTA;
- }
- else if (isJTA == Boolean.FALSE) {
- transactionType = PersistenceUnitTransactionType.RESOURCE_LOCAL;
- }
- else {
- transactionType = PersistenceUnitTransactionType.RESOURCE_LOCAL;
- }
- }
- metadata.setTransactionType( transactionType );
+ if (transactionType != null) metadata.setTransactionType( transactionType );
return metadata;
}
Modified: branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/PackagedEntityManagerTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/PackagedEntityManagerTest.java 2006-12-01 21:57:11 UTC (rev 10911)
+++ branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/PackagedEntityManagerTest.java 2006-12-04 17:10:27 UTC (rev 10912)
@@ -8,6 +8,7 @@
import javax.persistence.PersistenceException;
import org.hibernate.ejb.HibernateEntityManagerFactory;
+import org.hibernate.ejb.HibernatePersistence;
import org.hibernate.ejb.test.pack.cfgxmlpar.Morito;
import org.hibernate.ejb.test.pack.defaultpar.ApplicationServer;
import org.hibernate.ejb.test.pack.defaultpar.IncrementListener;
@@ -190,6 +191,27 @@
emf.close();
}
+ public void testOverridenPar() throws Exception {
+ HashMap properties = new HashMap();
+ properties.put( HibernatePersistence.JTA_DATASOURCE, null );
+ properties.put( "hibernate.connection.driver_class", "org.hsqldb.jdbcDriver" );
+ properties.put( "hibernate.connection.username", "sa" );
+ properties.put( "hibernate.connection.password", "" );
+ properties.put( "hibernate.connection.url", "jdbc:hsqldb:." );
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory( "overridenpar", properties );
+ EntityManager em = emf.createEntityManager();
+ org.hibernate.ejb.test.pack.overridenpar.Bug bug = new org.hibernate.ejb.test.pack.overridenpar.Bug();
+ bug.setSubject( "Allow DS overriding");
+ em.getTransaction().begin();
+ em.persist( bug );
+ em.flush();
+ em.remove( bug );
+ assertNotNull( bug.getId() );
+ em.getTransaction().rollback();
+ em.close();
+ emf.close();
+ }
+
public void testListenersOverridingCfgXmlPar() throws Exception {
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "cfgxmlpar", new HashMap() );
EntityManager em = emf.createEntityManager();
Added: branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/overridenpar/Bug.java
===================================================================
--- branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/overridenpar/Bug.java 2006-12-01 21:57:11 UTC (rev 10911)
+++ branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/overridenpar/Bug.java 2006-12-04 17:10:27 UTC (rev 10912)
@@ -0,0 +1,42 @@
+//$Id: $
+package org.hibernate.ejb.test.pack.overridenpar;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Bug {
+ @Id
+ @GeneratedValue
+ private Long id;
+ private String subject;
+ private String comment;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getSubject() {
+ return subject;
+ }
+
+ public void setSubject(String subject) {
+ this.subject = subject;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+}
Added: branches/Branch_3_2/HibernateExt/ejb/src/test-resources/overridenpar/META-INF/persistence.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/ejb/src/test-resources/overridenpar/META-INF/persistence.xml 2006-12-01 21:57:11 UTC (rev 10911)
+++ branches/Branch_3_2/HibernateExt/ejb/src/test-resources/overridenpar/META-INF/persistence.xml 2006-12-04 17:10:27 UTC (rev 10912)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+ <persistence-unit name="overridenpar">
+ <jta-data-source>java:/unreachableDS</jta-data-source>
+ <properties>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
+ </properties>
+ </persistence-unit>
+</persistence>
[View Less]
18 years, 3 months
Hibernate SVN: r10911 - in branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb: . packaging
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-12-01 16:57:11 -0500 (Fri, 01 Dec 2006)
New Revision: 10911
Modified:
branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java
branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java
Log:
EJB-246 adjust transaction type if jta-ds or non-jta-ds is used and not tx type is explicitly set
Modified: branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java
======…
[View More]=============================================================
--- branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java 2006-12-01 21:03:43 UTC (rev 10910)
+++ branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java 2006-12-01 21:57:11 UTC (rev 10911)
@@ -325,13 +325,8 @@
// defineTransactionType( overridenTxType, info.getPersistenceUnitName() );
// }
// else {
+ // }
- PersistenceUnitTransactionType transactionType = info.getTransactionType();
- //in JavaEE the default is JTA
- transactionType = transactionType != null ? transactionType : PersistenceUnitTransactionType.JTA;
- defineTransactionType( transactionType, workingVars );
- // }
- //workingVars.put( HibernatePersistence.TRANSACTION_TYPE, transactionType );
boolean[] detectArtifactForOtherJars = getDetectedArtifacts( info.getProperties(), null, false );
boolean[] detectArtifactForMainJar = getDetectedArtifacts( info.getProperties(), null, info.excludeUnlistedClasses() );
for ( URL jar : info.getJarFileUrls() ) {
@@ -361,27 +356,49 @@
if ( hbmFiles.size() > 0 ) workingVars.put( HibernatePersistence.HBXML_FILES, hbmFiles );
//datasources
+ Boolean isJTA = null;
boolean overridenDatasource = false;
String dataSource = (String) integration.get( HibernatePersistence.JTA_DATASOURCE );
if ( dataSource != null ) {
overridenDatasource = true;
properties.setProperty( Environment.DATASOURCE, dataSource );
+ isJTA = Boolean.TRUE;
}
dataSource = (String) integration.get( HibernatePersistence.NON_JTA_DATASOURCE );
if ( dataSource != null ) {
overridenDatasource = true;
properties.setProperty( Environment.DATASOURCE, dataSource );
+ if (isJTA == null) isJTA = Boolean.FALSE;
}
if ( ! overridenDatasource && ( info.getJtaDataSource() != null || info.getNonJtaDataSource() != null ) ) {
+ isJTA = info.getJtaDataSource() != null ? Boolean.TRUE : Boolean.FALSE;
this.setDataSource(
- info.getJtaDataSource() != null ? info.getJtaDataSource() : info.getNonJtaDataSource()
+ isJTA ? info.getJtaDataSource() : info.getNonJtaDataSource()
);
this.setProperty(
Environment.CONNECTION_PROVIDER, InjectedDataSourceConnectionProvider.class.getName()
);
}
-
+ /*
+ * If explicit type => use it
+ * If a JTA DS is used => JTA transaction,
+ * if a non JTA DS is used => RESOURCe_LOCAL
+ * if none, set to JavaEE default => JTA transaction
+ */
+ PersistenceUnitTransactionType transactionType = info.getTransactionType();
+ if (transactionType == null) {
+ if (isJTA == Boolean.TRUE) {
+ transactionType = PersistenceUnitTransactionType.JTA;
+ }
+ else if ( isJTA == Boolean.FALSE ) {
+ transactionType = PersistenceUnitTransactionType.RESOURCE_LOCAL;
+ }
+ else {
+ transactionType = PersistenceUnitTransactionType.JTA;
+ }
+ }
+ defineTransactionType( transactionType, workingVars );
configure( properties, workingVars );
}
finally {
Modified: branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java
===================================================================
--- branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java 2006-12-01 21:03:43 UTC (rev 10910)
+++ branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java 2006-12-01 21:57:11 UTC (rev 10911)
@@ -115,11 +115,8 @@
log.trace( "Persistent Unit name from persistence.xml: " + puName );
metadata.setName( puName );
}
- PersistenceUnitTransactionType transactionType = getTransactionType( top.getAttribute( "transaction-type" ) );
- //parsing a persistence.xml means we are in a JavaSE environment
- transactionType = transactionType != null ? transactionType : PersistenceUnitTransactionType.RESOURCE_LOCAL;
- metadata.setTransactionType( transactionType );
NodeList children = top.getChildNodes();
+ Boolean isJTA = null;
for ( int i = 0; i < children.getLength() ; i++ ) {
if ( children.item( i ).getNodeType() == Node.ELEMENT_NODE ) {
Element element = (Element) children.item( i );
@@ -132,9 +129,11 @@
// else
if ( tag.equals( "non-jta-data-source" ) ) {
metadata.setNonJtaDatasource( XmlHelper.getElementContent( element ) );
+ if (isJTA == null) isJTA = Boolean.FALSE;
}
else if ( tag.equals( "jta-data-source" ) ) {
metadata.setJtaDatasource( XmlHelper.getElementContent( element ) );
+ isJTA = Boolean.TRUE;
}
else if ( tag.equals( "provider" ) ) {
metadata.setProvider( XmlHelper.getElementContent( element ) );
@@ -170,6 +169,25 @@
}
}
}
+ /*
+ * if explicit => use it
+ * if JTA DS => JTA transaction
+ * if non JTA DA => RESULRCE_LOCAL transaction
+ * else default JavaSE => RESOURCE_LOCAL
+ */
+ PersistenceUnitTransactionType transactionType = getTransactionType( top.getAttribute( "transaction-type" ) );
+ if (transactionType == null) {
+ if (isJTA == Boolean.TRUE) {
+ transactionType = PersistenceUnitTransactionType.JTA;
+ }
+ else if (isJTA == Boolean.FALSE) {
+ transactionType = PersistenceUnitTransactionType.RESOURCE_LOCAL;
+ }
+ else {
+ transactionType = PersistenceUnitTransactionType.RESOURCE_LOCAL;
+ }
+ }
+ metadata.setTransactionType( transactionType );
return metadata;
}
[View Less]
18 years, 3 months
Hibernate SVN: r10910 - branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-12-01 16:03:43 -0500 (Fri, 01 Dec 2006)
New Revision: 10910
Modified:
branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/JarVisitor.java
Log:
EJB-253 Weblogic support in SE (zip protocol)
Modified: branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/JarVisitor.java
===================================================================
--- branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/…
[View More]JarVisitor.java 2006-12-01 19:21:14 UTC (rev 10909)
+++ branches/Branch_3_2/HibernateExt/ejb/src/java/org/hibernate/ejb/packaging/JarVisitor.java 2006-12-01 21:03:43 UTC (rev 10910)
@@ -54,10 +54,15 @@
if ( file.endsWith( "!" ) ) file = file.substring( 0, file.length() - 1 );
try {
String protocol = url.getProtocol();
+
if ( "jar".equals( protocol )
|| "wsjar".equals( protocol ) ) { //Websphere has it's own way
jarUrl = new URL( file );
}
+ else if ( "zip".equals( protocol ) ) { //Weblogic has it's own way
+ //we have extracted the zip file, so it should be read as a file
+ jarUrl = new URL( "file", null, file );
+ }
else if ("code-source".equals( url.getProtocol() ) ) {
//OC4J prevent ejb.jar access (ie everything without path
//fix contributed by the community
[View Less]
18 years, 3 months