Hibernate SVN: r11000 - in branches/Branch_3_2/HibernateExt/metadata/src: java/org/hibernate/annotations java/org/hibernate/cfg java/org/hibernate/cfg/annotations test/org/hibernate/test/annotations test/org/hibernate/test/annotations/tuplizer
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-12-19 06:38:26 -0500 (Tue, 19 Dec 2006)
New Revision: 11000
Added:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/annotations/Tuplizer.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/annotations/Tuplizers.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/Country.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/Cuisine.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/DataProxyHandler.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/DynamicComponentTuplizer.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/DynamicEntityTuplizer.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/DynamicInstantiator.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/EntityNameInterceptor.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/ProxyHelper.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/TuplizerTest.java
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationBinder.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/InheritanceState.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/TestCase.java
Log:
ANN-505 add @Tuplizer and allow interface annotations (not subclassed by real classes though)
Added: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/annotations/Tuplizer.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/annotations/Tuplizer.java 2006-12-18 20:58:17 UTC (rev 10999)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/annotations/Tuplizer.java 2006-12-19 11:38:26 UTC (rev 11000)
@@ -0,0 +1,21 @@
+//$Id: $
+package org.hibernate.annotations;
+
+import java.lang.annotation.*;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+
+/**
+ * Define a tuplizer for an entity or a component
+ * @author Emmanuel Bernard
+ */
+(a)java.lang.annotation.Target( {TYPE, FIELD, METHOD} )
+@Retention( RUNTIME )
+public @interface Tuplizer {
+ /** tuplizer implementation */
+ Class impl();
+ /** either pojo, dynamic-map or domj4 */
+ String entityMode() default "pojo";
+}
Added: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/annotations/Tuplizers.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/annotations/Tuplizers.java 2006-12-18 20:58:17 UTC (rev 10999)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/annotations/Tuplizers.java 2006-12-19 11:38:26 UTC (rev 11000)
@@ -0,0 +1,16 @@
+//$Id: $
+package org.hibernate.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Define a set of tuplizer for an entity or a component
+ * @author Emmanuel Bernard
+ */
+(a)java.lang.annotation.Target( {ElementType.TYPE, ElementType.FIELD, ElementType.METHOD} )
+@Retention( RetentionPolicy.RUNTIME )
+public @interface Tuplizers {
+ Tuplizer[] value();
+}
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationBinder.java 2006-12-18 20:58:17 UTC (rev 10999)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationBinder.java 2006-12-19 11:38:26 UTC (rev 11000)
@@ -53,6 +53,7 @@
import org.hibernate.AssertionFailure;
import org.hibernate.FetchMode;
import org.hibernate.MappingException;
+import org.hibernate.EntityMode;
import org.hibernate.annotations.AccessType;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
@@ -89,6 +90,8 @@
import org.hibernate.annotations.Where;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.Target;
+import org.hibernate.annotations.Tuplizers;
+import org.hibernate.annotations.Tuplizer;
import org.hibernate.cfg.annotations.CollectionBinder;
import org.hibernate.cfg.annotations.EntityBinder;
import org.hibernate.cfg.annotations.Nullability;
@@ -840,7 +843,7 @@
superClass = superClass.getSuperclass();
superclassState = inheritanceStatePerClass.get( superClass );
}
- while ( !mappings.getReflectionManager().equals( superClass, Object.class ) && superclassState == null );
+ while ( superClass != null && !mappings.getReflectionManager().equals( superClass, Object.class ) && superclassState == null );
currentClassInHierarchy = superClass;
}
@@ -1610,6 +1613,8 @@
isComponentEmbedded, isIdentifierMapper,
false, mappings
);
+ XProperty property = inferredData.getProperty();
+ setupComponentTuplizer( property, comp );
PropertyBinder binder = new PropertyBinder();
binder.setName( inferredData.getPropertyName() );
@@ -1710,6 +1715,9 @@
if ( componentId.getPropertySpan() == 0 ) {
throw new AnnotationException( componentId.getComponentClassName() + " has no persistent id property" );
}
+ //tuplizers
+ XProperty property = inferredData.getProperty();
+ setupComponentTuplizer( property, componentId );
}
else {
for ( Ejb3Column column : columns ) {
@@ -1740,6 +1748,21 @@
}
}
+ private static void setupComponentTuplizer(XProperty property, Component component) {
+ if (property == null) return;
+ if (property.isAnnotationPresent( Tuplizers.class ) ) {
+ for ( Tuplizer tuplizer : property.getAnnotation( Tuplizers.class ).value() ) {
+ EntityMode mode = EntityMode.parse( tuplizer.entityMode() );
+ component.addTuplizer( mode, tuplizer.impl().getName() );
+ }
+ }
+ if ( property.isAnnotationPresent( Tuplizer.class ) ) {
+ Tuplizer tuplizer = property.getAnnotation( Tuplizer.class );
+ EntityMode mode = EntityMode.parse( tuplizer.entityMode() );
+ component.addTuplizer( mode, tuplizer.impl().getName() );
+ }
+ }
+
private static void bindManyToOne(
String cascadeStrategy, Ejb3JoinColumn[] columns, boolean optional,
boolean ignoreNotFound, boolean cascadeOnDelete,
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java 2006-12-18 20:58:17 UTC (rev 10999)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationConfiguration.java 2006-12-19 11:38:26 UTC (rev 11000)
@@ -97,7 +97,7 @@
//for each class, copy all the relevent hierarchy
for ( XClass clazz : original ) {
XClass superClass = clazz.getSuperclass();
- while ( ! reflectionManager.equals( superClass, Object.class ) && ! copy.contains( superClass ) ) {
+ while ( superClass != null && ! reflectionManager.equals( superClass, Object.class ) && ! copy.contains( superClass ) ) {
if ( superClass.isAnnotationPresent( Entity.class )
|| superClass.isAnnotationPresent( MappedSuperclass.class ) ) {
copy.add( superClass );
@@ -115,7 +115,7 @@
}
private void orderHierarchy(List<XClass> copy, List<XClass> newList, List<XClass> original, XClass clazz) {
- if ( reflectionManager.equals( clazz, Object.class ) ) return;
+ if ( clazz == null || reflectionManager.equals( clazz, Object.class ) ) return;
//process superclass first
orderHierarchy( copy, newList, original, clazz.getSuperclass() );
if ( original.contains( clazz ) ) {
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/InheritanceState.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/InheritanceState.java 2006-12-18 20:58:17 UTC (rev 10999)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/InheritanceState.java 2006-12-19 11:38:26 UTC (rev 11000)
@@ -70,7 +70,7 @@
InheritanceState currentState = states.get( superclass );
if ( currentState != null && ! currentState.isEmbeddableSuperclass ) return currentState;
}
- while ( ! reflectionManager.equals( superclass, Object.class ) );
+ while ( superclass != null && ! reflectionManager.equals( superclass, Object.class ) );
return null;
}
@@ -84,7 +84,7 @@
InheritanceState currentState = states.get( superclass );
if ( currentState != null ) return currentState;
}
- while ( ! reflectionManager.equals( superclass, Object.class ) );
+ while ( superclass != null && ! reflectionManager.equals( superclass, Object.class ) );
return null;
}
}
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java 2006-12-18 20:58:17 UTC (rev 10999)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/EntityBinder.java 2006-12-19 11:38:26 UTC (rev 11000)
@@ -19,6 +19,7 @@
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.MappingException;
+import org.hibernate.EntityMode;
import org.hibernate.annotations.AccessType;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
@@ -34,6 +35,8 @@
import org.hibernate.annotations.Tables;
import org.hibernate.annotations.Where;
import org.hibernate.annotations.SQLDeleteAll;
+import org.hibernate.annotations.Tuplizers;
+import org.hibernate.annotations.Tuplizer;
import org.hibernate.cache.CacheFactory;
import org.hibernate.cfg.AnnotationBinder;
import org.hibernate.cfg.BinderHelper;
@@ -225,6 +228,19 @@
persistentClass.setLoaderName( loader.namedQuery() );
}
+ //tuplizers
+ if ( annotatedClass.isAnnotationPresent( Tuplizers.class ) ) {
+ for ( Tuplizer tuplizer : annotatedClass.getAnnotation( Tuplizers.class ).value() ) {
+ EntityMode mode = EntityMode.parse( tuplizer.entityMode() );
+ persistentClass.addTuplizer( mode, tuplizer.impl().getName() );
+ }
+ }
+ if ( annotatedClass.isAnnotationPresent( Tuplizer.class ) ) {
+ Tuplizer tuplizer = annotatedClass.getAnnotation( Tuplizer.class );
+ EntityMode mode = EntityMode.parse( tuplizer.entityMode() );
+ persistentClass.addTuplizer( mode, tuplizer.impl().getName() );
+ }
+
if ( !inheritanceState.hasParents ) {
Iterator<Map.Entry<String, String>> iter = filters.entrySet().iterator();
while ( iter.hasNext() ) {
Modified: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/TestCase.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/TestCase.java 2006-12-18 20:58:17 UTC (rev 10999)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/TestCase.java 2006-12-19 11:38:26 UTC (rev 11000)
@@ -6,6 +6,7 @@
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
+import org.hibernate.Interceptor;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
@@ -101,6 +102,11 @@
return session;
}
+ public Session openSession(Interceptor interceptor) throws HibernateException {
+ session = getSessions().openSession(interceptor);
+ return session;
+ }
+
protected abstract Class[] getMappings();
protected String[] getAnnotatedPackages() {
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/Country.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/Country.java 2006-12-18 20:58:17 UTC (rev 10999)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/Country.java 2006-12-19 11:38:26 UTC (rev 11000)
@@ -0,0 +1,15 @@
+//$Id: $
+package org.hibernate.test.annotations.tuplizer;
+
+import javax.persistence.Embeddable;
+import javax.persistence.Column;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Embeddable
+public interface Country {
+ @Column(name = "CountryName")
+ public String getName();
+ public void setName(String name);
+}
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/Cuisine.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/Cuisine.java 2006-12-18 20:58:17 UTC (rev 10999)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/Cuisine.java 2006-12-19 11:38:26 UTC (rev 11000)
@@ -0,0 +1,29 @@
+//$Id: $
+package org.hibernate.test.annotations.tuplizer;
+
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Entity;
+
+import org.hibernate.annotations.Tuplizer;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Tuplizer(impl = DynamicEntityTuplizer.class)
+public interface Cuisine {
+ @Id
+ @GeneratedValue
+ public Long getId();
+ public void setId(Long id);
+
+ public String getName();
+ public void setName(String name);
+
+ @Tuplizer(impl = DynamicComponentTuplizer.class)
+ public Country getCountry();
+ public void setCountry(Country country);
+
+
+}
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/DataProxyHandler.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/DataProxyHandler.java 2006-12-18 20:58:17 UTC (rev 10999)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/DataProxyHandler.java 2006-12-19 11:38:26 UTC (rev 11000)
@@ -0,0 +1,53 @@
+//$Id: $
+package org.hibernate.test.annotations.tuplizer;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.io.Serializable;
+
+/**
+ * A simple {@link java.lang.reflect.InvocationHandler} to act as the handler for our generated
+ * {@link java.lang.reflect.Proxy}-based entity instances.
+ * <p/>
+ * This is a trivial impl which simply keeps the property values into
+ * a Map.
+ *
+ * @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
+ */
+public final class DataProxyHandler implements InvocationHandler {
+ private String entityName;
+ private HashMap data = new HashMap();
+
+ public DataProxyHandler(String entityName, Serializable id) {
+ this.entityName = entityName;
+ data.put( "Id", id );
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ String methodName = method.getName();
+ if ( methodName.startsWith( "set" ) ) {
+ String propertyName = methodName.substring( 3 );
+ data.put( propertyName, args[0] );
+ }
+ else if ( methodName.startsWith( "get" ) ) {
+ String propertyName = methodName.substring( 3 );
+ return data.get( propertyName );
+ }
+ else if ( "toString".equals( methodName ) ) {
+ return entityName + "#" + data.get( "Id" );
+ }
+ else if ( "hashCode".equals( methodName ) ) {
+ return new Integer( this.hashCode() );
+ }
+ return null;
+ }
+
+ public String getEntityName() {
+ return entityName;
+ }
+
+ public HashMap getData() {
+ return data;
+ }
+}
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/DynamicComponentTuplizer.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/DynamicComponentTuplizer.java 2006-12-18 20:58:17 UTC (rev 10999)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/DynamicComponentTuplizer.java 2006-12-19 11:38:26 UTC (rev 11000)
@@ -0,0 +1,29 @@
+//$Id: $
+package org.hibernate.test.annotations.tuplizer;
+
+import org.hibernate.tuple.entity.PojoEntityTuplizer;
+import org.hibernate.tuple.entity.EntityMetamodel;
+import org.hibernate.tuple.Instantiator;
+import org.hibernate.tuple.component.PojoComponentTuplizer;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Component;
+import org.hibernate.proxy.ProxyFactory;
+import org.hibernate.property.Getter;
+import org.hibernate.property.Setter;
+import org.hibernate.HibernateException;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class DynamicComponentTuplizer extends PojoComponentTuplizer {
+
+ public DynamicComponentTuplizer(Component component) {
+ super( component );
+ }
+
+
+ protected Instantiator buildInstantiator(Component component) {
+ return new DynamicInstantiator( component.getComponentClassName() ); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+}
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/DynamicEntityTuplizer.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/DynamicEntityTuplizer.java 2006-12-18 20:58:17 UTC (rev 10999)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/DynamicEntityTuplizer.java 2006-12-19 11:38:26 UTC (rev 11000)
@@ -0,0 +1,32 @@
+//$Id: $
+package org.hibernate.test.annotations.tuplizer;
+
+import org.hibernate.tuple.entity.PojoEntityTuplizer;
+import org.hibernate.tuple.entity.EntityMetamodel;
+import org.hibernate.tuple.Instantiator;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.proxy.ProxyFactory;
+import org.hibernate.property.Getter;
+import org.hibernate.property.Setter;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class DynamicEntityTuplizer extends PojoEntityTuplizer {
+
+ public DynamicEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity) {
+ super( entityMetamodel, mappedEntity );
+ }
+
+ protected Instantiator buildInstantiator(PersistentClass persistentClass) {
+ return new DynamicInstantiator( persistentClass.getEntityName() );
+ }
+
+ protected ProxyFactory buildProxyFactory(PersistentClass persistentClass, Getter idGetter, Setter idSetter) {
+ // allows defining a custom proxy factory, which is responsible for
+ // generating lazy proxies for a given entity.
+ //
+ // Here we simply use the default...
+ return super.buildProxyFactory( persistentClass, idGetter, idSetter );
+ }
+ }
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/DynamicInstantiator.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/DynamicInstantiator.java 2006-12-18 20:58:17 UTC (rev 10999)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/DynamicInstantiator.java 2006-12-19 11:38:26 UTC (rev 11000)
@@ -0,0 +1,56 @@
+//$Id: $
+package org.hibernate.test.annotations.tuplizer;
+
+import java.io.Serializable;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.InvocationHandler;
+
+import org.hibernate.tuple.Instantiator;
+import org.hibernate.util.ReflectHelper;
+import org.hibernate.HibernateException;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class DynamicInstantiator implements Instantiator {
+ private final String entityName;
+
+ public DynamicInstantiator(String entityName) {
+ this.entityName = entityName;
+ }
+
+ public Object instantiate(Serializable id) {
+ if ( Cuisine.class.getName().equals( entityName ) ) {
+ return ProxyHelper.newCuisineProxy( id );
+ }
+ if ( Country.class.getName().equals( entityName ) ) {
+ return ProxyHelper.newCountryProxy( id );
+ }
+ else {
+ throw new IllegalArgumentException( "unknown entity for instantiation [" + entityName + "]" );
+ }
+ }
+
+ public Object instantiate() {
+ return instantiate( null );
+ }
+
+ public boolean isInstance(Object object) {
+ String resolvedEntityName = null;
+ if ( Proxy.isProxyClass( object.getClass() ) ) {
+ InvocationHandler handler = Proxy.getInvocationHandler( object );
+ if ( DataProxyHandler.class.isAssignableFrom( handler.getClass() ) ) {
+ DataProxyHandler myHandler = ( DataProxyHandler ) handler;
+ resolvedEntityName = myHandler.getEntityName();
+ }
+ }
+ try {
+ return ReflectHelper.classForName( entityName ).isInstance( object );
+ }
+ catch( Throwable t ) {
+ throw new HibernateException( "could not get handle to entity-name as interface : " + t );
+ }
+
+// return entityName.equals( resolvedEntityName );
+ }
+}
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/EntityNameInterceptor.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/EntityNameInterceptor.java 2006-12-18 20:58:17 UTC (rev 10999)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/EntityNameInterceptor.java 2006-12-19 11:38:26 UTC (rev 11000)
@@ -0,0 +1,25 @@
+//$Id: $
+package org.hibernate.test.annotations.tuplizer;
+
+import org.hibernate.EmptyInterceptor;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class EntityNameInterceptor extends EmptyInterceptor {
+ /**
+ * The callback from Hibernate to determine the entity name given
+ * a presumed entity instance.
+ *
+ * @param object The presumed entity instance.
+ * @return The entity name (pointing to the proper entity mapping).
+ */
+ public String getEntityName(Object object) {
+ String entityName = ProxyHelper.extractEntityName( object );
+ if ( entityName == null ) {
+ entityName = super.getEntityName( object );
+ }
+ return entityName;
+ }
+}
+
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/ProxyHelper.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/ProxyHelper.java 2006-12-18 20:58:17 UTC (rev 10999)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/ProxyHelper.java 2006-12-19 11:38:26 UTC (rev 11000)
@@ -0,0 +1,50 @@
+//$Id: $
+package org.hibernate.test.annotations.tuplizer;
+
+import java.io.Serializable;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.InvocationHandler;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class ProxyHelper {
+
+ public static Country newPersonProxy() {
+ return newCountryProxy( null );
+ }
+
+ public static Country newCountryProxy(Serializable id) {
+ return ( Country ) Proxy.newProxyInstance(
+ Country.class.getClassLoader(),
+ new Class[] {Country.class},
+ new DataProxyHandler( Country.class.getName(), id )
+ );
+ }
+
+ public static Cuisine newCustomerProxy() {
+ return newCuisineProxy( null );
+ }
+
+ public static Cuisine newCuisineProxy(Serializable id) {
+ return ( Cuisine ) Proxy.newProxyInstance(
+ Cuisine.class.getClassLoader(),
+ new Class[] {Cuisine.class},
+ new DataProxyHandler( Cuisine.class.getName(), id )
+ );
+ }
+
+ public static String extractEntityName(Object object) {
+ // Our custom java.lang.reflect.Proxy instances actually bundle
+ // their appropriate entity name, so we simply extract it from there
+ // if this represents one of our proxies; otherwise, we return null
+ if ( Proxy.isProxyClass( object.getClass() ) ) {
+ InvocationHandler handler = Proxy.getInvocationHandler( object );
+ if ( DataProxyHandler.class.isAssignableFrom( handler.getClass() ) ) {
+ DataProxyHandler myHandler = ( DataProxyHandler ) handler;
+ return myHandler.getEntityName();
+ }
+ }
+ return null;
+ }
+}
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/TuplizerTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/TuplizerTest.java 2006-12-18 20:58:17 UTC (rev 10999)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/tuplizer/TuplizerTest.java 2006-12-19 11:38:26 UTC (rev 11000)
@@ -0,0 +1,34 @@
+//$Id: $
+package org.hibernate.test.annotations.tuplizer;
+
+import org.hibernate.test.annotations.TestCase;
+import org.hibernate.Session;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class TuplizerTest extends TestCase {
+ public void testEntityTuplizer() throws Exception {
+ Cuisine cuisine = ProxyHelper.newCuisineProxy( null );
+ cuisine.setName( "Fran�aise" );
+ Country country = ProxyHelper.newCountryProxy( null );
+ country.setName( "France" );
+ cuisine.setCountry( country );
+ Session s = openSession( new EntityNameInterceptor() );
+ s.getTransaction().begin();
+ s.persist( cuisine );
+ s.flush();
+ s.clear();
+ cuisine = (Cuisine) s.get(Cuisine.class, cuisine.getId() );
+ assertNotNull( cuisine );
+ assertEquals( "Fran�aise", cuisine.getName() );
+ assertEquals( "France", country.getName() );
+ s.getTransaction().rollback();
+ s.close();
+ }
+ protected Class[] getMappings() {
+ return new Class[] {
+ Cuisine.class
+ };
+ }
+}
17 years, 11 months
Hibernate SVN: r10999 - in branches/Branch_3_2/HibernateExt/tools/src: java/org/hibernate/tool/ant java/org/hibernate/tool/hbm2x test/org/hibernate/tool/ant test/org/hibernate/tool/hbm2x testsupport
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-12-18 15:58:17 -0500 (Mon, 18 Dec 2006)
New Revision: 10999
Added:
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntHibernateToolTest.java
Removed:
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/HibernateToolTest.java
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/ant/GenericExporterTask.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/ant/HibernateToolTask.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/GenericExporter.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntAllTests.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/GenericExporterTest.java
branches/Branch_3_2/HibernateExt/tools/src/testsupport/anttest-build.xml
Log:
HBX-842 add control to hbmtemplate about what model parts should be processed
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/ant/GenericExporterTask.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/ant/GenericExporterTask.java 2006-12-15 16:30:55 UTC (rev 10998)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/ant/GenericExporterTask.java 2006-12-18 20:58:17 UTC (rev 10999)
@@ -22,6 +22,7 @@
String templateName;
String exporterClass;
String filePattern;
+ String forEach;
/**
* The FilePattern defines the pattern used to generate files.
@@ -31,6 +32,10 @@
this.filePattern = filePattern;
}
+ public void setForEach(String forEach) {
+ this.forEach = forEach;
+ }
+
public void setTemplate(String templateName) {
this.templateName = templateName;
}
@@ -62,7 +67,8 @@
if(exp instanceof GenericExporter) {
GenericExporter exporter = (GenericExporter) exp;
if(filePattern!=null) exporter.setFilePattern(filePattern);
- if(templateName!=null) exporter.setTemplateName(templateName);
+ if(templateName!=null) exporter.setTemplateName(templateName);
+ if(forEach!=null) exporter.setForEach(forEach);
}
return exp;
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/ant/HibernateToolTask.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/ant/HibernateToolTask.java 2006-12-15 16:30:55 UTC (rev 10998)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/ant/HibernateToolTask.java 2006-12-18 20:58:17 UTC (rev 10999)
@@ -148,7 +148,8 @@
public void setClasspath(Path s) {
classPath = s;
}
-
+
+
/**
* Adds a path to the classpath.
*
@@ -324,4 +325,5 @@
properties.put(property.getKey(), property.getValue());
}
+
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/GenericExporter.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/GenericExporter.java 2006-12-15 16:30:55 UTC (rev 10998)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/GenericExporter.java 2006-12-18 20:58:17 UTC (rev 10999)
@@ -1,11 +1,15 @@
package org.hibernate.tool.hbm2x;
import java.io.File;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
+import java.util.StringTokenizer;
import org.hibernate.cfg.Configuration;
+import org.hibernate.engine.CascadeStyle;
import org.hibernate.mapping.Component;
import org.hibernate.tool.hbm2x.pojo.ComponentPOJOClass;
import org.hibernate.tool.hbm2x.pojo.POJOClass;
@@ -14,8 +18,56 @@
public class GenericExporter extends AbstractExporter {
+ static abstract class ModelIterator {
+ abstract void process(GenericExporter ge);
+ }
+
+ static Map modelIterators = new HashMap();
+ static {
+ modelIterators.put( "configuration", new ModelIterator() {
+
+ void process(GenericExporter ge) {
+ TemplateProducer producer = new TemplateProducer(ge.getTemplateHelper(),ge.getArtifactCollector());
+ producer.produce(new HashMap(), ge.getTemplateName(), new File(ge.getOutputDirectory(),ge.filePattern), ge.templateName);
+ }
+
+ });
+ modelIterators.put("entity", new ModelIterator() {
+
+ void process(GenericExporter ge) {
+ Iterator iterator = ge.getCfg2JavaTool().getPOJOIterator(ge.getConfiguration().getClassMappings());
+ Map additionalContext = new HashMap();
+ while ( iterator.hasNext() ) {
+ POJOClass element = (POJOClass) iterator.next();
+ ge.exportPersistentClass( additionalContext, element );
+ }
+ }
+ });
+ modelIterators.put("component", new ModelIterator() {
+
+ void process(GenericExporter ge) {
+ Map components = new HashMap();
+
+ Iterator iterator = ge.getCfg2JavaTool().getPOJOIterator(ge.getConfiguration().getClassMappings());
+ Map additionalContext = new HashMap();
+ while ( iterator.hasNext() ) {
+ POJOClass element = (POJOClass) iterator.next();
+ ConfigurationNavigator.collectComponents(components, element);
+ }
+
+ iterator = components.values().iterator();
+ while ( iterator.hasNext() ) {
+ Component component = (Component) iterator.next();
+ ComponentPOJOClass element = new ComponentPOJOClass(component,ge.getCfg2JavaTool());
+ ge.exportComponent( additionalContext, element );
+ }
+ }
+ });
+ }
+
private String templateName;
private String filePattern;
+ private String forEach;
public GenericExporter(Configuration cfg, File outputdir) {
super(cfg,outputdir);
@@ -31,38 +83,49 @@
public void setTemplateName(String templateName) {
this.templateName = templateName;
}
-
+
+
+ public void setForEach(String foreach) {
+ this.forEach = foreach;
+ }
+
+
protected void doStart() {
- if(filePattern==null) throw new ExporterException("File pattern not set on " + this.getClass());
- if(templateName==null) throw new ExporterException("Template name not set on " + this.getClass());
+ if(filePattern==null) {
+ throw new ExporterException("File pattern not set on " + this.getClass());
+ }
+ if(templateName==null) {
+ throw new ExporterException("Template name not set on " + this.getClass());
+ }
- if(filePattern.indexOf("{class-name}")>=0) {
- exportClasses();
+ List exporters = new ArrayList();
+
+ if(StringHelper.isEmpty( forEach )) {
+ if(filePattern.indexOf("{class-name}")>=0) {
+ exporters.add( modelIterators.get( "entity" ) );
+ exporters.add( modelIterators.get( "component") );
+ } else {
+ exporters.add( modelIterators.get( "configuration" ));
+ }
} else {
- TemplateProducer producer = new TemplateProducer(getTemplateHelper(),getArtifactCollector());
- producer.produce(new HashMap(), getTemplateName(), new File(getOutputDirectory(),filePattern), templateName);
+ StringTokenizer tokens = new StringTokenizer(forEach, ",");
+
+ while ( tokens.hasMoreTokens() ) {
+ String nextToken = tokens.nextToken();
+ Object object = modelIterators.get(nextToken);
+ if(object==null) {
+ throw new ExporterException("for-each does not support [" + nextToken + "]");
+ }
+ exporters.add( object );
+ }
}
- }
- private void exportClasses() {
- Map components = new HashMap();
-
- Iterator iterator = getCfg2JavaTool().getPOJOIterator(getConfiguration().getClassMappings());
- Map additionalContext = new HashMap();
- while ( iterator.hasNext() ) {
- POJOClass element = (POJOClass) iterator.next();
- ConfigurationNavigator.collectComponents(components, element);
- exportPersistentClass( additionalContext, element );
+ Iterator it = exporters.iterator();
+ while(it.hasNext()) {
+ ModelIterator mit = (ModelIterator) it.next();
+ mit.process( this );
}
-
- iterator = components.values().iterator();
- while ( iterator.hasNext() ) {
- Component component = (Component) iterator.next();
- ComponentPOJOClass element = new ComponentPOJOClass(component,getCfg2JavaTool());
- exportComponent( additionalContext, element );
- }
-
}
protected void exportComponent(Map additionalContext, POJOClass element) {
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntAllTests.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntAllTests.java 2006-12-15 16:30:55 UTC (rev 10998)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntAllTests.java 2006-12-18 20:58:17 UTC (rev 10999)
@@ -8,7 +8,7 @@
public static Test suite() {
TestSuite suite = new TestSuite("Test for org.hibernate.tool.ant");
//$JUnit-BEGIN$
- suite.addTestSuite(HibernateToolTest.class);
+ suite.addTestSuite(AntHibernateToolTest.class);
suite.addTestSuite(SeamAntTest.class);
suite.addTestSuite(JavaFormatterTest.class);
//$JUnit-END$
Copied: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntHibernateToolTest.java (from rev 10966, branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/HibernateToolTest.java)
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/HibernateToolTest.java 2006-12-09 12:10:27 UTC (rev 10966)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntHibernateToolTest.java 2006-12-18 20:58:17 UTC (rev 10999)
@@ -0,0 +1,203 @@
+/*
+ * Created on 13-Feb-2005
+ *
+ */
+package org.hibernate.tool.ant;
+
+import java.io.File;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.tools.ant.BuildException;
+import org.hibernate.tool.test.TestHelper;
+
+/**
+ * @author max
+ *
+ */
+public class AntHibernateToolTest extends BuildFileTestCase {
+
+ private String property;
+
+ public AntHibernateToolTest(String name) {
+ super(name);
+ }
+
+ protected void tearDown() throws Exception {
+ executeTarget("cleanup");
+ System.out.println(getLog());
+ super.tearDown();
+ }
+ protected void setUp() throws Exception {
+ configureProject("src/testsupport/anttest-build.xml");
+ }
+
+ public void testHbm2DDLLogic() {
+ executeTarget("testantcfg");
+ File baseDir = new File(project.getProperty("build.dir"), "topdown");
+ File onlyCreate = new File(baseDir, "onlycreate.sql");
+ File onlyDrop = new File(baseDir, "onlydrop.sql");
+ File dropAndCreate = new File(baseDir, "dropandcreate.sql");
+
+ assertTrue(onlyCreate.exists());
+ assertTrue(onlyDrop.exists());
+ assertTrue(dropAndCreate.exists());
+
+ assertNotNull(TestHelper.findFirstString("drop", dropAndCreate));
+ assertNotNull(TestHelper.findFirstString("create", dropAndCreate));
+
+ assertEquals(null, TestHelper.findFirstString("create", onlyDrop));
+ assertNotNull(TestHelper.findFirstString("drop", onlyDrop));
+
+ assertEquals(null, TestHelper.findFirstString("drop", onlyCreate));
+ assertNotNull(TestHelper.findFirstString("create", onlyCreate));
+
+ }
+
+ public void testJDBCConfiguration() {
+ executeTarget("testantjdbccfg");
+ }
+
+ public void testAnnotationConfigurationFailureExpected() {
+ executeTarget("testantannotationcfg");
+ }
+
+ public void testEJB3ConfigurationFailureExpected() {
+ executeTarget("testantejb3cfg");
+ File baseDir = new File(project.getProperty("build.dir"));
+ File ejb3 = new File(baseDir, "ejb3.sql");
+
+ assertTrue(ejb3.exists());
+ assertEquals(null, TestHelper.findFirstString("drop", ejb3));
+
+ assertTrue(getLog().indexOf("<ejb3configuration> is deprecated")>0);
+
+ }
+
+ public void testJPABogusPUnit() {
+ try {
+ executeTarget("jpa-bogusunit");
+ fail("Bogus unit accepted");
+ } catch(BuildException be) {
+ // should happen
+ }
+ }
+
+ public void testJPAPUnit() {
+ executeTarget("jpa-punit");
+ }
+
+ public void testHbm2JavaConfiguration() {
+ executeTarget("testanthbm2java");
+ }
+
+ public void testHbm2JavaEJB3Configuration() {
+ executeTarget("testantejb3hbm2java");
+ }
+
+ public void testCfg2HbmNoError() {
+ executeTarget("testantcfg2hbm1");
+ }
+
+ public void testCfg2HbmWithCustomReverseNamingStrategy() {
+ executeTarget("testantcfg2hbm2");
+ }
+
+ public void testCfg2HbmWithInvalidReverseNamingStrategy() {
+ expectSpecificBuildException("testantcfg2hbm3",
+ "namingStrategy attribute should not be loaded",
+ "Could not create or find invalid.classname with one argument delegate constructor");
+ }
+
+ public void testCfg2HbmWithPackageName() {
+ executeTarget("testantcfg2hbm4");
+ }
+
+ public void testCfg2HbmWithPackageNameAndReverseNamingStrategy() {
+ executeTarget("testantcfg2hbm5");
+ }
+
+
+ public void testJDBCConfigWithRevEngXml() {
+ executeTarget("testantjdbccfgoverrides");
+ }
+
+ public void testProperties() {
+ executeTarget("testproperties");
+ }
+
+ public void testGenericExport() {
+ executeTarget("testgeneric");
+
+ property = project.getProperty("build.dir");
+ assertTrue(new File(property, "generic").exists());
+ assertTrue(new File(property, "generic/org/hibernate/tool/hbm2x/ant/TopDown.quote").exists());
+ }
+
+ public void testNoConnInfoExport() {
+ executeTarget("noconinfoexport");
+ File baseDir = new File(project.getProperty("build.dir"), "noconinfo");
+ File onlyCreate = new File(baseDir, "noconinfo.sql");
+
+ assertTrue(onlyCreate.toString() + " should exist", onlyCreate.exists());
+
+ assertTrue(onlyCreate.length()>0);
+
+ assertNotNull(TestHelper.findFirstString("create", onlyCreate));
+
+
+ }
+
+ public void testNoExporters() {
+ try {
+ executeTarget("testnoexporters");
+ fail("should have failed with no exporters!");
+ } catch(BuildException be) {
+ // should happen!
+ assertTrue(be.getMessage().indexOf("No exporters specified")>=0);
+ }
+
+ }
+
+ public void testException() {
+ try {
+ executeTarget("testexceptions");
+ fail("should have failed with an exception!");
+ } catch(BuildException be) {
+ // should happen!
+ }
+ }
+
+ public void testQuery() {
+ executeTarget("testquery");
+
+ File baseDir = new File(project.getProperty("build.dir"), "querytest");
+
+ assertTrue(new File(baseDir, "queryresult.txt").exists());
+
+ }
+
+ public void testHbmLint() {
+ executeTarget("testhbmlint");
+
+ File baseDir = new File(project.getProperty("build.dir"), "linttest");
+
+ assertTrue(new File(baseDir, "hbmlint-result.txt").exists());
+
+ }
+
+ public void testNoConfig() {
+ try {
+ executeTarget("noconfig-shoulderror");
+ } catch(BuildException e) {
+ assertTrue(e.getMessage().indexOf("No configuration specified")>=0);
+ }
+
+ }
+ public static Test suite() {
+ return new TestSuite(AntHibernateToolTest.class);
+ }
+
+
+}
Deleted: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/HibernateToolTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/HibernateToolTest.java 2006-12-15 16:30:55 UTC (rev 10998)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/HibernateToolTest.java 2006-12-18 20:58:17 UTC (rev 10999)
@@ -1,203 +0,0 @@
-/*
- * Created on 13-Feb-2005
- *
- */
-package org.hibernate.tool.ant;
-
-import java.io.File;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.apache.tools.ant.BuildException;
-import org.hibernate.tool.test.TestHelper;
-
-/**
- * @author max
- *
- */
-public class HibernateToolTest extends BuildFileTestCase {
-
- private String property;
-
- public HibernateToolTest(String name) {
- super(name);
- }
-
- protected void tearDown() throws Exception {
- executeTarget("cleanup");
- System.out.println(getLog());
- super.tearDown();
- }
- protected void setUp() throws Exception {
- configureProject("src/testsupport/anttest-build.xml");
- }
-
- public void testHbm2DDLLogic() {
- executeTarget("testantcfg");
- File baseDir = new File(project.getProperty("build.dir"), "topdown");
- File onlyCreate = new File(baseDir, "onlycreate.sql");
- File onlyDrop = new File(baseDir, "onlydrop.sql");
- File dropAndCreate = new File(baseDir, "dropandcreate.sql");
-
- assertTrue(onlyCreate.exists());
- assertTrue(onlyDrop.exists());
- assertTrue(dropAndCreate.exists());
-
- assertNotNull(TestHelper.findFirstString("drop", dropAndCreate));
- assertNotNull(TestHelper.findFirstString("create", dropAndCreate));
-
- assertEquals(null, TestHelper.findFirstString("create", onlyDrop));
- assertNotNull(TestHelper.findFirstString("drop", onlyDrop));
-
- assertEquals(null, TestHelper.findFirstString("drop", onlyCreate));
- assertNotNull(TestHelper.findFirstString("create", onlyCreate));
-
- }
-
- public void testJDBCConfiguration() {
- executeTarget("testantjdbccfg");
- }
-
- public void testAnnotationConfigurationFailureExpected() {
- executeTarget("testantannotationcfg");
- }
-
- public void testEJB3ConfigurationFailureExpected() {
- executeTarget("testantejb3cfg");
- File baseDir = new File(project.getProperty("build.dir"));
- File ejb3 = new File(baseDir, "ejb3.sql");
-
- assertTrue(ejb3.exists());
- assertEquals(null, TestHelper.findFirstString("drop", ejb3));
-
- assertTrue(getLog().indexOf("<ejb3configuration> is deprecated")>0);
-
- }
-
- public void testJPABogusPUnit() {
- try {
- executeTarget("jpa-bogusunit");
- fail("Bogus unit accepted");
- } catch(BuildException be) {
- // should happen
- }
- }
-
- public void testJPAPUnit() {
- executeTarget("jpa-punit");
- }
-
- public void testHbm2JavaConfiguration() {
- executeTarget("testanthbm2java");
- }
-
- public void testHbm2JavaEJB3Configuration() {
- executeTarget("testantejb3hbm2java");
- }
-
- public void testCfg2HbmNoError() {
- executeTarget("testantcfg2hbm1");
- }
-
- public void testCfg2HbmWithCustomReverseNamingStrategy() {
- executeTarget("testantcfg2hbm2");
- }
-
- public void testCfg2HbmWithInvalidReverseNamingStrategy() {
- expectSpecificBuildException("testantcfg2hbm3",
- "namingStrategy attribute should not be loaded",
- "Could not create or find invalid.classname with one argument delegate constructor");
- }
-
- public void testCfg2HbmWithPackageName() {
- executeTarget("testantcfg2hbm4");
- }
-
- public void testCfg2HbmWithPackageNameAndReverseNamingStrategy() {
- executeTarget("testantcfg2hbm5");
- }
-
-
- public void testJDBCConfigWithRevEngXml() {
- executeTarget("testantjdbccfgoverrides");
- }
-
- public void testProperties() {
- executeTarget("testproperties");
- }
-
- public void testGenericExport() {
- executeTarget("testgeneric");
-
- property = project.getProperty("build.dir");
- assertTrue(new File(property, "generic").exists());
- assertTrue(new File(property, "generic/org/hibernate/tool/hbm2x/ant/TopDown.quote").exists());
- }
-
- public void testNoConnInfoExport() {
- executeTarget("noconinfoexport");
- File baseDir = new File(project.getProperty("build.dir"), "noconinfo");
- File onlyCreate = new File(baseDir, "noconinfo.sql");
-
- assertTrue(onlyCreate.toString() + " should exist", onlyCreate.exists());
-
- assertTrue(onlyCreate.length()>0);
-
- assertNotNull(TestHelper.findFirstString("create", onlyCreate));
-
-
- }
-
- public void testNoExporters() {
- try {
- executeTarget("testnoexporters");
- fail("should have failed with no exporters!");
- } catch(BuildException be) {
- // should happen!
- assertTrue(be.getMessage().indexOf("No exporters specified")>=0);
- }
-
- }
-
- public void testException() {
- try {
- executeTarget("testexceptions");
- fail("should have failed with an exception!");
- } catch(BuildException be) {
- // should happen!
- }
- }
-
- public void testQuery() {
- executeTarget("testquery");
-
- File baseDir = new File(project.getProperty("build.dir"), "querytest");
-
- assertTrue(new File(baseDir, "queryresult.txt").exists());
-
- }
-
- public void testHbmLint() {
- executeTarget("testhbmlint");
-
- File baseDir = new File(project.getProperty("build.dir"), "linttest");
-
- assertTrue(new File(baseDir, "hbmlint-result.txt").exists());
-
- }
-
- public void testNoConfig() {
- try {
- executeTarget("noconfig-shoulderror");
- } catch(BuildException e) {
- assertTrue(e.getMessage().indexOf("No configuration specified")>=0);
- }
-
- }
- public static Test suite() {
- return new TestSuite(HibernateToolTest.class);
- }
-
-
-}
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/GenericExporterTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/GenericExporterTest.java 2006-12-15 16:30:55 UTC (rev 10998)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/GenericExporterTest.java 2006-12-18 20:58:17 UTC (rev 10999)
@@ -101,6 +101,41 @@
"genericHelloUniverse.txt" ) );
}
+ public void testForEachGeneration() {
+
+ GenericExporter ge = new GenericExporter();
+ ge.setConfiguration(getCfg());
+ ge.setOutputDirectory(getOutputDir());
+ ge.setTemplateName("generictemplates/pojo/generic-class.ftl");
+ ge.setFilePattern("{package-name}/generic{class-name}.txt");
+ ge.setForEach("entity");
+ ge.start();
+
+ assertFileAndExists( new File( getOutputDir(),
+ "org/hibernate/tool/hbm2x/genericAuthor.txt" ) );
+
+ assertFileAndExists( new File( getOutputDir(),
+ "org/hibernate/tool/hbm2x/genericArticle.txt" ) );
+
+ assertFileAndExists( new File( getOutputDir(),
+ "org/hibernate/tool/hbm2x/genericArticle.txt" ) );
+
+ assertFalse("component file should not exist", new File( getOutputDir(), "genericUniversalAddress.txt" ).exists());
+
+
+ assertFileAndExists( new File( getOutputDir(),
+ "genericHelloUniverse.txt" ) );
+
+
+ try {
+ ge.setForEach( "does, not, exist" );
+ ge.start();
+ fail();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
public void testPropertySet() throws FileNotFoundException, IOException {
GenericExporter ge = new GenericExporter();
ge.setConfiguration(getCfg());
Modified: branches/Branch_3_2/HibernateExt/tools/src/testsupport/anttest-build.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/testsupport/anttest-build.xml 2006-12-15 16:30:55 UTC (rev 10998)
+++ branches/Branch_3_2/HibernateExt/tools/src/testsupport/anttest-build.xml 2006-12-18 20:58:17 UTC (rev 10999)
@@ -133,7 +133,7 @@
</fileset>
</configuration>
- <hbmtemplate templateprefix="pojo/" template="pojo/Pojo.ftl" filepattern="X{package-name}/{class-name}.java">
+ <hbmtemplate templateprefix="pojo/" template="pojo/Pojo.ftl" filepattern="X{package-name}/{class-name}.java" foreach="entity">
<property key="jdk5" value="false" />
<property key="ejb3" value="false" />
</hbmtemplate>
17 years, 11 months
Hibernate SVN: r10998 - branches/Branch_3_2/Hibernate3/src/org/hibernate/bytecode/javassist
by hibernate-commits@lists.jboss.org
Author: scottmarlownovell
Date: 2006-12-15 11:30:55 -0500 (Fri, 15 Dec 2006)
New Revision: 10998
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/bytecode/javassist/FastClass.java
Log:
Fix for HHH-1646.
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/bytecode/javassist/FastClass.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/bytecode/javassist/FastClass.java 2006-12-15 09:55:36 UTC (rev 10997)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/bytecode/javassist/FastClass.java 2006-12-15 16:30:55 UTC (rev 10998)
@@ -157,7 +157,7 @@
}
public boolean equals(Object o) {
- if ( o == null || ( o instanceof FastClass ) ) {
+ if ( !( o instanceof FastClass ) ) {
return false;
}
return this.type.equals( ( ( FastClass ) o ).type );
17 years, 11 months
Hibernate SVN: r10997 - branches/Branch_3_2/HibernateExt/tools/src/templates/pojo
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-12-15 04:55:36 -0500 (Fri, 15 Dec 2006)
New Revision: 10997
Modified:
branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/PojoConstructors.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/PojoFields.ftl
branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/PojoPropertyAccessors.ftl
Log:
less bling-bling for gavin
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/PojoConstructors.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/PojoConstructors.ftl 2006-12-15 09:55:11 UTC (rev 10996)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/PojoConstructors.ftl 2006-12-15 09:55:36 UTC (rev 10997)
@@ -1,10 +1,9 @@
- // Constructors
- /** default constructor */
+<#-- /** default constructor */ -->
public ${pojo.getDeclarationName()}() {
}
-<#if pojo.needsMinimalConstructor()> /** minimal constructor */
+<#if pojo.needsMinimalConstructor()> <#-- /** minimal constructor */ -->
public ${pojo.getDeclarationName()}(${c2j.asParameterList(pojo.getPropertyClosureForMinimalConstructor(), jdk5, pojo)}) {
<#if pojo.isSubclass() && !pojo.getPropertyClosureForSuperclassMinimalConstructor().isEmpty()>
super(${c2j.asArgumentList(pojo.getPropertyClosureForSuperclassMinimalConstructor())});
@@ -15,7 +14,7 @@
}
</#if>
<#if pojo.needsFullConstructor()>
- /** full constructor */
+<#-- /** full constructor */ -->
public ${pojo.getDeclarationName()}(${c2j.asParameterList(pojo.getPropertyClosureForFullConstructor(), jdk5, pojo)}) {
<#if pojo.isSubclass() && !pojo.getPropertyClosureForSuperclassFullConstructor().isEmpty()>
super(${c2j.asArgumentList(pojo.getPropertyClosureForSuperclassFullConstructor())});
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/PojoFields.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/PojoFields.ftl 2006-12-15 09:55:11 UTC (rev 10996)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/PojoFields.ftl 2006-12-15 09:55:36 UTC (rev 10997)
@@ -1,4 +1,4 @@
- // Fields
+<#-- // Fields -->
<#foreach field in pojo.getAllPropertiesIterator()><#if pojo.getMetaAttribAsBool(field, "gen-property", true)> <#if pojo.hasMetaAttribute(field, "field-description")> /**
${pojo.getFieldJavaDoc(field, 0)}
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/PojoPropertyAccessors.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/PojoPropertyAccessors.ftl 2006-12-15 09:55:11 UTC (rev 10996)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/PojoPropertyAccessors.ftl 2006-12-15 09:55:36 UTC (rev 10997)
@@ -1,4 +1,4 @@
- // Property accessors
+<#-- // Property accessors -->
<#foreach property in pojo.getAllPropertiesIterator()>
<#if pojo.getMetaAttribAsBool(property, "gen-property", true)>
<#if pojo.hasFieldJavaDoc(property)>
17 years, 11 months
Hibernate SVN: r10996 - branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-12-15 04:55:11 -0500 (Fri, 15 Dec 2006)
New Revision: 10996
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java
Log:
rollback broken column defaulting to less broken column defaulting.
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java 2006-12-15 07:43:10 UTC (rev 10995)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java 2006-12-15 09:55:11 UTC (rev 10996)
@@ -415,13 +415,13 @@
appendCommonColumnInfo( annotations, column, insertable, updatable );
- if (column.getPrecision() != 0 /*Column.DEFAULT_PRECISION*/) { // the default is actually 0 in spec
+ if (column.getPrecision() != Column.DEFAULT_PRECISION) { // the default is actually 0 in spec
annotations.append( ", precision=" ).append( column.getPrecision() );
}
- if (column.getScale() != 0 /*Column.DEFAULT_SCALE*/) { // default is actually 0 in spec
+ if (column.getScale() != Column.DEFAULT_SCALE) { // default is actually 0 in spec
annotations.append( ", scale=" ).append( column.getScale() );
}
- else if (column.getLength() != 255 /*Column.DEFAULT_LENGTH*/){
+ else if (column.getLength() != 255){
annotations.append( ", length=" ).append( column.getLength() );
}
17 years, 11 months
Hibernate SVN: r10995 - branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-12-15 02:43:10 -0500 (Fri, 15 Dec 2006)
New Revision: 10995
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java
Log:
align annotation column defaults gen with spec
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java 2006-12-14 19:10:37 UTC (rev 10994)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java 2006-12-15 07:43:10 UTC (rev 10995)
@@ -415,13 +415,13 @@
appendCommonColumnInfo( annotations, column, insertable, updatable );
- if (column.getPrecision() != Column.DEFAULT_PRECISION) {
+ if (column.getPrecision() != 0 /*Column.DEFAULT_PRECISION*/) { // the default is actually 0 in spec
annotations.append( ", precision=" ).append( column.getPrecision() );
}
- if (column.getScale() != Column.DEFAULT_SCALE) { // default is actually 0 in spec
+ if (column.getScale() != 0 /*Column.DEFAULT_SCALE*/) { // default is actually 0 in spec
annotations.append( ", scale=" ).append( column.getScale() );
}
- else if (column.getLength() != Column.DEFAULT_LENGTH){ // the default is actually 0 in spec
+ else if (column.getLength() != 255 /*Column.DEFAULT_LENGTH*/){
annotations.append( ", length=" ).append( column.getLength() );
}
17 years, 11 months
Hibernate SVN: r10994 - in branches/Branch_3_2/HibernateExt/tools/doc/reference/en: . images modules
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-12-14 14:10:37 -0500 (Thu, 14 Dec 2006)
New Revision: 10994
Added:
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgclasspath.gif
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgclasspath.png
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgmappings.gif
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgmappings.png
Modified:
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/codegendropdown.gif
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/codegenexporters.gif
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/codegenmaintab.gif
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgwizard.gif
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consoleoutline-before-reveng.gif
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/hibernatecfgwizard.gif
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/master.xml
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/codegenarchitecture.xml
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/plugins.xml
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/setup.xml
Log:
HBX-838 update docs for simplified ui
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/codegendropdown.gif
===================================================================
(Binary files differ)
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/codegenexporters.gif
===================================================================
(Binary files differ)
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/codegenmaintab.gif
===================================================================
(Binary files differ)
Added: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgclasspath.gif
===================================================================
(Binary files differ)
Property changes on: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgclasspath.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgclasspath.png
===================================================================
(Binary files differ)
Property changes on: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgclasspath.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgmappings.gif
===================================================================
(Binary files differ)
Property changes on: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgmappings.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgmappings.png
===================================================================
(Binary files differ)
Property changes on: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgmappings.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consolecfgwizard.gif
===================================================================
(Binary files differ)
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/consoleoutline-before-reveng.gif
===================================================================
(Binary files differ)
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/images/hibernatecfgwizard.gif
===================================================================
(Binary files differ)
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/master.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/doc/reference/en/master.xml 2006-12-14 15:06:36 UTC (rev 10993)
+++ branches/Branch_3_2/HibernateExt/tools/doc/reference/en/master.xml 2006-12-14 19:10:37 UTC (rev 10994)
@@ -14,8 +14,8 @@
<subtitle>Reference Guide</subtitle>
- <releaseinfo>3.2.0.beta8</releaseinfo>
-
+ <releaseinfo>3.2.0.beta9</releaseinfo>
+
<mediaobject>
<imageobject>
<imagedata fileref="images/hibernate_logo_a.png" format="PNG" />
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/codegenarchitecture.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/codegenarchitecture.xml 2006-12-14 15:06:36 UTC (rev 10993)
+++ branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/codegenarchitecture.xml 2006-12-14 19:10:37 UTC (rev 10994)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<chapter id="codegenarchitecture">
<title>Code generation architecture</title>
@@ -17,12 +17,49 @@
build a session factory.</para>
<para>The model represented by the <literal>Configuration</literal> class
- can be build in many ways. The best known is by using hbm.xml files to
- describe the meta model, other methods are using annotations in java
- source code and a third is reading JDBC metadata and build a
- configuration. The last method is provided via the reverse engineering
- part of the hibernate tools.</para>
+ can be build in many ways. The following list the currently supported ones
+ in Hibernate Tools. </para>
+ <para><itemizedlist>
+ <listitem>
+ <para>A <emphasis>Core configuration</emphasis> uses Hibernate Core
+ and supports reading hbm.xml files, requires a hibernate.cfg.xml.
+ Named core in Eclipse and <literal><configuration></literal>
+ in ant.</para>
+ </listitem>
+
+ <listitem>
+ <para>A <emphasis>Annotation configuration</emphasis> uses Hibernate
+ Annotations and supports hbm.xml and annotated classes, requires a
+ hibernate.cfg.xml. Named annotations in Eclipse and
+ <literal><annotationconfiguration></literal> in ant.</para>
+ </listitem>
+
+ <listitem>
+ <para>A <emphasis>JPA configuration</emphasis> uses a Hibernate
+ EntityManager and supports hbm.xml and annotated classes requires
+ that the project has a META-INF/persistence.xml in its classpath.
+ Named JPA in Eclipse and <literal><jpaconfiguration></literal>
+ in ant.</para>
+ </listitem>
+
+ <listitem>
+ <para>A <emphasis>JDBC configuration</emphasis> uses Hibernate Tools
+ reverse engineering and reads its mappings via JDBC metadata +
+ additional reverse engineering files (reveng.xml). Automatically
+ used in Eclipse when doing reverse engineering from JDBC and named
+ <literal><jdbcconfiguration></literal> in ant.</para>
+ </listitem>
+ </itemizedlist></para>
+
+ <para>In most projects you will normally use only one of the Core,
+ Annotation or JPA configuration and possibly the JDBC configuration if you
+ are using the reverse engineering facilities of Hibernate Tools. The
+ important thing to note is that no matter which Hibnerate Configuration
+ type you are using Hibernate Tools supports them.</para>
+
+ <para>The following drawing illustrates the core concepts:</para>
+
<para><mediaobject>
<imageobject role="fo">
<imagedata fileref="images/architecture.png" format="PNG" />
@@ -34,10 +71,10 @@
</imageobject>
</mediaobject></para>
- <para>The code generation is done based on this model no matter which
- method have been used to create the meta model, and thus the code
- generation is independent on the source of the meta model and represented
- via Exporters.</para>
+ <para>The code generation is done based on the Configuration model no
+ matter which type of configuration have been used to create the meta
+ model, and thus the code generation is independent on the source of the
+ meta model and represented via Exporters.</para>
</section>
<section>
@@ -54,9 +91,6 @@
<para>Users can provide their own customer Exporter's, either by custom
classes implementing the Exporter interface or simply be providing custom
- templates. This is documented at <xref linkend="hbmtemplate"/></para>
-
- <para>NOTICE: This release uses Velocity for the templates. The next
- release might move to an alternative template engine.</para>
+ templates. This is documented at <xref linkend="hbmtemplate" /></para>
</section>
</chapter>
\ No newline at end of file
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/plugins.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/plugins.xml 2006-12-14 15:06:36 UTC (rev 10993)
+++ branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/plugins.xml 2006-12-14 19:10:37 UTC (rev 10994)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<chapter id="plugins">
<title>Eclipse Plugins</title>
@@ -16,9 +16,9 @@
and property/field names, making it much more versatile than a normal XML
editor.</para>
- <para><emphasis role="bold">Hibernate Console:</emphasis> The console is a
- new perspetive in Eclipse. It provides an overview of your Hibernate
- Console configurations, were also get an interactive view of your
+ <para><emphasis role="bold">Hibernate Console</emphasis>: The console is a
+ new perspective in Eclipse. It provides an overview of your Hibernate
+ Console configurations, were you also can get an interactive view of your
persistent classes and their relationships. The console allows you to
execute HQL queries against your database and browse the result directly
in Eclipse.</para>
@@ -31,6 +31,12 @@
engineer an existing database schema and use the code generation to
generate POJO source files and Hibernate mapping files.</para>
+ <para><emphasis role="bold">Eclipse JDT integration</emphasis>: Hibernate
+ Tools integrates into the Java code completion and build support of Java
+ in Eclipse. This gives you codecompletion of HQL inside Java code plus
+ Hibernate Tools will add problem markers if your queries are not valid
+ against the console configuration associated with the project.</para>
+
<para>Please note that these tools do not try to hide any functionality of
Hibernate. The tools make working with Hibernate easier, but you are still
encouraged/required to read the documentation for Hibernate to fully
@@ -41,8 +47,8 @@
<title>Creating a Hibernate configuration file</title>
<para>To be able to reverse engineer, prototype queries, and of course to
- simply use Hibernate a hibernate.properties or hibernate.cfg.xml file is
- needed. The Hibernate Tools provide a wizard for generating the
+ simply use Hibernate Core a hibernate.properties or hibernate.cfg.xml file
+ is needed. The Hibernate Tools provide a wizard for generating the
hibernate.cfg.xml file if you do not already have such file.</para>
<para>Start the wizard by clicking "New Wizard" (Ctrl+N), select the
@@ -52,7 +58,8 @@
<mediaobject>
<imageobject role="fo">
- <imagedata fileref="images/hibernatecfgwizard.gif" format="GIF" contentwidth="5cm" />
+ <imagedata contentwidth="5cm" fileref="images/hibernatecfgwizard.gif"
+ format="GIF" />
</imageobject>
<imageobject role="html">
@@ -81,17 +88,26 @@
<section>
<title>Creating a Hibernate Console configuration</title>
- <para>A Console Configuration describes to the Hibernate plugin which configuration files should be used to configure hibernate, including which classpath is needed to load the POJO's, JDBC drivers etc. It is required to make usage of query prototyping, reverse engineering and code generation. You can have multiple named console configurations. Normally you would just need one per project, but more (or less) is definitly possible. </para>
+ <para>A Console Configuration describes to the Hibernate plugin how it
+ should configure Hibernate and what configuration files, including which
+ classpath is needed to load the POJO's, JDBC drivers etc. It is required
+ to make usage of query prototyping, reverse engineering and code
+ generation. You can have multiple named console configurations. Normally
+ you would just need one per project, but more is definitly
+ possible.</para>
<para>You create a console configuration by running the Console
Configuration wizard, shown in the following screenshot. The same wizard
will also be used if you are coming from the hibernate.cfg.xml wizard and
had enabled "Create Console Configuration".</para>
-
+ <para>Tip: the wizard will look at the current selection in the IDE and
+ try and auto-detect the settings which you then can just approve or modify
+ to suit your needs.</para>
+ <para></para>
+
<mediaobject>
-
<imageobject role="fo">
<imagedata fileref="images/consolecfgwizard.gif" format="GIF" />
</imageobject>
@@ -101,17 +117,21 @@
fileref="../shared/images/consolecfgwizard.gif"
format="GIF" />
</imageobject>
- <caption>Creating a Hibernate Console configuration</caption>
+
+ <caption>Creating a Hibernate Console configuration</caption>
</mediaobject>
-
+ <para>The dialog consists of three tabs, "General" for the basic/required
+ settings, "Classpath" for classpath and "Mappings" for additional
+ mappings. The two latter ones is normally not required if you specify a
+ project and it has <literal> /hibernate.cfg.xml </literal>or
+ <literal>/META-INF/persistence.xml</literal> in its project
+ classpath.</para>
<para>The following table describes the available settings. The wizard can
automatically detect default values for most of these if you started the
- Wizard with the relevant java project selected</para>
+ Wizard with the relevant java project or resource selected</para>
-
-
<table>
<title>Hibernate Console Configuration Parameters</title>
@@ -124,150 +144,211 @@
<thead>
<row>
- <entry align="center">
- <para>Parameter</para>
- </entry>
+ <entry align="center"><para>Parameter</para></entry>
- <entry align="center">
- <para>Description</para>
- </entry>
+ <entry align="center"><para>Description</para></entry>
- <entry align="center">
- <para>Auto detected value</para>
- </entry>
+ <entry align="center"><para>Auto detected value</para></entry>
</row>
</thead>
<tbody>
<row>
- <entry>
- <para>Name</para>
- </entry>
+ <entry><para>Name</para></entry>
- <entry>
- <para>The unique name of the configuration</para>
- </entry>
+ <entry><para>The unique name of the console
+ configuration</para></entry>
- <entry>
- <para>Name of the selected project</para>
- </entry>
+ <entry><para>Name of the selected project</para></entry>
</row>
<row>
- <entry>
- <para>Property file</para>
- </entry>
+ <entry>Project</entry>
- <entry>
- <para>Path to a hibernate.properties file</para>
- </entry>
+ <entry>The name of a java project which classpath should be used
+ in the console configuration</entry>
- <entry>
- <para>First hibernate.properties file found in the selected
- project</para>
- </entry>
+ <entry>Name of the selected project</entry>
</row>
<row>
- <entry>
- <para>Configuration file</para>
- </entry>
+ <entry>Type</entry>
- <entry>
- <para>Path to a hibernate.cfg.xml file</para>
- </entry>
+ <entry>Choose between "Core", "Annotations" and "JPA". Note that
+ the two latter requires running Eclipse IDE with a JDK 5 runtime,
+ otherwise you will get classloading and/or version errors.</entry>
- <entry>
- <para>First hibernate.cfg.xml file found in the selected
- project</para>
- </entry>
+ <entry>No default value</entry>
</row>
<row>
- <entry>
- <para>Entity resolver</para>
- </entry>
+ <entry><para>Property file</para></entry>
- <entry>
- <para>Fully qualified classname of a custom EntityResolver. Only
- required if you have special xml entity includes in your mapping
- files.</para>
- </entry>
+ <entry><para>Path to a hibernate.properties file</para></entry>
- <entry>
- <para>No default value</para>
- </entry>
+ <entry><para>First hibernate.properties file found in the selected
+ project</para></entry>
</row>
<row>
- <entry>
- <para>Enable Hibernate ejb3/annotations</para>
- </entry>
+ <entry><para>Configuration file</para></entry>
- <entry>
- <para>Selecting this option enables usage of annotated classes.
- hbm.xml files are of course still possible to use too. This
- feature requires running the Eclipse IDE with a JDK 5 runtime,
- otherwise you will get classloading and/or version
- errors.</para>
- </entry>
+ <entry><para>Path to a hibernate.cfg.xml file</para></entry>
- <entry>
- <para>Not enabled</para>
- </entry>
+ <entry><para>First hibernate.cfg.xml file found in the selected
+ project</para></entry>
</row>
<row>
- <entry>
- <para>Mapping files</para>
- </entry>
+ <entry>Persistence unit</entry>
- <entry>
- <para>List of additional mapping files that should be loaded.
- Note: A hibernate.cfg.xml can also contain mappings. Thus if
- these a duplicated here, you will get "Duplicate mapping" errors
- when using the console configuration.</para>
- </entry>
+ <entry>Name of the persistence unit to use</entry>
- <entry>
- <para>If no hibernate.cfg.xml file is found, all hbm.xml files
- found in the selected project</para>
- </entry>
+ <entry>No default value (lets Hibernate Entity Manager find the
+ persistence unit)</entry>
</row>
<row>
- <entry>
- <para>Classpath</para>
- </entry>
+ <entry>Naming strategy</entry>
- <entry>
- <para>The classpath for loading POJO and JDBC drivers. Do not
- add Hibernate core libraries or dependencies, they are already
- included. If you get ClassNotFound errors then check this list
- for possible missing or redundant directories/jars.</para>
- </entry>
+ <entry>Fully qualified classname of a custom NamingStrategy. Only
+ required if you use a special naming strategy.</entry>
- <entry>
- <para>The default build output directory and any JARs with a
- class implementing java.sql.Driver in the selected
- project</para>
- </entry>
+ <entry>No default value</entry>
</row>
+
+ <row>
+ <entry><para>Entity resolver</para></entry>
+
+ <entry><para>Fully qualified classname of a custom EntityResolver.
+ Only required if you have special xml entity includes in your
+ mapping files.</para></entry>
+
+ <entry><para>No default value</para></entry>
+ </row>
</tbody>
</tgroup>
</table>
-
+ <mediaobject>
+ <imageobject role="fo">
+ <imagedata align="center" fileref="images/consolecfgclasspath.gif"
+ format="GIF" />
+ </imageobject>
+ <imageobject role="html">
+ <imagedata align="center"
+ fileref="../shared/images/consolecfgclasspath.gif"
+ format="GIF" />
+ </imageobject>
+
+ <caption>Specifying classpath in a Hibernate Console
+ configuration</caption>
+ </mediaobject>
+
+ <para><table>
+ <title>Hibernate Console Configuration Classpath</title>
+
+ <tgroup cols="3">
+ <colspec colnum="1" colwidth="1*" />
+
+ <colspec colnum="2" colwidth="3*" />
+
+ <colspec colnum="3" colwidth="1*" />
+
+ <thead>
+ <row>
+ <entry align="center"><para>Parameter</para></entry>
+
+ <entry align="center"><para>Description</para></entry>
+
+ <entry align="center"><para>Auto detected value</para></entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><para>Classpath</para></entry>
+
+ <entry><para>The classpath for loading POJO and JDBC drivers;
+ only needed if the default classpath of the Project does not
+ contain the required classes. Do not add Hibernate core
+ libraries or dependencies, they are already included. If you get
+ ClassNotFound errors then check this list for possible missing
+ or redundant directories/jars.</para></entry>
+
+ <entry><para>empty</para></entry>
+ </row>
+
+ <row>
+ <entry><para>Include default classpath from
+ project</para></entry>
+
+ <entry><para>When enabled the project classpath will be appended
+ to the classpath specified above.</para></entry>
+
+ <entry><para>Enabled</para></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+
+ <para><mediaobject>
+ <imageobject role="fo">
+ <imagedata align="center" fileref="images/consolecfgmappings.gif"
+ format="GIF" />
+ </imageobject>
+
+ <imageobject role="html">
+ <imagedata align="center"
+ fileref="../shared/images/consolecfgmappings.gif"
+ format="GIF" />
+ </imageobject>
+
+ <caption>Specifying additional mappings in a Hibernate console
+ configuration</caption>
+ </mediaobject><table>
+ <title>Hibernate Console Configuration Mappings</title>
+
+ <tgroup cols="3">
+ <colspec colnum="1" colwidth="1*" />
+
+ <colspec colnum="2" colwidth="3*" />
+
+ <colspec colnum="3" colwidth="1*" />
+
+ <thead>
+ <row>
+ <entry align="center"><para>Parameter</para></entry>
+
+ <entry align="center"><para>Description</para></entry>
+
+ <entry align="center"><para>Auto detected value</para></entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><para>Mapping files </para></entry>
+
+ <entry><para>List of additional mapping files that should be
+ loaded. Note: A hibernate.cfg.xml or persistence.xml can also
+ contain mappings. Thus if these are duplicated here, you will
+ get "Duplicate mapping" errors when using the console
+ configuration.</para></entry>
+
+ <entry><para>empty</para></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+
<para>Clicking "Finish" creates the configuration and shows it in the
"Hibernate Configurations" view</para>
-
-
- <mediaobject>
-
+ <mediaobject>
<imageobject role="fo">
- <imagedata align="center"
+ <imagedata align="center"
fileref="images/consoleoutline-before-reveng.gif"
format="GIF" />
</imageobject>
@@ -277,23 +358,20 @@
fileref="../shared/images/consoleoutline-before-reveng.gif"
format="GIF" />
</imageobject>
-
- <caption>Console overview</caption>
+
+ <caption>Console overview</caption>
</mediaobject>
-
-
</section>
<section>
<title>Reverse engineering and code generation</title>
- <para>A very simple "click-and-generate" reverse engineering and code
- generation facility is also available. This facility allows you to
- generate a range of artifacts based on database or an already existing
- Hibernate configuration, be that mapping files or annotations. Some of
- these are POJO Java source file, Hibernate *.hbm.xml, hibernate.cfg.xml
- generation and even the option for generating the skeleton for a full Seam
- CRUD application.</para>
+ <para>A "click-and-generate" reverse engineering and code generation
+ facility is available. This facility allows you to generate a range of
+ artifacts based on database or an already existing Hibernate
+ configuration, be that mapping files or annotated classes. Some of these
+ are POJO Java source file, Hibernate *.hbm.xml, hibernate.cfg.xml
+ generation and schema documentation.</para>
<para>To start working with this process, start the "Hibernate Code
Generation" which is available in the toolbar via the Hibernate icon or
@@ -318,10 +396,7 @@
</imageobject>
</mediaobject>
- <para>The dialog has the standard tabs "Refresh" and "Common" that can
- be used to configure which directories should be automatically refreshed
- and various general settings launchers, such as saving them in a project
- for sharing the launcher within a team.</para>
+ <para></para>
<mediaobject>
<imageobject role="fo">
@@ -344,8 +419,13 @@
exporter on the Exporter tab. When an exporter has been selected the
warning will disappear.</para>
- <para>On the "Main" tab you the following fields:</para>
+ <para>The dialog also have the standard tabs "Refresh" and "Common" that
+ can be used to configure which directories should be automatically
+ refreshed and various general settings launchers, such as saving them in
+ a project for sharing the launcher within a team.</para>
+ <para>On the "Main" tab you see the following fields:</para>
+
<table>
<title>Code generation "Main" tab fields</title>
@@ -438,18 +518,34 @@
</row>
<row>
+ <entry>Detect optimistic lock columns</entry>
+
+ <entry>Automatically detect optimistic lock columns.
+ Controllable via reveng. strategy; the current default is to use
+ columns named VERSION or TIMESTAMP.</entry>
+ </row>
+
+ <row>
+ <entry>Detect many-to-many tables</entry>
+
+ <entry>Automatically detect many-to-many tables. Controllable
+ via reveng. strategy.</entry>
+ </row>
+
+ <row>
<entry><para>Use custom templates</para></entry>
<entry><para>If enabled, the Template directory will be searched
- first when looking up the templates, allowing you to
- redefine how the individual templates process the hibernate
- mapping model.</para></entry>
+ first when looking up the templates, allowing you to redefine
+ how the individual templates process the hibernate mapping
+ model.</para></entry>
</row>
<row>
<entry><para>Template directory</para></entry>
- <entry><para>A path to a directory with custom templates.</para></entry>
+ <entry><para>A path to a directory with custom
+ templates.</para></entry>
</row>
</tbody>
</tgroup>
@@ -486,8 +582,6 @@
<colspec colnum="2" colwidth="3*" />
- <colspec colnum="3" colwidth="0.5*" />
-
<thead>
<row>
<entry align="center"><para>Field</para></entry>
@@ -506,20 +600,6 @@
</row>
<row>
- <entry><para>JDK 1.5 constructs</para></entry>
-
- <entry><para>When enabled the POJO's will use JDK 1.5
- constructs.</para></entry>
- </row>
-
- <row>
- <entry><para>EJB3/JSR-220 annotations</para></entry>
-
- <entry><para>When enabled the POJO's will be annotated according
- to the EJB3/JSR-220 persistency specification.</para></entry>
- </row>
-
- <row>
<entry><para>DAO code</para></entry>
<entry><para>Generates a set of DAO's for each entity
@@ -549,7 +629,7 @@
</row>
<row>
- <entry><para>Generate JBoss Seam skeleton app [Beta]</para></entry>
+ <entry><para>JBoss Seam skeleton app [Beta]</para></entry>
<entry><para>Generates a complete JBoss Seam skeleton app. The
generation will include annotated POJO's, Seam controller beans
@@ -557,11 +637,58 @@
readme.txt for how to use it. </para><para>Note: this exporter
generates a full application, including a build.xml thus you
will get the best results if you use an output directory which
- is the root of your project.</para></entry>
+ is the root of your project.</para><para>Currently this
+ generation is the old style of CRUD generation for Seam 1.0. If
+ you use Seam 1.1 seam-gen is more apropriate and
+ uptodate.</para></entry>
</row>
</tbody>
</tgroup>
</table>
+
+ <para>Each exporter listens to certain properties and these can be setup
+ in the "Properties" section where you can add/remove predefined or
+ customer properties for each of the exporters. The following table lists
+ the time of writing pre-defined properties:</para>
+
+ <para><table>
+ <title>Exporter Properties</title>
+
+ <tgroup cols="2">
+ <colspec colnum="1" colwidth="1*" />
+
+ <colspec colnum="2" colwidth="3*" />
+
+ <thead>
+ <row>
+ <entry align="center"><para>Name</para></entry>
+
+ <entry align="center"><para>Description</para></entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry><para>jdk5</para></entry>
+
+ <entry><para>Generate Java 5 syntax</para></entry>
+ </row>
+
+ <row>
+ <entry><para>ejb3</para></entry>
+
+ <entry><para>Generate EJB 3 annotations</para></entry>
+ </row>
+
+ <row>
+ <entry><para>dot.executable</para></entry>
+
+ <entry><para>executable to run GraphViz (only relevant, but
+ optional for Schema documentation)</para></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
</section>
</section>
@@ -696,7 +823,7 @@
<para>Note that not all the features of the .reveng.xml file is exposed or
fully implemented in the editor, but the main functionallity is there. To
understand the full flexibility of the reveng.xml, please see <xref
- linkend="hibernaterevengxmlfile"/></para>
+ linkend="hibernaterevengxmlfile" /></para>
<para>The editor is activated as soon as an .reveng.xml file is opened. To
get an initial reveng.xml file the reveng.xml wizard can be started via
@@ -776,39 +903,32 @@
you need to create a console configuration.</para>
<section>
-
-
<title>Viewing the entity structure</title>
<para>To view your new configuration and entity/class structure, expand
the Hibernate Console configuration by clicking on the + icon.</para>
-
-
<para>Clicking on the small <literal>+</literal> symbol allows you to
browse the class/entity structure and see the relationships.</para>
-
-<para>
- <mediaobject>
- <imageobject role="fo">
- <imagedata fileref="images/queryconsole.png" />
- </imageobject>
+ <para><mediaobject>
+ <imageobject role="fo">
+ <imagedata fileref="images/queryconsole.png" />
+ </imageobject>
- <imageobject role="html">
- <imagedata align="center"
- fileref="../shared/images/queryconsole.png" />
- </imageobject>
- </mediaobject>
+ <imageobject role="html">
+ <imagedata align="center"
+ fileref="../shared/images/queryconsole.png" />
+ </imageobject>
+ </mediaobject> Hibernate Console perspective showing entity structure,
+ query editor and result</para>
- Hibernate Console perspective showing entity structure, query editor and result
-</para>
<section>
<title>Class Diagram</title>
<para>A class diagram is available in the view named "Hibernate Entity
- Model". It will show the model when the Configuration node in a Hibernate Console
- Configuration is selected.</para>
+ Model". It will show the model when the Configuration node in a
+ Hibernate Console Configuration is selected.</para>
<mediaobject>
<imageobject role="fo">
@@ -821,11 +941,10 @@
</imageobject>
</mediaobject>
- <para>This view supports zoom in/out and can also be printed. Zooming is done via the toolbar buttons in the view
- and printing is done by selecting the view and choose File/Print or use the Print Icon.</para>
+ <para>This view supports zoom in/out and can also be printed. Zooming
+ is done via the toolbar buttons in the view and printing is done by
+ selecting the view and choose File/Print or use the Print Icon.</para>
</section>
-
-
</section>
<section>
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/setup.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/setup.xml 2006-12-14 15:06:36 UTC (rev 10993)
+++ branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/setup.xml 2006-12-14 19:10:37 UTC (rev 10994)
@@ -3,14 +3,14 @@
<title>Download and install Hibernate Tools</title>
<para>Hibernate tools can be used "standalone" via Ant 1.6.x or fully
- integrated into a Eclipse 3.1.x based IDE, such as JBoss Eclipse IDE or a
- default Eclipse 3.1.x installation. The following describes the install
+ integrated into a Eclipse 3.2.x based IDE, such as JBoss Eclipse IDE or a
+ default Eclipse 3.2.x installation. The following describes the install
steps in these environments.</para>
<section>
<title>JBoss Eclipse IDE</title>
- <para>JBoss Eclipse IDE 1.5.x includes Hibernate Tools and thus nothing is
+ <para>JBoss Eclipse IDE 2.x includes Hibernate Tools and thus nothing is
required besides downloading and installing JBoss Eclipse IDE. If you need
to update to a newer version of the Hibernate Tools just follow the
instructions in the Eclipse IDE section.</para>
@@ -19,10 +19,10 @@
<section>
<title>Eclipse IDE</title>
- <para>To install into any Eclipse 3.1.x based Eclipse IDE you can either
+ <para>To install into any Eclipse 3.2.x based Eclipse IDE you can either
download the Hibernate Tools distribution from the Hibernate website or
- use the Eclipse updatesite (see http://tools.hibernate.org for download
- links).</para>
+ use the JBoss IDE Eclipse update site (see http://tools.hibernate.org for
+ links to the update site).</para>
<para>If you download the Hibernate Tools distribution you need to place
the /plugins and /feature directory into your eclipse directory or eclipse
@@ -41,11 +41,11 @@
<section>
<title>Usage of Eclipse WTP</title>
- <para>The Hibernate tools plugins currently uses WTP 1.0 which at this
+ <para>The Hibernate tools plugins currently uses WTP 1.5.x which at this
time is the latest stable release from the Eclipse Webtools
project.</para>
- <para>Because the WTP project have not proper versioned their plugins
+ <para>Because the WTP project not always have had proper versioning of their plugins
there might exist WTP plugins in your existing eclipse directory from
other Eclipse based projects that are from an earlier WTP release but
has either the same version number or higher. It is thus recommended
@@ -53,9 +53,9 @@
the plugins on a clean install of eclipse to ensure there are no
version-collisions.</para>
- <para>The tools only include a subset of the WTP 1.0 plugins, thus if
- you want full access to the WTP functionallity the full WTP 1.0 SDK can
- be installed on top of the plugins without any problems.</para>
+ <para>The tools only include a subset of the WTP 1.5.x plugins, thus if
+ you want full access to the WTP functionallity the full WTP 1.5.x SDK should
+ be able to instal on top of the plugins without any problems.</para>
</section>
</section>
@@ -66,7 +66,7 @@
associated libraries. The libraries are included in the distribution from
the Hibernate website and the Eclipse updatesite. The libraries are
located in the eclipse plugins directory at
- <literal>/plugins/org.hibernate.eclipse.x.x.x/lib/tools/. </literal>These
+ <literal>/plugins/org.hibernate.eclipse.x.x.x/lib/tools/.</literal>These
libraries are 100% independent from the eclipse platform. How to use these
via ant tasks are described in the Ant chapter.</para>
</section>
17 years, 11 months
Hibernate SVN: r10993 - trunk/Hibernate3/src/org/hibernate/bytecode/javassist
by hibernate-commits@lists.jboss.org
Author: scottmarlownovell
Date: 2006-12-14 10:06:36 -0500 (Thu, 14 Dec 2006)
New Revision: 10993
Modified:
trunk/Hibernate3/src/org/hibernate/bytecode/javassist/FastClass.java
Log:
Applied "equals" method patch for HHH-1646.
Modified: trunk/Hibernate3/src/org/hibernate/bytecode/javassist/FastClass.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/bytecode/javassist/FastClass.java 2006-12-14 13:27:15 UTC (rev 10992)
+++ trunk/Hibernate3/src/org/hibernate/bytecode/javassist/FastClass.java 2006-12-14 15:06:36 UTC (rev 10993)
@@ -157,7 +157,7 @@
}
public boolean equals(Object o) {
- if ( o == null || ( o instanceof FastClass ) ) {
+ if (! ( o instanceof FastClass ) ) {
return false;
}
return this.type.equals( ( ( FastClass ) o ).type );
17 years, 11 months
Hibernate SVN: r10992 - branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-12-14 08:27:15 -0500 (Thu, 14 Dec 2006)
New Revision: 10992
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java
Log:
more tuning
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java 2006-12-14 13:27:05 UTC (rev 10991)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java 2006-12-14 13:27:15 UTC (rev 10992)
@@ -49,6 +49,8 @@
settings = ( ExecutionEnvironment.Settings ) test;
// todo : we could also centralize the skipping of "database specific" tests here
// instead of duplicating this notion in AllTests and DatabaseSpecificFunctionalTestCase.
+ // as a test gets added, simply check to see if we should really add it via
+ // DatabaseSpecificFunctionalTestCase.appliesTo( ExecutionEnvironment.DIALECT )...
}
}
testCount++;
@@ -77,6 +79,7 @@
}
public void runTest(Test test, TestResult testResult) {
+ testPosition++;
if ( environmentSetupError != null ) {
testResult.startTest( test );
testResult.addError( test, environmentSetupError );
@@ -89,12 +92,10 @@
else {
FunctionalTestCase functionalTest = ( ( FunctionalTestCase ) test );
try {
- if ( ++testPosition < testCount ) {
- // disallow rebuilding the schema because this is the last test
- // in this suite, thus it is about to get dropped immediately
- // afterwards anyway...
- environment.setAllowRebuild( true );
- }
+ // disallow rebuilding the schema because this is the last test
+ // in this suite, thus it is about to get dropped immediately
+ // afterwards anyway...
+ environment.setAllowRebuild( testPosition < testCount );
functionalTest.setEnvironment( environment );
super.runTest( functionalTest, testResult );
}
17 years, 11 months
Hibernate SVN: r10991 - trunk/Hibernate3/test/org/hibernate/junit/functional
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-12-14 08:27:05 -0500 (Thu, 14 Dec 2006)
New Revision: 10991
Modified:
trunk/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java
Log:
more tuning
Modified: trunk/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java 2006-12-14 10:04:59 UTC (rev 10990)
+++ trunk/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestClassTestSuite.java 2006-12-14 13:27:05 UTC (rev 10991)
@@ -49,6 +49,8 @@
settings = ( ExecutionEnvironment.Settings ) test;
// todo : we could also centralize the skipping of "database specific" tests here
// instead of duplicating this notion in AllTests and DatabaseSpecificFunctionalTestCase.
+ // as a test gets added, simply check to see if we should really add it via
+ // DatabaseSpecificFunctionalTestCase.appliesTo( ExecutionEnvironment.DIALECT )...
}
}
testCount++;
@@ -77,6 +79,7 @@
}
public void runTest(Test test, TestResult testResult) {
+ testPosition++;
if ( environmentSetupError != null ) {
testResult.startTest( test );
testResult.addError( test, environmentSetupError );
@@ -89,12 +92,10 @@
else {
FunctionalTestCase functionalTest = ( ( FunctionalTestCase ) test );
try {
- if ( ++testPosition < testCount ) {
- // disallow rebuilding the schema because this is the last test
- // in this suite, thus it is about to get dropped immediately
- // afterwards anyway...
- environment.setAllowRebuild( true );
- }
+ // disallow rebuilding the schema because this is the last test
+ // in this suite, thus it is about to get dropped immediately
+ // afterwards anyway...
+ environment.setAllowRebuild( testPosition < testCount );
functionalTest.setEnvironment( environment );
super.runTest( functionalTest, testResult );
}
17 years, 11 months