Hibernate SVN: r10458 - branches/Branch_3_2/Hibernate3/src/org/hibernate/engine
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-09-06 10:07:22 -0400 (Wed, 06 Sep 2006)
New Revision: 10458
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/engine/CascadingAction.java
Log:
EJB-221
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/engine/CascadingAction.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/engine/CascadingAction.java 2006-09-06 13:51:50 UTC (rev 10457)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/engine/CascadingAction.java 2006-09-06 14:07:22 UTC (rev 10458)
@@ -11,6 +11,7 @@
import org.hibernate.LockMode;
import org.hibernate.ReplicationMode;
import org.hibernate.TransientObjectException;
+import org.hibernate.proxy.HibernateProxy;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.collection.PersistentCollection;
import org.hibernate.event.EventSource;
@@ -344,7 +345,9 @@
if ( type.isEntityType() ) {
String childEntityName = ( ( EntityType ) type ).getAssociatedEntityName( session.getFactory() );
- if ( ! isInManagedState( child, session ) && ForeignKeys.isTransient( childEntityName, child, null, session ) ) {
+ if ( ! isInManagedState( child, session )
+ && ! ( child instanceof HibernateProxy ) //a proxy cannot be transient and it breaks ForeignKeys.isTransient
+ && ForeignKeys.isTransient( childEntityName, child, null, session ) ) {
String parentEntiytName = persister.getEntityName();
String propertyName = persister.getPropertyNames()[propertyIndex];
throw new TransientObjectException(
18 years, 3 months
Hibernate SVN: r10457 - branches/Branch_3_2/Hibernate3/src/org/hibernate/proxy
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-09-06 09:51:50 -0400 (Wed, 06 Sep 2006)
New Revision: 10457
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/proxy/EntityNotFoundDelegate.java
Log:
HHH-2056 already applied to trunk, applying to 3.2 too
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/proxy/EntityNotFoundDelegate.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/proxy/EntityNotFoundDelegate.java 2006-09-06 04:01:34 UTC (rev 10456)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/proxy/EntityNotFoundDelegate.java 2006-09-06 13:51:50 UTC (rev 10457)
@@ -7,6 +7,6 @@
*
* @author Steve Ebersole
*/
-public interface EntityNotFoundDelegate {
+public interface EntityNotFoundDelegate extends Serializable {
public void handleEntityNotFound(String entityName, Serializable id);
}
18 years, 3 months
Hibernate SVN: r10456 - in trunk/HibernateExt/ejb-api/src/javax/persistence: . spi
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-09-06 00:01:34 -0400 (Wed, 06 Sep 2006)
New Revision: 10456
Modified:
trunk/HibernateExt/ejb-api/src/javax/persistence/AssociationOverride.java
trunk/HibernateExt/ejb-api/src/javax/persistence/AssociationOverrides.java
trunk/HibernateExt/ejb-api/src/javax/persistence/AttributeOverride.java
trunk/HibernateExt/ejb-api/src/javax/persistence/AttributeOverrides.java
trunk/HibernateExt/ejb-api/src/javax/persistence/Basic.java
trunk/HibernateExt/ejb-api/src/javax/persistence/Column.java
trunk/HibernateExt/ejb-api/src/javax/persistence/ColumnResult.java
trunk/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorColumn.java
trunk/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorValue.java
trunk/HibernateExt/ejb-api/src/javax/persistence/Embeddable.java
trunk/HibernateExt/ejb-api/src/javax/persistence/Embedded.java
trunk/HibernateExt/ejb-api/src/javax/persistence/EmbeddedId.java
trunk/HibernateExt/ejb-api/src/javax/persistence/Entity.java
trunk/HibernateExt/ejb-api/src/javax/persistence/EntityExistsException.java
trunk/HibernateExt/ejb-api/src/javax/persistence/EntityListeners.java
trunk/HibernateExt/ejb-api/src/javax/persistence/EntityNotFoundException.java
trunk/HibernateExt/ejb-api/src/javax/persistence/EntityResult.java
trunk/HibernateExt/ejb-api/src/javax/persistence/Enumerated.java
trunk/HibernateExt/ejb-api/src/javax/persistence/ExcludeDefaultListeners.java
trunk/HibernateExt/ejb-api/src/javax/persistence/ExcludeSuperclassListeners.java
trunk/HibernateExt/ejb-api/src/javax/persistence/FieldResult.java
trunk/HibernateExt/ejb-api/src/javax/persistence/GeneratedValue.java
trunk/HibernateExt/ejb-api/src/javax/persistence/GenerationType.java
trunk/HibernateExt/ejb-api/src/javax/persistence/Id.java
trunk/HibernateExt/ejb-api/src/javax/persistence/IdClass.java
trunk/HibernateExt/ejb-api/src/javax/persistence/Inheritance.java
trunk/HibernateExt/ejb-api/src/javax/persistence/InheritanceType.java
trunk/HibernateExt/ejb-api/src/javax/persistence/JoinTable.java
trunk/HibernateExt/ejb-api/src/javax/persistence/Lob.java
trunk/HibernateExt/ejb-api/src/javax/persistence/LockModeType.java
trunk/HibernateExt/ejb-api/src/javax/persistence/ManyToMany.java
trunk/HibernateExt/ejb-api/src/javax/persistence/ManyToOne.java
trunk/HibernateExt/ejb-api/src/javax/persistence/MapKey.java
trunk/HibernateExt/ejb-api/src/javax/persistence/MappedSuperclass.java
trunk/HibernateExt/ejb-api/src/javax/persistence/OneToMany.java
trunk/HibernateExt/ejb-api/src/javax/persistence/OneToOne.java
trunk/HibernateExt/ejb-api/src/javax/persistence/OrderBy.java
trunk/HibernateExt/ejb-api/src/javax/persistence/PersistenceContext.java
trunk/HibernateExt/ejb-api/src/javax/persistence/PersistenceContextType.java
trunk/HibernateExt/ejb-api/src/javax/persistence/PersistenceContexts.java
trunk/HibernateExt/ejb-api/src/javax/persistence/spi/PersistenceUnitTransactionType.java
Log:
EJB-211
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/AssociationOverride.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/AssociationOverride.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/AssociationOverride.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -9,9 +9,26 @@
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.FIELD;
-
+/**
+ * This annotation is used to override a many-to-one or one-to-one mapping of property or field for
+ * an entity relationship.
+ * The AssociationOverride annotation may be applied to an entity that extends a mapped superclass
+ * to override a many-to-one or one-to-one mapping defined by the mapped superclass. If the
+ * AssociationOverride annotation is not specified, the join column is mapped the same as in
+ * the original mapping.
+ *
+ * @author Emmanuel Bernard
+ */
@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
public @interface AssociationOverride {
+ /**
+ * The name of the relationship property whose mapping is being overridden if property-based
+ * access is being used, or the name of the relationship field if field-based access is used.
+ */
String name();
+
+ /**
+ * The join column that is being mapped to the persistent attribute.
+ */
JoinColumn[] joinColumns();
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/AssociationOverrides.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/AssociationOverrides.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/AssociationOverrides.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -10,9 +10,15 @@
import static java.lang.annotation.ElementType.FIELD;
/**
+ * This annotation is used to override mappings of multiple many-to-one
+ * or one-to-one relationship properties or fields.
+ *
* @author Emmanuel Bernard
*/
@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
public @interface AssociationOverrides {
+ /**
+ * Mapping overrides of relationship properties or fields
+ */
AssociationOverride[] value();
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/AttributeOverride.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/AttributeOverride.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/AttributeOverride.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -10,10 +10,25 @@
/**
+ * The AttributeOverride annotation is used to override the mapping of a Basic (whether explicit
+ * or default) property or field or Id property or field.
+ *
+ * The AttributeOverride annotation may be applied to an entity that extends a mapped superclass
+ * or to an embedded field or property to override a basic mapping defined by the mapped superclass
+ * or embeddable class. If the AttributeOverride annotation is not specified, the column is mapped
+ * the same as in the original mapping.
+ *
* @author Emmanuel Bernard
*/
@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
public @interface AttributeOverride {
+ /**
+ * The column that is being mapped to the persistent attribute
+ */
String name();
+ /**
+ * The name of the property whose mapping is being overridden if property-based access is being
+ * used, or the name of the field if field-based access is used.
+ */
Column column();
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/AttributeOverrides.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/AttributeOverrides.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/AttributeOverrides.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -10,9 +10,14 @@
/**
+ * Is used to override mappings of multiple properties or fields
+ *
* @author Emmanuel Bernard
*/
@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
public @interface AttributeOverrides {
+ /**
+ * One or more mapping override
+ */
AttributeOverride[] value();
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/Basic.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/Basic.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/Basic.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -10,10 +10,30 @@
import static javax.persistence.FetchType.EAGER;
/**
+ * The Basic annotation is the simplest type of mapping to a database column. The Basic
+ * annotation can be applied to a persistent property or instance variable of any of the
+ * following types: Java primitive types, wrappers of the primitive types, String,
+ * java.math.BigInteger, java.math.BigDecimal, java.util.Date, java.util.Calendar,
+ * java.sql.Date, java.sql.Time, java.sql.Timestamp, byte[], Byte[], char[], Character[],
+ * enums, and any other type that implements Serializable.
+ *
+ * The use of the Basic annotation is optional for persistent fields and properties of these types.
+
* @author Emmanuel Bernard
*/
@Target({METHOD, FIELD}) @Retention(RUNTIME)
public @interface Basic {
+ /**
+ * Defines whether the value of the field or property should be lazily loaded or must be
+ * eagerly fetched. The EAGER strategy is a requirement on the persistence provider runtime
+ * that the value must be eagerly fetched. The LAZY strategy is a hint to the persistence
+ * provider runtime. If not specified, defaults to EAGER.
+ */
FetchType fetch() default EAGER;
+ /**
+ * Defines whether the value of the field or property may be null. This is a hint and is
+ * disregarded for primitive types; it may be used in schema generation. If not specified,
+ * defaults to true.
+ */
boolean optional() default true;
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/Column.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/Column.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/Column.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -9,18 +9,57 @@
import static java.lang.annotation.RetentionPolicy.*;
/**
+ * Is used to specify a mapped column for a persistent property or field. If no Column annotation is
+ * specified, the default values are applied.
+ *
* @author Emmanuel Bernard
*/
@Target({METHOD, FIELD}) @Retention(RUNTIME)
public @interface Column {
+ /**
+ * The name of the column. Defaults to the property or field name
+ */
String name() default "";
+ /**
+ * Whether the property is a unique key. This is a shortcut for the UniqueConstraint
+ * annotation at the table level and is useful for when the unique key constraint is
+ * only a single field. This constraint applies in addition to any constraint entailed
+ * by primary key mapping and to constraints specified at the table level.
+ */
boolean unique() default false;
+ /**
+ * Whether the database column is nullable
+ */
boolean nullable() default true;
+ /**
+ * Whether the column is included in SQL INSERT statements generated by the persistence provider.
+ */
boolean insertable() default true;
+ /**
+ * Whether the column is included in SQL UPDATE statements generated by the persistence provider.
+ */
boolean updatable() default true;
+ /**
+ * The SQL fragment that is used when generating the DDL for the column.
+ * Defaults to the generated SQL to create a column of the inferred type.
+ */
String columnDefinition() default "";
+ /**
+ * The name of the table that contains the column. If absent the column is assumed to
+ * be in the primary table.
+ */
String table() default "";
+ /**
+ * The column length. (Applies only if a string-valued column is used.)
+ */
int length() default 255;
- int precision() default 0; // decimal precision
- int scale() default 0; // decimal scale
+ /**
+ * The precision for a decimal (exact numeric) column. (Applies only if a decimal column is used.)
+ * Value must be set by developer if used when generating the DDL for the column.
+ */
+ int precision() default 0;
+ /**
+ * The scale for a decimal (exact numeric) column. (Applies only if a decimal column is used.)
+ */
+ int scale() default 0;
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/ColumnResult.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/ColumnResult.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/ColumnResult.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -7,9 +7,16 @@
import java.lang.annotation.RetentionPolicy;
/**
+ * References name of a column in the SELECT clause of a SQL query - i.e.,
+ * column alias, if applicable. Scalar result types can be included in the query
+ * result by specifying this annotation in the metadata.
+ *
* @author Emmanuel Bernard
*/
@Target({}) @Retention(RetentionPolicy.RUNTIME)
public @interface ColumnResult {
+ /**
+ * The name of a column in the SELECT clause of a SQL query
+ */
String name();
}
\ No newline at end of file
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorColumn.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorColumn.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorColumn.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -10,12 +10,38 @@
import static javax.persistence.DiscriminatorType.STRING;
/**
+ * Is used to define the discriminator column for the SINGLE_TABLE and JOINED inheritance
+ * mapping strategies.
+ *
+ * The strategy and the discriminator column are only specified in the root of an entity
+ * class hierarchy or subhierarchy in which a different inheritance strategy is applied
+ *
+ * If the DiscriminatorColumn annotation is missing, and a discriminator column is required,
+ * the name of the discriminator column defaults to "DTYPE" and the discriminator type to
+ * DiscriminatorType.STRING.
+ *
* @author Emmanuel Bernard
*/
@Target({TYPE}) @Retention(RUNTIME)
public @interface DiscriminatorColumn {
+ /**
+ * The name of column to be used for the discriminator.
+ */
String name() default "DTYPE";
+ /**
+ * The type of object/column to use as a class discriminator.
+ * Defaults to DiscriminatorType.STRING
+ */
DiscriminatorType discriminatorType() default STRING;
+ /**
+ * The SQL fragment that is used when generating the DDL for the discriminator column.
+ * Defaults to the provider-generated SQL to create a column of the specified
+ * discriminator type.
+ */
String columnDefinition() default "";
+ /**
+ * The column length for String-based discriminator types. Ignored for other
+ * discriminator types.
+ */
int length() default 31;
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorValue.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorValue.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/DiscriminatorValue.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -7,9 +7,27 @@
import static java.lang.annotation.ElementType.TYPE;
/**
+ * Is used to specify the value of the discriminator column for entities of the given type.
+ * The DiscriminatorValue annotation can only be specified on a concrete entity class.
+ * If the DiscriminatorValue annotation is not specified and a discriminator column is used,
+ * a provider-specific function will be used to generate a value representing the entity type.
+ * If the DiscriminatorType is STRING, the discriminator value default is the entity name.
+ *
+ * The inheritance strategy and the discriminator column are only specified in the root
+ * of an entity class hierarchy or subhierarchy in which a different inheritance strategy
+ * is applied. The discriminator value, if not defaulted, should be specified for each entity
+ * class in the hierarchy.
+ *
* @author Emmanuel Bernard
*/
@Target({TYPE}) @Retention(RUNTIME)
public @interface DiscriminatorValue {
+ /**
+ * The value that indicates that the row is an entity of the annotated entity type.
+ *
+ * If the DiscriminatorValue annotation is not specified and a discriminator column is used,
+ * a provider-specific function will be used to generate a value representing the entity type.
+ * If the DiscriminatorType is STRING, the discriminator value default is the entity name.
+ */
String value();
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/Embeddable.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/Embeddable.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/Embeddable.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -10,6 +10,12 @@
/**
+ * Defines a class whose instances are stored as an intrinsic part of an owning entity and share
+ * the identity of the entity. Each of the persistent properties or fields of the embedded object
+ * is mapped to the database table for the entity. Only Basic, Column, Lob, Temporal, and
+ * Enumerated mapping annotations may portably be used to map the persistent fields or properties
+ * of classes annotated as Embeddable.
+ *
* @author Emmanuel Bernard
*/
@Target({TYPE}) @Retention(RUNTIME)
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/Embedded.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/Embedded.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/Embedded.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -9,6 +9,9 @@
import static java.lang.annotation.RetentionPolicy.*;
/**
+ * Defines a persistent field or property of an entity whose value is an instance of
+ * an embeddable class. The embeddable class must be annotated as Embeddable.
+ *
* @author Emmanuel Bernard
*/
@Target({METHOD, FIELD}) @Retention(RUNTIME)
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/EmbeddedId.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/EmbeddedId.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/EmbeddedId.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -8,6 +8,10 @@
import java.lang.annotation.Target;
/**
+ * Is applied to a persistent field or property of an entity class or mapped superclass to denote
+ * a composite primary key that is an embeddable class. The embeddable class must be annotated
+ * as Embeddable.
+ *
* @author Emmanuel Bernard
*/
@Target({ElementType.METHOD, ElementType.FIELD})
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/Entity.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/Entity.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/Entity.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -8,9 +8,16 @@
import java.lang.annotation.Target;
/**
+ * Specifies that the class is an entity. This annotation is applied to the entity class.
+ *
* @author Emmanuel Bernard
*/
@Target(TYPE) @Retention(RUNTIME)
public @interface Entity {
+ /**
+ * The name of an entity. Defaults to the unqualified name of the entity class.
+ * This name is used to refer to the entity in queries. The name must not be a
+ * reserved literal in the Java Persistence query language.
+ */
String name() default "";
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/EntityExistsException.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/EntityExistsException.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/EntityExistsException.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -2,21 +2,43 @@
package javax.persistence;
/**
+ * Thrown by the persistence provider when EntityManager.persist(Object) is called and the
+ * entity already exists. The current transaction, if one is active, will be marked for rollback.
+ *
* @author Emmanuel Bernard
*/
public class EntityExistsException extends PersistenceException {
+ /**
+ * Constructs a new EntityExistsException exception with null as its detail message.
+ */
public EntityExistsException() {
super();
}
+ /**
+ * Constructs a new EntityExistsException exception with the specified cause.
+ *
+ * @param cause the cause
+ */
public EntityExistsException(Throwable cause) {
super( cause );
}
+ /**
+ * Constructs a new EntityExistsException exception with the specified detail message.
+ *
+ * @param message the detail message.
+ */
public EntityExistsException(String message) {
super( message );
}
+ /**
+ * Constructs a new EntityExistsException exception with the specified detail message and cause.
+ *
+ * @param message the detail message.
+ * @param cause the cause.
+ */
public EntityExistsException(String message, Throwable cause) {
super( message, cause );
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/EntityListeners.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/EntityListeners.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/EntityListeners.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -13,12 +13,16 @@
/**
- * comment
+ * Specifies the callback listener classes to be used for an entity or mapped superclass.
+ * This annotation may be applied to an entity class or mapped superclass.
*
* @author <a href="mailto:bill@jboss.org">Bill Burke</a>
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface EntityListeners {
+ /**
+ * The callback listener classes
+ */
Class[] value();
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/EntityNotFoundException.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/EntityNotFoundException.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/EntityNotFoundException.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -2,14 +2,26 @@
package javax.persistence;
/**
+ * Thrown by the persistence provider when an entity reference obtained by
+ * EntityManager.getReference(Class,Object) is accessed but the entity does not exist.
+ * Also thrown when EntityManager.refresh(Object) is called and the object no longer exists
+ * in the database. The current transaction, if one is active, will be marked for rollback.
+ *
* @author Gavin King
*/
public class EntityNotFoundException extends PersistenceException {
-
+ /**
+ * Constructs a new EntityNotFoundException exception with null as its detail message.
+ */
public EntityNotFoundException() {
super();
}
+ /**
+ * Constructs a new EntityNotFoundException exception with the specified detail message.
+ *
+ * @param message the detail message
+ */
public EntityNotFoundException(String message) {
super( message );
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/EntityResult.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/EntityResult.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/EntityResult.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -7,11 +7,27 @@
import java.lang.annotation.RetentionPolicy;
/**
+ * References an entity in the SELECT clause of a SQL query. If this annotation is used,
+ * the SQL statement should select all of the columns that are mapped to the entity object.
+ * This should include foreign key columns to related entities. The results obtained when
+ * insufficient data is available are undefined.
+ *
* @author Emmanuel Bernard
*/
@Target({}) @Retention(RetentionPolicy.RUNTIME)
public @interface EntityResult {
+ /**
+ * The class of the result
+ */
Class entityClass();
+ /**
+ * Maps the columns specified in the SELECT list of the query to the properties or
+ * fields of the entity class.
+ */
FieldResult[] fields() default {};
+ /**
+ * Specifies the column name (or alias) of the column in the SELECT list that is used to
+ * determine the type of the entity instance.
+ */
String discriminatorColumn() default "";
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/Enumerated.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/Enumerated.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/Enumerated.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -9,10 +9,16 @@
import static javax.persistence.EnumType.*;
/**
+ * Specifies that a persistent property or field should be persisted as a enumerated type.
+ * It may be used in conjunction with the Basic annotation.
+ *
* @author Emmanuel Bernard
*/
@Target({METHOD, FIELD})
@Retention(RUNTIME)
public @interface Enumerated {
+ /**
+ * The type used in mapping an enum type
+ */
EnumType value() default ORDINAL;
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/ExcludeDefaultListeners.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/ExcludeDefaultListeners.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/ExcludeDefaultListeners.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -7,6 +7,9 @@
import java.lang.annotation.Target;
/**
+ * Specifies that the invocation of default listeners is to be excluded for the entity class
+ * (or mapped superclass) and its subclasses.
+ *
* @author Emmanuel Bernard
*/
@Target(TYPE) @Retention(RUNTIME)
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/ExcludeSuperclassListeners.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/ExcludeSuperclassListeners.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/ExcludeSuperclassListeners.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -7,6 +7,9 @@
import static java.lang.annotation.ElementType.TYPE;
/**
+ * Specifies that the invocation of superclass listeners is to be excluded for the
+ * entity class (or mapped superclass) and its subclasses.
+ *
* @author Emmanuel Bernard
*/
@Target(TYPE) @Retention(RUNTIME)
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/FieldResult.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/FieldResult.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/FieldResult.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -7,10 +7,19 @@
import java.lang.annotation.RetentionPolicy;
/**
+ * Is used to map the columns specified in the SELECT list of the query to the properties
+ * or fields of the entity class.
+ *
* @author Emmanuel Bernard
*/
@Target({}) @Retention(RetentionPolicy.RUNTIME)
public @interface FieldResult {
+ /**
+ * Name of the persistent field or property of the class.
+ */
String name();
+ /**
+ * Name of the column in the SELECT clause - i.e., column aliases, if applicable.
+ */
String column();
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/GeneratedValue.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/GeneratedValue.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/GeneratedValue.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -8,11 +8,25 @@
import java.lang.annotation.Target;
/**
+ * Provides for the specification of generation strategies for the values of primary keys.
+ * The GeneratedValue annotation may be applied to a primary key property or field of an entity
+ * or mapped superclass in conjunction with the Id annotation.
+ *
* @author Emmanuel Bernard
*/
@Target({METHOD, FIELD})
@Retention(RUNTIME)
public @interface GeneratedValue {
+ /**
+ * The primary key generation strategy that the persistence provider must use
+ * to generate the annotated entity primary key.
+ */
GenerationType strategy() default GenerationType.AUTO;
+ /**
+ * The name of the primary key generator to use as specified in the SequenceGenerator or
+ * TableGenerator annotation.
+ *
+ * Defaults to the id generator supplied by persistence provider.
+ */
String generator() default "";
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/GenerationType.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/GenerationType.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/GenerationType.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -3,6 +3,32 @@
package javax.persistence;
/**
+ * Defines the types of primary key generation.
+ *
* @author Emmanuel Bernard
*/
-public enum GenerationType { TABLE, SEQUENCE, IDENTITY, AUTO };
+public enum GenerationType {
+ /**
+ * Indicates that the persistence provider must assign primary keys for the entity using an underlying
+ * database table to ensure uniqueness.
+ */
+ TABLE,
+ /**
+ * Indicates that the persistence provider must assign primary keys for the entity using database
+ * sequence column.
+ */
+ SEQUENCE,
+ /**
+ * Indicates that the persistence provider must assign primary keys for the entity using
+ * database identity column.
+ */
+ IDENTITY,
+ /**
+ * Indicates that the persistence provider should pick an appropriate strategy for the
+ * particular database. The AUTO generation strategy may expect a database resource
+ * to exist, or it may attempt to create one. A vendor may provide documentation on how
+ * to create such resources in the event that it does not support schema generation or cannot
+ * create the schema resource at runtime.
+ */
+ AUTO
+};
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/Id.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/Id.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/Id.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -10,6 +10,8 @@
/**
+ * Specifies the primary key property or field of an entity.
+ *
* @author Emmanuel Bernard
*/
@Target({METHOD, FIELD}) @Retention(RUNTIME)
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/IdClass.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/IdClass.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/IdClass.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -9,9 +9,18 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
+ * Specifies a composite primary key class that is mapped to multiple fields or properties
+ * of the entity.
+ *
+ * The names of the fields or properties in the primary key class and the primary key fields
+ * or properties of the entity must correspond and their types must be the same.
+ *
* @author Emmanuel Bernard
*/
@Target({TYPE}) @Retention(RUNTIME)
public @interface IdClass {
+ /**
+ * Primary key class
+ */
Class value();
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/Inheritance.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/Inheritance.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/Inheritance.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -9,9 +9,15 @@
import static javax.persistence.InheritanceType.SINGLE_TABLE;
/**
+ * Defines the inheritance strategy to be used for an entity class hierarchy. It is specified
+ * on the entity class that is the root of the entity class hierarchy.
+ *
* @author Emmanuel Bernard
*/
@Target({TYPE}) @Retention(RUNTIME)
public @interface Inheritance {
+ /**
+ * The strategy to be used
+ */
InheritanceType strategy() default SINGLE_TABLE;
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/InheritanceType.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/InheritanceType.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/InheritanceType.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -3,7 +3,23 @@
package javax.persistence;
/**
+ * Defines inheritance strategy options.
+ *
* @author Emmanuel Bernard
*/
public enum InheritanceType
-{ SINGLE_TABLE, TABLE_PER_CLASS, JOINED };
+{
+ /**
+ * A single table per class hierarchy
+ */
+ SINGLE_TABLE,
+ /**
+ * A table per concrete entity class
+ */
+ TABLE_PER_CLASS,
+ /**
+ * A strategy in which fields that are specific to a subclass are mapped to a separate
+ * table than the fields that are common to the parent class, and a join is performed
+ * to instantiate the subclass.
+ */
+ JOINED };
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/JoinTable.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/JoinTable.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/JoinTable.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -9,14 +9,55 @@
import static java.lang.annotation.RetentionPolicy.*;
/**
+ * This annotation is used in the mapping of associations. It is specified on the owning
+ * side of a many-to-many association, or in a unidirectional one-to-many association.
+ *
+ * If the JoinTable annotation is missing, the default values of the annotation elements apply.
+ * The name of the join table is assumed to be the table names of the associated primary tables
+ * concatenated together (owning side first) using an underscore.
+ *
* @author Emmanuel Bernard
*/
@Target({METHOD, FIELD}) @Retention(RUNTIME)
public @interface JoinTable {
+ /**
+ * The name of the join table.
+ *
+ * Defaults to the concatenated names of the two associated primary entity tables,
+ * separated by an underscore
+ */
String name() default "";
+ /**
+ * The catalog of the table.
+ *
+ * Defaults to the default catalog.
+ */
String catalog() default "";
+ /**
+ * The schema of the table.
+ *
+ * Defaults to the default schema for user.
+ */
String schema() default "";
+ /**
+ * The foreign key columns of the join table which reference the primary table of the
+ * entity owning the association (i.e. the owning side of the association).
+ *
+ * Uses the same defaults as for JoinColumn.
+ */
JoinColumn[] joinColumns() default {};
+ /**
+ * The foreign key columns of the join table which reference the primary table of the entity
+ * that does not own the association (i.e. the inverse side of the association).
+ *
+ * Uses the same defaults as for JoinColumn
+ */
JoinColumn[] inverseJoinColumns() default {};
+ /**
+ * Unique constraints that are to be placed on the table. These are only used if table
+ * generation is in effect.
+ *
+ * Defaults to no additional constraints
+ */
UniqueConstraint[] uniqueConstraints() default {};
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/Lob.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/Lob.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/Lob.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -12,6 +12,13 @@
import java.lang.annotation.Retention;
/**
+ * Specifies that a persistent property or field should be persisted as a large object to a
+ * database-supported large object type. The Lob annotation may be used in conjunction with
+ * the Basic annotation. A Lob may be either a binary or character type.
+ *
+ * The Lob type is inferred from the type of the persistent field or property, and except
+ * for string and character-based types defaults to Blob.
+ *
* @author Emmanuel Bernard
*/
@Target({METHOD, FIELD}) @Retention(RUNTIME)
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/LockModeType.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/LockModeType.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/LockModeType.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -2,9 +2,39 @@
package javax.persistence;
/**
+ * Lock modes that can be specified by means of the EntityManager.lock() method.
+ *
+ * The semantics of requesting locks of type LockModeType.READ and LockModeType.WRITE are t
+ * he following.
+ *
+ * If transaction T1 calls lock(entity, LockModeType.READ) on a versioned object, the entity
+ * manager must ensure that neither of the following phenomena can occur:
+ *
+ * * P1 (Dirty read): Transaction T1 modifies a row. Another transaction T2 then reads
+ * that row and obtains the modified value, before T1 has committed or rolled back.
+ * Transaction T2 eventually commits successfully; it does not matter whether T1 commits or rolls
+ * back and whether it does so before or after T2 commits.
+ *
+ * * P2 (Non-repeatable read): Transaction T1 reads a row. Another transaction T2 then modifies
+ * or deletes that row, before T1 has committed. Both transactions eventually commit successfully.
+ *
+ * Lock modes must always prevent the phenomena P1 and P2.
+ * In addition, calling lock(entity, LockModeType.WRITE) on a versioned object,
+ * will also force an update (increment) to the entity's version column.
+ *
+ * The persistence implementation is not required to support calling EntityManager.lock()
+ * on a non-versioned object. When it cannot support a such lock call, it must
+ * throw the PersistenceException.
+ *
* @author Emmanuel Bernard
*/
public enum LockModeType {
+ /**
+ * Read lock
+ */
READ,
+ /**
+ * Write lock
+ */
WRITE
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/ManyToMany.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/ManyToMany.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/ManyToMany.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -10,12 +10,42 @@
import static javax.persistence.FetchType.*;
/**
+ * Defines a many-valued association with many-to-many multiplicity. If the Collection is
+ * defined using generics to specify the element type, the associated target entity class
+ * does not need to be specified; otherwise it must be specified.
+ *
+ * Every many-to-many association has two sides, the owning side and the non-owning, or inverse,
+ * side. The join table is specified on the owning side. If the association is bidirectional,
+ * either side may be designated as the owning side.
+ *
+ * The same annotation elements for the OneToMany annotation apply to the ManyToMany annotation.
+ *
* @author Emmanuel Bernard
*/
@Target({METHOD, FIELD}) @Retention(RUNTIME)
public @interface ManyToMany {
+ /**
+ * The entity class that is the target of the association. Optional only if the
+ * collection property is defined using Java generics. Must be specified otherwise.
+ *
+ * Defaults to the parameterized type of the collection when defined using generics.
+ */
Class targetEntity() default void.class;
+ /**
+ * The operations that must be cascaded to the target of the association.
+ *
+ * Defaults to no operations being cascaded.
+ */
CascadeType[] cascade() default {};
+ /**
+ * Whether the association should be lazily loaded or must be eagerly fetched.
+ * The EAGER strategy is a requirement on the persistenceprovider runtime that
+ * the associatedentities must be eagerly fetched. The LAZY strategy is a hint
+ * to the persistence provider runtime.
+ */
FetchType fetch() default LAZY;
+ /**
+ * The field that owns the relationship. Required unless the relationship is unidirectional.
+ */
String mappedBy() default "";
}
\ No newline at end of file
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/ManyToOne.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/ManyToOne.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/ManyToOne.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -10,12 +10,35 @@
import static javax.persistence.FetchType.*;
/**
+ * This annotation defines a single-valued association to another entity class that has
+ * many-to-one multiplicity. It is not normally necessary to specify the target entity
+ * explicitly since it can usually be inferred from the type of the object being referenced.
+ *
* @author Emmanuel Bernard
*/
@Target({METHOD, FIELD}) @Retention(RUNTIME)
public @interface ManyToOne {
+ /**
+ * The entity class that is the target of the association.
+ *
+ * Defaults to the type of the field or property that stores the association
+ */
Class targetEntity() default void.class;
+ /**
+ * The operations that must be cascaded to the target of the association.
+ *
+ * By default no operations are cascaded.
+ */
CascadeType[] cascade() default {};
+ /**
+ * Whether the association should be lazily loaded or must be eagerly fetched.
+ * The EAGER strategy is a requirement on the persistence provider runtime that
+ * the associated entity must be eagerly fetched. The LAZY strategy is a hint to
+ * the persistence provider runtime.
+ */
FetchType fetch() default EAGER;
+ /**
+ * Whether the association is optional. If set to false then a non-null relationship must always exist.
+ */
boolean optional() default true;
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/MapKey.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/MapKey.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/MapKey.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -7,9 +7,19 @@
import java.lang.annotation.Retention;
/**
+ * Is used to specify the map key for associations of type Map.
+ * If a persistent field or property other than the primary key is used as a map key then it
+ * is expected to have a uniqueness constraint associated with it.
+ *
* @author Emmanuel Bernard
*/
@Target({METHOD, FIELD}) @Retention(RUNTIME)
public @interface MapKey {
- String name() default ""; // name of persistent field or property of map key
+ /**
+ * The name of the persistent field or property of the associated entity that is used as the map key.
+ * If the name element is not specified, the primary key of the associated entity is used as the map key.
+ * If the primary key is a composite primary key and is mapped as IdClass, an instance of the primary key
+ * class is used as the key.
+ */
+ String name() default "";
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/MappedSuperclass.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/MappedSuperclass.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/MappedSuperclass.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -9,6 +9,16 @@
import static java.lang.annotation.RetentionPolicy.*;
/**
+ * Designates a class whose mapping information is applied to the entities that inherit
+ * from it. A mapped superclass has no separate table defined for it.
+ *
+ * A class designated with the MappedSuperclass annotation can be mapped in the same way as
+ * an entity except that the mappings will apply only to its subclasses since no table exists
+ * for the mapped superclass itself. When applied to the subclasses the inherited mappings will
+ * apply in the context of the subclass tables. Mapping information may be overridden in such
+ * subclasses by using the AttributeOverride and AssociationOverride annotations or corresponding *
+ * XML elements.
+ *
* @author Emmanuel Bernard
*/
@Target(TYPE) @Retention(RUNTIME)
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/OneToMany.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/OneToMany.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/OneToMany.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -10,12 +10,38 @@
import static javax.persistence.FetchType.*;
/**
+ * Defines a many-valued association with one-to-many multiplicity.
+ *
+ * If the collection is defined using generics to specify the element type,
+ * the associated target entity type need not be specified; otherwise the target
+ * entity class must be specified.
+ *
* @author Emmanuel Bernard
*/
@Target({METHOD, FIELD}) @Retention(RUNTIME)
public @interface OneToMany {
+ /**
+ * The entity class that is the target of the association. Optional only if the collection
+ * property is defined using Java generics. Must be specified otherwise.
+ *
+ * Defaults to the parameterized type of the collection when defined using generics.
+ */
Class targetEntity() default void.class;
+ /**
+ * The operations that must be cascaded to the target of the association.
+ *
+ * Defaults to no operations being cascaded.
+ */
CascadeType[] cascade() default {};
+ /**
+ * Whether the association should be lazily loaded or must be eagerly fetched.
+ * The EAGER strategy is a requirement on the persistenceprovider runtime that the
+ * associatedentities must be eagerly fetched. The LAZY strategy is a hint to the
+ * persistence provider runtime.
+ */
FetchType fetch() default LAZY;
+ /**
+ * The field that owns the relationship. Required unless the relationship is unidirectional.
+ */
String mappedBy() default "";
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/OneToOne.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/OneToOne.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/OneToOne.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -10,13 +10,42 @@
import static javax.persistence.FetchType.*;
/**
+ * This annotation defines a single-valued association to another entity that has
+ * one-to-one multiplicity. It is not normally necessary to specify the associated
+ * target entity explicitly since it can usually be inferred from the type of the object
+ * being referenced.
+ *
* @author Emmanuel Bernard
*/
@Target({METHOD, FIELD}) @Retention(RUNTIME)
public @interface OneToOne {
+ /**
+ * The entity class that is the target of the association.
+ *
+ * Defaults to the type of the field or property that stores the association.
+ */
Class targetEntity() default void.class;
+ /**
+ * The operations that must be cascaded to the target of the association.
+ *
+ * By default no operations are cascaded.
+ */
CascadeType[] cascade() default {};
+ /**
+ * Whether the association should be lazily loaded or must be eagerly fetched.
+ * The EAGER strategy is a requirement on the persistence provider runtime that
+ * the associated entity must be eagerly fetched. The LAZY strategy is a hint to
+ * the persistence provider runtime.
+ */
FetchType fetch() default EAGER;
+ /**
+ * Whether the association is optional. If set to false then a non-null relationship must
+ * always exist.
+ */
boolean optional() default true;
+ /**
+ * The field that owns the relationship. This element is only specified on the
+ * inverse (non-owning) side of the association.
+ */
String mappedBy() default "";
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/OrderBy.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/OrderBy.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/OrderBy.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -8,9 +8,32 @@
import static java.lang.annotation.RetentionPolicy.*;
/**
+ * This annotation specifies the ordering of the elements of a collection valued association at the
+ * point when the association is retrieved.
+ *
+ * The syntax of the value ordering element is an orderby_list, as follows:
+ * <code>orderby_list::= orderby_item [,orderby_item]*
+ * orderby_item::= property_or_field_name [ASC | DESC]</code>
+ *
+ * If ASC or DESC is not specified, ASC (ascending order) is assumed.
+ *
+ * If the ordering element is not specified, ordering by the primary key of the associated
+ * entity is assumed.
+ *
+ * The property or field name must correspond to that of a persistent property or field of the
+ * associated class. The properties or fields used in the ordering must correspond to columns
+ * for which comparison operators are supported.
+ *
* @author Emmanuel Bernard
*/
@Target({METHOD, FIELD}) @Retention(RUNTIME)
public @interface OrderBy {
+ /**
+ * An orderby_list, specified as follows:
+ * orderby_list::= orderby_item [,orderby_item]* orderby_item::= property_or_field_name [ASC | DESC]
+ *
+ * If ASC or DESC is not specified, ASC (ascending order) is assumed.
+ *
+ */
String value() default "";
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/PersistenceContext.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/PersistenceContext.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/PersistenceContext.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -1,5 +1,5 @@
-/*
- * JBoss, the OpenSource J2EE webOS
+/* $Id$
+ * JBoss Inc
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
@@ -25,17 +25,19 @@
*/
String name() default "";
/**
- * The name of the persistence unit. If the unitName element is specified, the persistence unit for the
- * entity manager that is accessible in JNDI must have the same name.
+ * The name of the persistence unit. If the unitName element is specified, the persistence unit
+ * for the entity manager that is accessible in JNDI must have the same name.
*/
String unitName() default "";
/**
- * Used to specify properties for the container or persistence provider. Vendor specific properties may be included
- * in this set of properties. Properties that are not recognized by a vendor are ignored.
+ * Used to specify properties for the container or persistence provider. Vendor specific
+ * properties may be included in this set of properties. Properties that are not
+ * recognized by a vendor are ignored.
*/
PersistenceProperty[] properties() default {};
/**
- * Specifies whether this is a transaction-scoped persistence context or an extended persistence context.
+ * Specifies whether this is a transaction-scoped persistence context or
+ * an extended persistence context.
*/
PersistenceContextType type() default PersistenceContextType.TRANSACTION;
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/PersistenceContextType.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/PersistenceContextType.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/PersistenceContextType.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -1,7 +1,18 @@
//$Id$
package javax.persistence;
+/**
+ * Specifies whether a transaction-scoped or extended persistence context is to be used in
+ * PersistenceContext. If the type element is not specified, a transaction-scoped persistence
+ * context is used.
+ */
public enum PersistenceContextType {
- TRANSACTION,
- EXTENDED
+ /**
+ * Transaction-scoped persistence context
+ */
+ TRANSACTION,
+ /**
+ * Extended persistence context
+ */
+ EXTENDED
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/PersistenceContexts.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/PersistenceContexts.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/PersistenceContexts.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -1,5 +1,5 @@
-/*
- * JBoss, the OpenSource J2EE webOS
+/* $Id$
+ * JBoss Inc
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
@@ -12,14 +12,16 @@
import java.lang.annotation.Target;
/**
- * Comment
+ * Declares one or more PersistenceContext annotations. It is used to express a dependency on
+ * container-managed entity manager persistence contexts.
*
* @author <a href="mailto:bill@jboss.org">Bill Burke</a>
- * @version $Revision$
*/
-@Target({ ElementType.TYPE })
+(a)Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
-public @interface PersistenceContexts
-{
- PersistenceContext[] value();
+public @interface PersistenceContexts {
+ /**
+ * One or more persistence context
+ */
+ PersistenceContext[] value();
}
Modified: trunk/HibernateExt/ejb-api/src/javax/persistence/spi/PersistenceUnitTransactionType.java
===================================================================
--- trunk/HibernateExt/ejb-api/src/javax/persistence/spi/PersistenceUnitTransactionType.java 2006-09-06 00:05:28 UTC (rev 10455)
+++ trunk/HibernateExt/ejb-api/src/javax/persistence/spi/PersistenceUnitTransactionType.java 2006-09-06 04:01:34 UTC (rev 10456)
@@ -3,7 +3,8 @@
package javax.persistence.spi;
/**
- * This enum class defines whether the entity managers created by the EntityManagerFactory will be JTA or resource-local entity managers.
+ * This enum class defines whether the entity managers created by the EntityManagerFactory will be
+ * JTA or resource-local entity managers.
*
* @author <a href="mailto:bill@jboss.org">Bill Burke</a>
*/
18 years, 3 months
Hibernate SVN: r10455 - trunk/Hibernate3/src/org/hibernate/proxy
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-09-05 20:05:28 -0400 (Tue, 05 Sep 2006)
New Revision: 10455
Modified:
trunk/Hibernate3/src/org/hibernate/proxy/EntityNotFoundDelegate.java
Log:
EJB-160 make Ejb3Configuration and AnnotationConfiguration serializable and allow JNDI reference
EntityNotFoundDelegate must be serializable
Modified: trunk/Hibernate3/src/org/hibernate/proxy/EntityNotFoundDelegate.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/proxy/EntityNotFoundDelegate.java 2006-09-06 00:03:49 UTC (rev 10454)
+++ trunk/Hibernate3/src/org/hibernate/proxy/EntityNotFoundDelegate.java 2006-09-06 00:05:28 UTC (rev 10455)
@@ -7,6 +7,6 @@
*
* @author Steve Ebersole
*/
-public interface EntityNotFoundDelegate {
+public interface EntityNotFoundDelegate extends Serializable {
public void handleEntityNotFound(String entityName, Serializable id);
}
18 years, 3 months
Hibernate SVN: r10454 - in trunk/HibernateExt: ejb/src/java/org/hibernate/ejb ejb/src/java/org/hibernate/ejb/util metadata/src/java/org/hibernate/cfg
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-09-05 20:03:49 -0400 (Tue, 05 Sep 2006)
New Revision: 10454
Added:
trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3ConfigurationObjectFactory.java
trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/util/NamingHelper.java
Modified:
trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java
trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/HibernatePersistence.java
trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java
Log:
EJB-160 make Ejb3Configuration and AnnotationConfiguration serializable and allow JNDI reference
Modified: trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java
===================================================================
--- trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java 2006-09-05 20:38:24 UTC (rev 10453)
+++ trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3Configuration.java 2006-09-06 00:03:49 UTC (rev 10454)
@@ -2,10 +2,13 @@
package org.hibernate.ejb;
import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.net.URL;
import java.util.ArrayList;
@@ -19,6 +22,10 @@
import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
+import javax.naming.BinaryRefAddr;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.EntityManagerFactory;
@@ -39,8 +46,8 @@
import org.hibernate.HibernateException;
import org.hibernate.Interceptor;
import org.hibernate.MappingException;
+import org.hibernate.MappingNotFoundException;
import org.hibernate.SessionFactory;
-import org.hibernate.MappingNotFoundException;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
@@ -55,6 +62,7 @@
import org.hibernate.ejb.transaction.JoinableCMTTransactionFactory;
import org.hibernate.ejb.util.ConfigurationHelper;
import org.hibernate.ejb.util.LogHelper;
+import org.hibernate.ejb.util.NamingHelper;
import org.hibernate.engine.FilterDefinition;
import org.hibernate.event.EventListeners;
import org.hibernate.mapping.AuxiliaryDatabaseObject;
@@ -72,9 +80,23 @@
import org.xml.sax.SAXException;
/**
+ * Allow a fine tuned configuration of an EJB 3.0 EntityManagerFactory
+ *
+ * A Ejb3Configuration object is only guaranteed to create one EntityManagerFactory.
+ * Multiple usage of #buildEntityManagerFactory() is not guaranteed.
+ *
+ * After #buildEntityManagerFactory() has been called, you no longer can change the configuration
+ * state (no class adding, no property change etc)
+ *
+ * When serialized / deserialized or retrieved from the JNDI, you no longer can change the
+ * configuration state (no class adding, no property change etc)
+ *
+ * Putting the configuration in the JNDI is an expensive operation that requires a partial
+ * serialization
+ *
* @author Emmanuel Bernard
*/
-public class Ejb3Configuration implements Serializable {
+public class Ejb3Configuration implements Serializable, Referenceable {
private static final String IMPLEMENTATION_NAME = HibernatePersistence.class.getName();
private static final String META_INF_ORM_XML = "META-INF/orm.xml";
private static Log log = LogFactory.getLog( Ejb3Configuration.class );
@@ -85,10 +107,10 @@
private AnnotationConfiguration cfg;
private SettingsFactory settingsFactory;
- private EventListenerConfigurator listenerConfigurator;
+ private transient EventListenerConfigurator listenerConfigurator;
private PersistenceUnitTransactionType transactionType;
private boolean discardOnClose;
- private ClassLoader overridenClassLoader;
+ private transient ClassLoader overridenClassLoader;
public Ejb3Configuration() {
@@ -660,12 +682,13 @@
thread.setContextClassLoader( overridenClassLoader );
}
try {
+ NamingHelper.bind(this);
return new EntityManagerFactoryImpl(
cfg.buildSessionFactory(),
transactionType,
discardOnClose
);
- }
+ }
catch (HibernateException e) {
throw new PersistenceException( e );
}
@@ -676,6 +699,32 @@
}
}
+ public Reference getReference() throws NamingException {
+ log.debug("Returning a Reference to the Ejb3Configuration");
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ ObjectOutput out = null;
+ byte[] serialized;
+ try {
+ out = new ObjectOutputStream( stream );
+ out.writeObject( this );
+ out.close();
+ serialized = stream.toByteArray();
+ stream.close();
+ }
+ catch (IOException e) {
+ NamingException namingException = new NamingException( "Unable to serialize Ejb3Configuration" );
+ namingException.setRootCause( e );
+ throw namingException;
+ }
+
+ return new Reference(
+ Ejb3Configuration.class.getName(),
+ new BinaryRefAddr("object", serialized ),
+ Ejb3ConfigurationObjectFactory.class.getName(),
+ null
+ );
+ }
+
/**
* create a factory from a canonical workingVars map and the overriden properties
*
Added: trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3ConfigurationObjectFactory.java
===================================================================
--- trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3ConfigurationObjectFactory.java 2006-09-05 20:38:24 UTC (rev 10453)
+++ trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/Ejb3ConfigurationObjectFactory.java 2006-09-06 00:03:49 UTC (rev 10454)
@@ -0,0 +1,27 @@
+//$Id: $
+package org.hibernate.ejb;
+
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+import java.util.Hashtable;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.Reference;
+import javax.naming.spi.ObjectFactory;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class Ejb3ConfigurationObjectFactory implements ObjectFactory {
+ public Object getObjectInstance(
+ Object reference, Name name, Context nameCtx, Hashtable<?, ?> environment
+ ) throws Exception {
+ byte[] serialized = (byte[]) ( (Reference) reference ).get(0).getContent();
+ ByteArrayInputStream byteIn = new ByteArrayInputStream( serialized );
+ ObjectInputStream in = new ObjectInputStream( byteIn );
+ Ejb3Configuration cfg = (Ejb3Configuration) in.readObject();
+ in.close();
+ byteIn.close();
+ return cfg;
+ }
+}
Modified: trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/HibernatePersistence.java
===================================================================
--- trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/HibernatePersistence.java 2006-09-05 20:38:24 UTC (rev 10453)
+++ trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/HibernatePersistence.java 2006-09-06 00:03:49 UTC (rev 10454)
@@ -34,21 +34,6 @@
*/
public static final String AUTODETECTION = "hibernate.archive.autodetection";
/**
- * List of classes names
- * Internal use only
- */
- public static final String CLASS_NAMES = "hibernate.ejb.classes";
- /**
- * List of annotated packages
- * Internal use only
- */
- public static final String PACKAGE_NAMES = "hibernate.ejb.packages";
- /**
- * List of classes names
- * Internal use only
- */
- public static final String XML_FILE_NAMES = "hibernate.ejb.xml_files";
- /**
* cfg.xml configuration file used
*/
public static final String CFG_FILE = "hibernate.ejb.cfgfile";
@@ -86,12 +71,33 @@
* The EJB3 compliant and default choice is false
*/
public static final String DISCARD_PC_ON_CLOSE = "hibernate.ejb.discard_pc_on_close";
+ /**
+ * Consider this as experimental
+ * It is not recommended to set up this property, the configuration is stored
+ * in the JNDI in a serialized form
+ */
+ public static final String CONFIGURATION_JNDI_NAME = "hibernate.ejb.configuration_jndi_name";
//The following properties are for Internal use only
/**
* link to the alternative Hibernate configuration file
* Internal use only
*/
+ /**
+ * List of classes names
+ * Internal use only
+ */
+ public static final String CLASS_NAMES = "hibernate.ejb.classes";
+ /**
+ * List of annotated packages
+ * Internal use only
+ */
+ public static final String PACKAGE_NAMES = "hibernate.ejb.packages";
+ /**
+ * List of classes names
+ * Internal use only
+ */
+ public static final String XML_FILE_NAMES = "hibernate.ejb.xml_files";
public static final String HBXML_FILES = "hibernate.hbmxml.files";
public static final String LOADED_CLASSES = "hibernate.ejb.loaded.classes";
public static final String JACC_CONTEXT_ID = "hibernate.jacc.ctx.id";
Added: trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/util/NamingHelper.java
===================================================================
--- trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/util/NamingHelper.java 2006-09-05 20:38:24 UTC (rev 10453)
+++ trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/util/NamingHelper.java 2006-09-06 00:03:49 UTC (rev 10454)
@@ -0,0 +1,74 @@
+//$Id: $
+package org.hibernate.ejb.util;
+
+import javax.naming.Context;
+import javax.naming.InvalidNameException;
+import javax.naming.NamingException;
+import javax.naming.event.EventContext;
+import javax.naming.event.NamespaceChangeListener;
+import javax.naming.event.NamingEvent;
+import javax.naming.event.NamingExceptionEvent;
+import javax.naming.event.NamingListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.ejb.Ejb3Configuration;
+import org.hibernate.ejb.HibernatePersistence;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class NamingHelper {
+ private NamingHelper() {};
+
+ private static Log log = LogFactory.getLog( NamingHelper.class );
+
+ /** bind the configuration to the JNDI */
+ public static void bind(Ejb3Configuration cfg) {
+ String name = cfg.getHibernateConfiguration().getProperty( HibernatePersistence.CONFIGURATION_JNDI_NAME );
+ if ( name == null ) {
+ log.debug( "Not Ejb3Configuration to JNDI, no JNDI name configured" );
+ }
+ else {
+ log.info( "Ejb3Configuration name: " + name );
+
+ try {
+ Context ctx = org.hibernate.util.NamingHelper.getInitialContext( cfg.getProperties() );
+ org.hibernate.util.NamingHelper.bind( ctx, name, cfg );
+ log.info( "Bound Ejb3Configuration to JNDI name: " + name );
+ ( (EventContext) ctx ).addNamingListener( name, EventContext.OBJECT_SCOPE, LISTENER );
+ }
+ catch (InvalidNameException ine) {
+ log.error( "Invalid JNDI name: " + name, ine );
+ }
+ catch (NamingException ne) {
+ log.warn( "Could not bind Ejb3Configuration to JNDI", ne );
+ }
+ catch (ClassCastException cce) {
+ log.warn( "InitialContext did not implement EventContext" );
+ }
+ }
+ }
+
+ private static final NamingListener LISTENER = new NamespaceChangeListener() {
+ public void objectAdded(NamingEvent evt) {
+ log.debug( "An Ejb3Configuration was successfully bound to name: " + evt.getNewBinding().getName() );
+ }
+
+ public void objectRemoved(NamingEvent evt) {
+ String name = evt.getOldBinding().getName();
+ log.info( "An Ejb3Configuration was unbound from name: " + name );
+ }
+
+ public void objectRenamed(NamingEvent evt) {
+ String name = evt.getOldBinding().getName();
+ log.info( "An Ejb3Configuration was renamed from name: " + name );
+ }
+
+ public void namingExceptionThrown(NamingExceptionEvent evt) {
+ log.warn( "Naming exception occurred accessing Ejb3Configuration: " + evt.getException() );
+ }
+ };
+
+
+}
Modified: trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java
===================================================================
--- trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java 2006-09-05 20:38:24 UTC (rev 10453)
+++ trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java 2006-09-06 00:03:49 UTC (rev 10454)
@@ -80,7 +80,7 @@
private List<Document> hbmDocuments; //user ordering matters, hence the list
private String precedence = null;
private boolean inSecondPass = false;
- private ReflectionManager reflectionManager;
+ private transient ReflectionManager reflectionManager;
private boolean isDefaultProcessed = false;
public AnnotationConfiguration() {
18 years, 3 months
Hibernate SVN: r10453 - trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-09-05 16:38:24 -0400 (Tue, 05 Sep 2006)
New Revision: 10453
Added:
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Asset.hbm.xml
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Asset.java
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/FinancialAsset.java
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassAndSecondaryTable.java
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Parent.java
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Pool.java
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/PropertyAsset.java
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/SwimmingPool.java
Modified:
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassTest.java
Log:
add tests on joined and secondary tables
Added: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Asset.hbm.xml
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Asset.hbm.xml 2006-09-05 16:49:05 UTC (rev 10452)
+++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Asset.hbm.xml 2006-09-05 20:38:24 UTC (rev 10453)
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.hibernate.test.annotations.inheritance.joined">
+
+ <class name="Parent">
+ <id name="id">
+ <generator class="native"/>
+ </id>
+ <set name="financialAssets" fetch="join" cascade="refresh" inverse="true">
+ <key column="PARENT_ID"/>
+ <one-to-many class="FinancialAsset"/>
+ </set>
+ <set name="propertyAssets" fetch="join" cascade="refresh" inverse="true">
+ <key column="PARENT_ID"/>
+ <one-to-many class="PropertyAsset"/>
+ </set>
+ </class>
+ <class name="Asset">
+ <id name="id">
+ <generator class="native"/>
+ </id>
+ <many-to-one name="parent" column="PARENT_ID" property-ref="parent"/>
+ <joined-subclass name="FinancialAsset">
+ <key column="ID"/>
+ <property name="price"/>
+ </joined-subclass>
+ <joined-subclass name="PropertyAsset">
+ <key column="ID"/>
+ <property name="price"/>
+ </joined-subclass>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Asset.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Asset.java 2006-09-05 16:49:05 UTC (rev 10452)
+++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Asset.java 2006-09-05 20:38:24 UTC (rev 10453)
@@ -0,0 +1,41 @@
+//$Id: $
+package org.hibernate.test.annotations.inheritance.joined;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Inheritance(strategy = InheritanceType.JOINED)
+@Table(name = "TBLASSET")
+public class Asset {
+ private Integer id;
+
+ private Parent parent = null;
+
+ @Id @GeneratedValue public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ @ManyToOne(targetEntity = Parent.class)
+ @JoinColumn(name = "PARENTID")
+ public Parent getParent() {
+ return parent;
+ }
+
+ public void setParent(Parent parent) {
+ this.parent = parent;
+ }
+}
Added: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/FinancialAsset.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/FinancialAsset.java 2006-09-05 16:49:05 UTC (rev 10452)
+++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/FinancialAsset.java 2006-09-05 20:38:24 UTC (rev 10453)
@@ -0,0 +1,20 @@
+//$Id: $
+package org.hibernate.test.annotations.inheritance.joined;
+
+import javax.persistence.Entity;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class FinancialAsset extends Asset {
+ private double price;
+
+ public double getPrice() {
+ return price;
+ }
+
+ public void setPrice(double price) {
+ this.price = price;
+ }
+}
Added: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassAndSecondaryTable.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassAndSecondaryTable.java 2006-09-05 16:49:05 UTC (rev 10452)
+++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassAndSecondaryTable.java 2006-09-05 20:38:24 UTC (rev 10453)
@@ -0,0 +1,33 @@
+//$Id: $
+package org.hibernate.test.annotations.inheritance.joined;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.test.annotations.TestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class JoinedSubclassAndSecondaryTable extends TestCase {
+
+ public void testSecondaryTableAndJoined() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ SwimmingPool sp = new SwimmingPool();
+ sp.setAddress( "Park Avenue" );
+ s.persist( sp );
+ tx.rollback();
+ s.close();
+ }
+
+ /**
+ * @see org.hibernate.test.annotations.TestCase#getMappings()
+ */
+ protected Class[] getMappings() {
+ return new Class[]{
+ Pool.class,
+ SwimmingPool.class
+ };
+ }
+
+}
Modified: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassTest.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassTest.java 2006-09-05 16:49:05 UTC (rev 10452)
+++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/JoinedSubclassTest.java 2006-09-05 20:38:24 UTC (rev 10453)
@@ -123,6 +123,37 @@
session.close();
}
+// public void testManyToOneAndJoin() throws Exception {
+// Session session = openSession();
+// Transaction transaction = session.beginTransaction();
+// Parent parent = new Parent();
+// session.persist( parent );
+// PropertyAsset property = new PropertyAsset();
+// property.setParent( parent );
+// property.setPrice( 230000d );
+// FinancialAsset financial = new FinancialAsset();
+// financial.setParent( parent );
+// financial.setPrice( 230000d );
+// session.persist( financial );
+// session.persist( property );
+// session.flush();
+// session.clear();
+// parent = (Parent) session.get( Parent.class, parent.getId() );
+// assertNotNull( parent );
+// assertEquals( 1, parent.getFinancialAssets().size() );
+// assertEquals( 1, parent.getPropertyAssets().size() );
+// assertEquals( property.getId(), parent.getPropertyAssets().iterator().next() );
+// transaction.rollback();
+// session.close();
+// }
+
+ @Override
+ protected String[] getXmlFiles() {
+ return new String[] {
+ //"org/hibernate/test/annotations/inheritance/joined/Asset.hbm.xml"
+ };
+ }
+
/**
* @see org.hibernate.test.annotations.TestCase#getMappings()
*/
@@ -136,7 +167,11 @@
Clothing.class,
Sweater.class,
EventInformation.class,
- Alarm.class
+ Alarm.class,
+ //Asset.class,
+ //Parent.class,
+ //PropertyAsset.class,
+ //FinancialAsset.class
};
}
Added: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Parent.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Parent.java 2006-09-05 16:49:05 UTC (rev 10452)
+++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Parent.java 2006-09-05 20:38:24 UTC (rev 10453)
@@ -0,0 +1,49 @@
+//$Id: $
+package org.hibernate.test.annotations.inheritance.joined;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Table(name = "Parent")
+public class Parent {
+ private Integer id;
+ private Set propertyAssets = new HashSet();
+ private Set financialAssets = new HashSet();
+
+ @Id @GeneratedValue public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ @OneToMany(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER, mappedBy = "parent", targetEntity = PropertyAsset.class)
+ public Set getPropertyAssets() {
+ return this.propertyAssets;
+ }
+
+ public void setPropertyAssets(Set propertyAssets) {
+ this.propertyAssets = propertyAssets;
+ }
+
+ @OneToMany(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER, mappedBy = "parent", targetEntity = FinancialAsset.class)
+ public Set getFinancialAssets() {
+ return this.financialAssets;
+ }
+
+ public void setFinancialAssets(Set financialAssets) {
+ this.financialAssets = financialAssets;
+ }
+}
Added: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Pool.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Pool.java 2006-09-05 16:49:05 UTC (rev 10452)
+++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/Pool.java 2006-09-05 20:38:24 UTC (rev 10453)
@@ -0,0 +1,38 @@
+//$Id: $
+package org.hibernate.test.annotations.inheritance.joined;
+
+import javax.persistence.Entity;
+import javax.persistence.SecondaryTable;
+import javax.persistence.Column;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Inheritance(strategy = InheritanceType.JOINED)
+@SecondaryTable(name="POOL_ADDRESS")
+public class Pool {
+ @Id @GeneratedValue private Integer id;
+ @Column(table = "POOL_ADDRESS")
+ private String address;
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+}
Added: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/PropertyAsset.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/PropertyAsset.java 2006-09-05 16:49:05 UTC (rev 10452)
+++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/PropertyAsset.java 2006-09-05 20:38:24 UTC (rev 10453)
@@ -0,0 +1,20 @@
+//$Id: $
+package org.hibernate.test.annotations.inheritance.joined;
+
+import javax.persistence.Entity;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class PropertyAsset extends Asset {
+ private double price;
+
+ public double getPrice() {
+ return price;
+ }
+
+ public void setPrice(double price) {
+ this.price = price;
+ }
+}
Added: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/SwimmingPool.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/SwimmingPool.java 2006-09-05 16:49:05 UTC (rev 10452)
+++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/inheritance/joined/SwimmingPool.java 2006-09-05 20:38:24 UTC (rev 10453)
@@ -0,0 +1,11 @@
+//$Id: $
+package org.hibernate.test.annotations.inheritance.joined;
+
+import javax.persistence.Entity;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class SwimmingPool extends Pool {
+}
\ No newline at end of file
18 years, 3 months
Hibernate SVN: r10452 - in trunk/HibernateExt/metadata/src: java/org/hibernate/cfg java/org/hibernate/reflection/java test/org/hibernate/test/annotations/generics
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-09-05 12:49:05 -0400 (Tue, 05 Sep 2006)
New Revision: 10452
Added:
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/State.java
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/StateType.java
Modified:
trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationBinder.java
trunk/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXClass.java
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/Gene.java
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/UnresolvedTypeTest.java
Log:
ANN-181 do not raise unresolved type exception if a @Type is defined
Modified: trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationBinder.java 2006-09-05 06:53:46 UTC (rev 10451)
+++ trunk/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationBinder.java 2006-09-05 16:49:05 UTC (rev 10452)
@@ -942,7 +942,7 @@
log.debug( "Processing " + propertyHolder.getEntityName() + " " + accessType + " annotation" );
List<XProperty> properties = annotatedClass.getDeclaredProperties( accessType );
for ( XProperty p : properties ) {
- if ( !p.isTypeResolved() && !hasExplicitTargetEntity( p ) && !mustBeSkipped( p, mappings ) ) {
+ if ( !p.isTypeResolved() && !discoverTypeWithoutReflection( p ) && !mustBeSkipped( p, mappings ) ) {
throw new IllegalStateException(
"Property " + p + " has an unbound type and no explicit target entity."
);
@@ -953,7 +953,7 @@
return hasIdentifier;
}
- private static boolean hasExplicitTargetEntity(XProperty p) {
+ private static boolean discoverTypeWithoutReflection(XProperty p) {
if ( p.isAnnotationPresent( OneToOne.class ) && !p.getAnnotation( OneToOne.class )
.targetEntity()
.equals( void.class ) ) {
@@ -974,6 +974,9 @@
.equals( void.class ) ) {
return true;
}
+ if (p.isAnnotationPresent( Type.class ) ) {
+ return true;
+ }
return false;
}
Modified: trunk/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXClass.java
===================================================================
--- trunk/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXClass.java 2006-09-05 06:53:46 UTC (rev 10451)
+++ trunk/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXClass.java 2006-09-05 16:49:05 UTC (rev 10452)
@@ -31,7 +31,6 @@
}
public XClass getSuperclass() {
- //FIXME we do not pass the class TypeEnvironment here
//return getFactory().toXClass( toClass().getSuperclass(), getFactory().getTypeEnvironment( toClass() ) );
return getFactory().toXClass( toClass().getSuperclass(),
new CompoundTypeEnvironment( getTypeEnvironment(), getFactory().getTypeEnvironment( toClass() )
@@ -45,7 +44,7 @@
XClass[] xClasses = new XClass[length];
//TypeEnvironment environment = getFactory().getTypeEnvironment( toClass() );
TypeEnvironment environment =
- new CompoundTypeEnvironment( getTypeEnvironment(), getFactory().getTypeEnvironment( toClass() ) );
+ new CompoundTypeEnvironment( getTypeEnvironment(), getFactory().getTypeEnvironment( toClass() ) );
for ( int index = 0; index < length ; index++ ) {
xClasses[index] = getFactory().toXClass( classes[index], environment );
}
Modified: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/Gene.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/Gene.java 2006-09-05 06:53:46 UTC (rev 10451)
+++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/Gene.java 2006-09-05 16:49:05 UTC (rev 10452)
@@ -5,14 +5,26 @@
import javax.persistence.Id;
import javax.persistence.ManyToOne;
+import org.hibernate.annotations.Type;
+
/**
* @author Paolo Perrotta
*/
@Entity
-public class Gene<T> {
+public class Gene<T, STE extends Enum> {
private Integer id;
+ private STE state;
+ @Type(type="org.hibernate.test.annotations.generics.StateType")
+ public STE getState() {
+ return state;
+ }
+
+ public void setState(STE state) {
+ this.state = state;
+ }
+
@Id
@GeneratedValue
public Integer getId() {
Added: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/State.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/State.java 2006-09-05 06:53:46 UTC (rev 10451)
+++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/State.java 2006-09-05 16:49:05 UTC (rev 10452)
@@ -0,0 +1,10 @@
+//$Id: $
+package org.hibernate.test.annotations.generics;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public enum State {
+ ACTIVE,
+ DORMANT
+}
Added: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/StateType.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/StateType.java 2006-09-05 06:53:46 UTC (rev 10451)
+++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/StateType.java 2006-09-05 16:49:05 UTC (rev 10452)
@@ -0,0 +1,69 @@
+//$Id: $
+package org.hibernate.test.annotations.generics;
+
+import java.io.Serializable;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.PreparedStatement;
+import java.sql.Types;
+
+import org.hibernate.usertype.UserType;
+import org.hibernate.HibernateException;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class StateType implements UserType {
+ public int[] sqlTypes() {
+ return new int[] {
+ Types.INTEGER
+ };
+ }
+
+ public Class returnedClass() {
+ return State.class;
+ }
+
+ public boolean equals(Object x, Object y) throws HibernateException {
+ return x == y;
+ }
+
+ public int hashCode(Object x) throws HibernateException {
+ return x.hashCode();
+ }
+
+ public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
+ int result = rs.getInt( names[0] );
+ if ( rs.wasNull() ) return null;
+ return State.values()[result];
+ }
+
+ public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
+ if (value == null) {
+ st.setNull( index, Types.INTEGER );
+ }
+ else {
+ st.setInt( index, ( (State) value ).ordinal() );
+ }
+ }
+
+ public Object deepCopy(Object value) throws HibernateException {
+ return value;
+ }
+
+ public boolean isMutable() {
+ return false;
+ }
+
+ public Serializable disassemble(Object value) throws HibernateException {
+ return (Serializable) value;
+ }
+
+ public Object assemble(Serializable cached, Object owner) throws HibernateException {
+ return cached;
+ }
+
+ public Object replace(Object original, Object target, Object owner) throws HibernateException {
+ return original;
+ }
+}
Modified: trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/UnresolvedTypeTest.java
===================================================================
--- trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/UnresolvedTypeTest.java 2006-09-05 06:53:46 UTC (rev 10451)
+++ trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/generics/UnresolvedTypeTest.java 2006-09-05 16:49:05 UTC (rev 10452)
@@ -19,6 +19,20 @@
s.close();
}
+ public void testAcceptsUnresolvedPropertyTypesIfATypeExplicitlySet() {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ Gene item = new Gene();
+ item.setState( State.DORMANT );
+ s.persist( item );
+ s.flush();
+ s.clear();
+ item = (Gene) s.get( Gene.class, item.getId() );
+ assertEquals( State.DORMANT, item.getState() );
+ tx.rollback();
+ s.close();
+ }
+
@Override
protected Class[] getMappings() {
return new Class[]{
18 years, 3 months
Hibernate SVN: r10451 - in trunk: Hibernate3/src/org/hibernate/engine HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-09-05 02:53:46 -0400 (Tue, 05 Sep 2006)
New Revision: 10451
Added:
trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/FetchTest2.java
trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Soldier2.java
trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Troop2.java
Modified:
trunk/Hibernate3/src/org/hibernate/engine/CascadingAction.java
Log:
EJB-221 TransientObjectException raised on proxies during persist_on_fllush.noCascade()
Modified: trunk/Hibernate3/src/org/hibernate/engine/CascadingAction.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/CascadingAction.java 2006-09-04 10:54:02 UTC (rev 10450)
+++ trunk/Hibernate3/src/org/hibernate/engine/CascadingAction.java 2006-09-05 06:53:46 UTC (rev 10451)
@@ -11,6 +11,7 @@
import org.hibernate.LockMode;
import org.hibernate.ReplicationMode;
import org.hibernate.TransientObjectException;
+import org.hibernate.proxy.HibernateProxy;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.collection.PersistentCollection;
import org.hibernate.event.EventSource;
@@ -344,7 +345,9 @@
if ( type.isEntityType() ) {
String childEntityName = ( ( EntityType ) type ).getAssociatedEntityName( session.getFactory() );
- if ( ! isInManagedState( child, session ) && ForeignKeys.isTransient( childEntityName, child, null, session ) ) {
+ if ( ! isInManagedState( child, session )
+ && ! ( child instanceof HibernateProxy ) //a proxy cannot be transient and it breaks ForeignKeys.isTransient
+ && ForeignKeys.isTransient( childEntityName, child, null, session ) ) {
String parentEntiytName = persister.getEntityName();
String propertyName = persister.getPropertyNames()[propertyIndex];
throw new TransientObjectException(
Added: trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/FetchTest2.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/FetchTest2.java 2006-09-04 10:54:02 UTC (rev 10450)
+++ trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/FetchTest2.java 2006-09-05 06:53:46 UTC (rev 10451)
@@ -0,0 +1,67 @@
+package org.hibernate.ejb.test.cascade;
+
+import javax.persistence.EntityManager;
+
+import org.hibernate.ejb.test.TestCase;
+
+public class FetchTest2 extends TestCase {
+
+ public void testProxyTransientStuff() throws Exception {
+
+ EntityManager em = factory.createEntityManager();
+ em.getTransaction().begin();
+
+ Troop2 disney = new Troop2();
+ disney.setName( "Disney" );
+
+ Soldier2 mickey = new Soldier2();
+ mickey.setName( "Mickey" );
+ mickey.setTroop( disney );
+
+ em.persist( disney );
+ em.persist( mickey );
+
+ em.getTransaction().commit();
+ em.close();
+
+ em = factory.createEntityManager();
+ em.getTransaction().begin();
+
+ Soldier2 soldier = em.find( Soldier2.class, mickey.getId() );
+ soldier.getTroop().getId();
+ try {
+ em.flush();
+ }
+ catch (IllegalStateException e) {
+ fail( "Should not raise an exception" );
+ }
+
+ em.getTransaction().commit();
+ em.close();
+
+ em = factory.createEntityManager();
+ em.getTransaction().begin();
+
+ //load troop wo a proxy
+ disney = em.find( Troop2.class, disney.getId() );
+ soldier = em.find( Soldier2.class, mickey.getId() );
+
+ try {
+ em.flush();
+ }
+ catch (IllegalStateException e) {
+ fail( "Should not raise an exception" );
+ }
+ em.remove( soldier );
+ em.remove( disney );
+ em.getTransaction().commit();
+ em.close();
+ }
+
+ public Class[] getAnnotatedClasses() {
+ return new Class[]{
+ Troop2.class,
+ Soldier2.class
+ };
+ }
+}
Added: trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Soldier2.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Soldier2.java 2006-09-04 10:54:02 UTC (rev 10450)
+++ trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Soldier2.java 2006-09-05 06:53:46 UTC (rev 10451)
@@ -0,0 +1,62 @@
+package org.hibernate.ejb.test.cascade;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Soldier2 implements Serializable {
+ private Integer id;
+ private String name;
+ private Troop2 troop;
+
+ @Id
+ @GeneratedValue
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "troop_fk")
+ public Troop2 getTroop() {
+ return troop;
+ }
+
+ public void setTroop(Troop2 troop) {
+ this.troop = troop;
+ }
+
+ public boolean equals(Object o) {
+ if ( this == o ) return true;
+ if ( !( o instanceof Soldier2 ) ) return false;
+
+ final Soldier2 soldier = (Soldier2) o;
+
+ if ( !name.equals( soldier.name ) ) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ return name.hashCode();
+ }
+}
Added: trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Troop2.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Troop2.java 2006-09-04 10:54:02 UTC (rev 10450)
+++ trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/cascade/Troop2.java 2006-09-05 06:53:46 UTC (rev 10451)
@@ -0,0 +1,40 @@
+package org.hibernate.ejb.test.cascade;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Troop2 implements Serializable {
+
+ /* FAILS: */
+ @Id
+ @GeneratedValue
+ private Integer id;
+ private String name;
+
+ /* WORKS:
+ @Id
+ @GeneratedValue
+ */
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
18 years, 3 months
Hibernate SVN: r10450 - trunk/Hibernate3/doc/reference/ko/modules
by hibernate-commits@lists.jboss.org
Author: jdkim528
Date: 2006-09-04 06:54:02 -0400 (Mon, 04 Sep 2006)
New Revision: 10450
Modified:
trunk/Hibernate3/doc/reference/ko/modules/basic_mapping.xml
Log:
Modified: trunk/Hibernate3/doc/reference/ko/modules/basic_mapping.xml
===================================================================
--- trunk/Hibernate3/doc/reference/ko/modules/basic_mapping.xml 2006-09-03 07:02:17 UTC (rev 10449)
+++ trunk/Hibernate3/doc/reference/ko/modules/basic_mapping.xml 2006-09-04 10:54:02 UTC (rev 10450)
@@ -2263,7 +2263,8 @@
<title>join</title>
<para>
- <literal><join></literal> 요소를 사용하면, 한 개의 클래스의 프로퍼티들을 몇 개의 테이블들로 매핑시키는 것이
+ <literal><join></literal> 테이블들 사이에 1대일 관계가 존재할 때,
+ 요소를 사용하여 하나의 클래스에 속한 프로퍼티들을 몇 개의 테이블들로 매핑시키는 것이
가능하다.
</para>
18 years, 3 months
Hibernate SVN: r10448 - trunk/Hibernate3/doc/reference/ko/fop
by hibernate-commits@lists.jboss.org
Author: jdkim528
Date: 2006-09-03 03:01:05 -0400 (Sun, 03 Sep 2006)
New Revision: 10448
Modified:
trunk/Hibernate3/doc/reference/ko/fop/userconfig.xml
Log:
Replaced Gulim font With Hankc
Modified: trunk/Hibernate3/doc/reference/ko/fop/userconfig.xml
===================================================================
--- trunk/Hibernate3/doc/reference/ko/fop/userconfig.xml 2006-09-03 07:00:02 UTC (rev 10447)
+++ trunk/Hibernate3/doc/reference/ko/fop/userconfig.xml 2006-09-03 07:01:05 UTC (rev 10448)
@@ -92,11 +92,11 @@
<font-triplet name="Mincho" style="italic" weight="bold"/>
</font>
-->
- <font metrics-file="Gulim.xml" kerning="yes" embed-file="C:\windows\fonts\gulim.ttc">
- <font-triplet name="Gulim" style="normal" weight="normal"/>
- <font-triplet name="Gulim" style="normal" weight="bold"/>
- <font-triplet name="Gulim" style="italic" weight="normal"/>
- <font-triplet name="Gulim" style="italic" weight="bold"/>
+ <font metrics-file="Hankc.xml" kerning="yes" embed-file="Hankc.ttf">
+ <font-triplet name="Hankc" style="normal" weight="normal"/>
+ <font-triplet name="Hankc" style="normal" weight="bold"/>
+ <font-triplet name="Hankc" style="italic" weight="normal"/>
+ <font-triplet name="Hankc" style="italic" weight="bold"/>
</font>
<font metrics-file="Bangwool.xml" kerning="yes" embed-file="Bangwool.ttf">
<font-triplet name="Bangwool" style="normal" weight="normal"/>
18 years, 4 months