Hibernate SVN: r10640 - branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-10-24 06:33:00 -0400 (Tue, 24 Oct 2006)
New Revision: 10640
Modified:
branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/entity.ftl
Log:
HBX-785 Entity property table corrupt for Collections in Firefox
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/entity.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/entity.ftl 2006-10-24 00:07:14 UTC (rev 10639)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/doc/entities/entity.ftl 2006-10-24 10:33:00 UTC (rev 10640)
@@ -58,7 +58,7 @@
<#assign columnIterator = property.getValue().columnIterator>
<#assign rowspan = property.getValue().getColumnSpan()>
<TR>
- <TD WIDTH="14%" ROWSPAN="${rowspan}">
+ <TD WIDTH="14%" <#if (rowspan>0)>ROWSPAN="${rowspan}"</#if>>
<A HREF='#field_summary'>
${property.name}
</A>
@@ -84,7 +84,7 @@
</TD>
</#if>
- <TD WIDTH="14%" ROWSPAN="${rowspan}">
+ <TD WIDTH="14%" <#if (rowspan>0)>ROWSPAN="${rowspan}"</#if>>
<#if dochelper.getComponentPOJO(property)?exists>
@@ -96,7 +96,7 @@
</#if>
</TD>
- <TD WIDTH="44%" ROWSPAN="${rowspan}">
+ <TD WIDTH="44%" <#if (rowspan>0)>ROWSPAN="${rowspan}"</#if>>
<#if compoclass.hasFieldJavaDoc(property)?exists>
${compoclass.getFieldDescription(property)}
@@ -172,7 +172,7 @@
<#assign columnIterator = property.getValue().columnIterator>
<#assign rowspan = property.getValue().getColumnSpan()>
<TR>
- <TD WIDTH="14%" ROWSPAN="${rowspan}">
+ <TD WIDTH="14%" <#if (rowspan>0)>ROWSPAN="${rowspan}"</#if>>
<A HREF='#field_summary'>
${property.name}
</A>
@@ -195,11 +195,11 @@
</TD>
</#if>
- <TD WIDTH="14%" ROWSPAN="${rowspan}">
+ <TD WIDTH="14%" <#if (rowspan>0)>ROWSPAN="${rowspan}"</#if>>
${property.getPropertyAccessorName()} (<A HREF='#property_summary'>get</A> / <A HREF='#property_summary'>set</A>)
</TD>
- <TD WIDTH="14%" ROWSPAN="${rowspan}">
+ <TD WIDTH="14%" <#if (rowspan>0)>ROWSPAN="${rowspan}"</#if>>
<#if dochelper.getComponentPOJO(property)?exists>
<A HREF='${docFileManager.getRef(docFile, docFileManager.getEntityDocFileByDeclarationName(dochelper.getComponentPOJO(property)))}' TARGET="generalFrame">
@@ -209,7 +209,7 @@
</#if>
</TD>
- <TD WIDTH="44%" ROWSPAN="${rowspan}">
+ <TD WIDTH="44%" <#if (rowspan>0)>ROWSPAN="${rowspan}"</#if>>
<#if class.hasFieldJavaDoc(property)>${class.getFieldDescription(property)}
</#if> </TD>
18 years, 1 month
Hibernate SVN: r10639 - in branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java: . generics
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-10-23 20:07:14 -0400 (Mon, 23 Oct 2006)
New Revision: 10639
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/EJB3OverridenAnnotationReader.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXAnnotatedElement.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXClass.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXFactory.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/Pair.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/CompoundTypeEnvironment.java
Log:
First set of optimization to the XLayer
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/EJB3OverridenAnnotationReader.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/EJB3OverridenAnnotationReader.java 2006-10-20 16:31:39 UTC (rev 10638)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/EJB3OverridenAnnotationReader.java 2006-10-24 00:07:14 UTC (rev 10639)
@@ -11,6 +11,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
@@ -176,7 +177,8 @@
private String propertyName;
private PropertyType propertyType;
private transient Annotation[] annotations;
- private static final String WORD_SEPARATOR = "-";
+ private transient Map<Class, Annotation> annotationsMap;
+ private static final String WORD_SEPARATOR = "-";
private transient List<Element> elementsForProperty;
private AccessibleObject mirroredAttribute;
@@ -246,18 +248,12 @@
public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
initAnnotations();
- for ( Annotation annotation : annotations ) {
- if ( annotation.annotationType().equals( annotationType ) ) return (T) annotation;
- }
- return null;
+ return (T) annotationsMap.get( annotationType );
}
public <T extends Annotation> boolean isAnnotationPresent(Class<T> annotationType) {
initAnnotations();
- for ( Annotation annotation : annotations ) {
- if ( annotation.annotationType().equals( annotationType ) ) return true;
- }
- return false;
+ return (T) annotationsMap.get( annotationType ) != null;
}
public Annotation[] getAnnotations() {
@@ -267,13 +263,14 @@
private void initAnnotations() {
if ( annotations == null ) {
- XMLContext.Default defaults = xmlContext.getDefault( className );
+ XMLContext.Default defaults = xmlContext.getDefault( className );
if ( className != null && propertyName == null ) {
//is a class
Element tree = xmlContext.getXMLTree( className, null );
Annotation[] annotations = super.getAnnotations();
List<Annotation> annotationList = new ArrayList<Annotation>( annotations.length + 5 );
- for ( Annotation annotation : annotations ) {
+ annotationsMap = new HashMap<Class, Annotation>( annotations.length + 5 );
+ for ( Annotation annotation : annotations ) {
if ( ! annotationToXml.containsKey( annotation.annotationType() ) ) {
//unknown annotations are left over
annotationList.add( annotation );
@@ -321,13 +318,18 @@
if ( current != null ) annotationList.add( current );
current = getEntityListeners( tree, defaults );
if ( current != null ) annotationList.add( current );
- this.annotations = annotationList.toArray( new Annotation[ annotationList.size() ] );
- }
- else if ( className != null && propertyName != null ) {
+ //FIXME use annotationsMap rather than annotationList this will be faster since the annotation type is usually known at put() time
+ this.annotations = annotationList.toArray( new Annotation[ annotationList.size() ] );
+ for (Annotation ann : this.annotations) {
+ annotationsMap.put( ann.annotationType(), ann );
+ }
+ }
+ else if ( className != null ) { //&& propertyName != null ) { //always true but less confusing
Element tree = xmlContext.getXMLTree( className, propertyName );
Annotation[] annotations = super.getAnnotations();
List<Annotation> annotationList = new ArrayList<Annotation>( annotations.length + 5 );
- for ( Annotation annotation : annotations ) {
+ annotationsMap = new HashMap<Class, Annotation>( annotations.length + 5 );
+ for ( Annotation annotation : annotations ) {
if ( ! annotationToXml.containsKey( annotation.annotationType() ) ) {
//unknown annotations are left over
annotationList.add( annotation );
@@ -359,11 +361,18 @@
}
processEventAnnotations(annotationList, defaults);
- this.annotations = annotationList.toArray( new Annotation[ annotationList.size() ] );
- }
+ //FIXME use annotationsMap rather than annotationList this will be faster since the annotation type is usually known at put() time
+ this.annotations = annotationList.toArray( new Annotation[ annotationList.size() ] );
+ for (Annotation ann : this.annotations) {
+ annotationsMap.put( ann.annotationType(), ann );
+ }
+ }
else {
this.annotations = super.getAnnotations();
- }
+ for (Annotation ann : this.annotations) {
+ annotationsMap.put( ann.annotationType(), ann );
+ }
+ }
}
}
@@ -461,10 +470,11 @@
//no element but might have some default or some annotation
boolean defaultToJoinTable = ! ( super.isAnnotationPresent( JoinColumn.class )
|| super.isAnnotationPresent( JoinColumns.class ) );
- defaultToJoinTable = defaultToJoinTable &&
- ( ( annotation.annotationType() == ManyToMany.class && StringHelper.isEmpty( ( (ManyToMany) annotation).mappedBy() ) )
- || ( annotation.annotationType() == OneToMany.class && StringHelper.isEmpty( ( (OneToMany) annotation).mappedBy() ) )
- || ( annotation.annotationType() == CollectionOfElements.class )
+ final Class<? extends Annotation> annotationClass = annotation.annotationType();
+ defaultToJoinTable = defaultToJoinTable &&
+ ( ( annotationClass == ManyToMany.class && StringHelper.isEmpty( ( (ManyToMany) annotation).mappedBy() ) )
+ || ( annotationClass == OneToMany.class && StringHelper.isEmpty( ( (OneToMany) annotation).mappedBy() ) )
+ || ( annotationClass == CollectionOfElements.class )
);
final Class<JoinTable> annotationType = JoinTable.class;
if ( defaultToJoinTable
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXAnnotatedElement.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXAnnotatedElement.java 2006-10-20 16:31:39 UTC (rev 10638)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXAnnotatedElement.java 2006-10-24 00:07:14 UTC (rev 10639)
@@ -33,15 +33,15 @@
}
public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
- return getAnnotationReader().getAnnotation( annotationType );
+ return annotationReader.getAnnotation( annotationType );
}
public <T extends Annotation> boolean isAnnotationPresent(Class<T> annotationType) {
- return getAnnotationReader().isAnnotationPresent( annotationType );
+ return annotationReader.isAnnotationPresent( annotationType );
}
public Annotation[] getAnnotations() {
- return getAnnotationReader().getAnnotations();
+ return annotationReader.getAnnotations();
}
AnnotatedElement toAnnotatedElement() {
@@ -53,16 +53,16 @@
if ( obj == null || ! ( obj instanceof JavaXAnnotatedElement ) ) return false;
JavaXAnnotatedElement other = (JavaXAnnotatedElement) obj;
//FIXME yuk this defeat the type environment
- return toAnnotatedElement().equals( other.toAnnotatedElement() );
+ return annotatedElement.equals( other.toAnnotatedElement() );
}
@Override
public int hashCode() {
- return toAnnotatedElement().hashCode();
+ return annotatedElement.hashCode();
}
@Override
public String toString() {
- return toAnnotatedElement().toString();
+ return annotatedElement.toString();
}
}
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXClass.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXClass.java 2006-10-20 16:31:39 UTC (rev 10638)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXClass.java 2006-10-24 00:07:14 UTC (rev 10639)
@@ -20,10 +20,12 @@
class JavaXClass extends JavaXAnnotatedElement implements XClass {
private final TypeEnvironment context;
+ private final Class clazz;
- public JavaXClass(Class clazz, TypeEnvironment env, JavaXFactory factory) {
+ public JavaXClass(Class clazz, TypeEnvironment env, JavaXFactory factory) {
super( clazz, factory );
- this.context = env;
+ this.clazz = clazz; //optimization
+ this.context = env;
}
public String getName() {
@@ -110,7 +112,7 @@
}
public Class<?> toClass() {
- return (Class) toAnnotatedElement();
+ return clazz;
}
public boolean isAssignableFrom(XClass c) {
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXFactory.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXFactory.java 2006-10-20 16:31:39 UTC (rev 10638)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/JavaXFactory.java 2006-10-24 00:07:14 UTC (rev 10639)
@@ -174,8 +174,6 @@
JavaXClass result = xClasses.get( key );
if ( result == null ) {
result = new JavaXClass( classType, context, JavaXFactory.this );
- //TODO get rid of it
- //result.setXMLDescriptor( xml );
xClasses.put( key, result );
}
return result;
@@ -192,8 +190,6 @@
JavaXPackage xPackage = packagesToXPackages.get( pkg );
if ( xPackage == null ) {
xPackage = new JavaXPackage( pkg, this );
- //TODO get rid of it
- //xPackage.setXMLDescriptor( xml );
packagesToXPackages.put( pkg, xPackage );
}
return xPackage;
@@ -201,8 +197,9 @@
XProperty getXProperty(Member member, JavaXClass owner) {
MemberKey key = new MemberKey( member, owner.toClass(), owner.getTypeEnvironment() );
- JavaXProperty xProperty = xProperties.get( key );
- if ( ! xProperties.containsKey( key ) ) {
+ //FIXME get is as expensive as create most time spent in hashCode and equals
+ JavaXProperty xProperty = xProperties.get( key );
+ if ( xProperty == null ) {
xProperty = JavaXProperty.create( member, owner.getTypeEnvironment(), this );
xProperties.put( key, xProperty );
}
@@ -211,8 +208,9 @@
XMethod getXMethod(Member member, JavaXClass owner) {
MemberKey key = new MemberKey( member, owner.toClass(), owner.getTypeEnvironment() );
- JavaXMethod xMethod = xMethods.get( key );
- if ( ! xMethods.containsKey( key ) ) {
+ //FIXME get is as expensive as create most time spent in hashCode and equals
+ JavaXMethod xMethod = xMethods.get( key );
+ if ( xMethod == null ) {
xMethod = JavaXMethod.create( member, owner.getTypeEnvironment(), this );
xMethods.put( key, xMethod );
}
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/Pair.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/Pair.java 2006-10-20 16:31:39 UTC (rev 10638)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/Pair.java 2006-10-24 00:07:14 UTC (rev 10639)
@@ -11,11 +11,13 @@
private final T o1;
private final U o2;
+ private final int hashCode;
- Pair(T o1, U o2) {
+ Pair(T o1, U o2) {
this.o1 = o1;
this.o2 = o2;
- }
+ this.hashCode = doHashCode();
+ }
@Override
public boolean equals(Object obj) {
@@ -23,11 +25,20 @@
return false;
}
Pair other = (Pair) obj;
- return safeEquals( o1, other.o1 ) && safeEquals( o2, other.o2 );
+ return !differentHashCode( other ) && safeEquals( o1, other.o1 ) && safeEquals( o2, other.o2 );
+ }
+
+ private boolean differentHashCode(Pair other) {
+ return hashCode != other.hashCode;
+ }
+
+ @Override
+ public int hashCode() {
+ //cached because the inheritance can be big
+ return hashCode;
}
- @Override
- public int hashCode() {
+ private int doHashCode() {
return safeHashCode( o1 ) ^ safeHashCode( o2 );
}
@@ -42,7 +53,6 @@
if ( obj1 == null ) {
return obj2 == null;
}
- boolean result = obj1.equals( obj2 );
- return result;
+ return obj1.equals( obj2 );
}
}
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/CompoundTypeEnvironment.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/CompoundTypeEnvironment.java 2006-10-20 16:31:39 UTC (rev 10638)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/reflection/java/generics/CompoundTypeEnvironment.java 2006-10-24 00:07:14 UTC (rev 10639)
@@ -13,11 +13,13 @@
private final TypeEnvironment f;
private final TypeEnvironment g;
+ private final int hashCode;
- public CompoundTypeEnvironment(TypeEnvironment f, TypeEnvironment g) {
+ public CompoundTypeEnvironment(TypeEnvironment f, TypeEnvironment g) {
this.f = f;
this.g = g;
- }
+ hashCode = doHashCode();
+ }
public Type bind(Type type) {
return f.bind( g.bind( type ) );
@@ -25,20 +27,30 @@
public boolean equals(Object o) {
if ( this == o ) return true;
- if ( o == null || getClass() != o.getClass() ) return false;
+ if ( ! ( o instanceof CompoundTypeEnvironment ) ) return false;
final CompoundTypeEnvironment that = (CompoundTypeEnvironment) o;
- if ( !f.equals( that.f ) ) return false;
- if ( !g.equals( that.g ) ) return false;
+ if ( differentHashCode( that ) ) return false;
- return true;
- }
+ if ( !f.equals( that.f ) ) return false;
+ return g.equals( that.g );
- public int hashCode() {
+ }
+
+ private boolean differentHashCode(CompoundTypeEnvironment that) {
+ return hashCode != that.hashCode;
+ }
+
+ private int doHashCode() {
int result;
result = f.hashCode();
result = 29 * result + g.hashCode();
return result;
}
+
+ public int hashCode() {
+ //cached because the inheritance can be big
+ return hashCode;
+ }
}
18 years, 1 month
Hibernate SVN: r10638 - in branches/Branch_3_2/HibernateExt/metadata/src: java/org/hibernate/validator/interpolator test/org/hibernate/validator/test/haintegration
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-10-20 12:31:39 -0400 (Fri, 20 Oct 2006)
New Revision: 10638
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/haintegration/Building.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/haintegration/InterpolationTest.java
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/DefaultMessageInterpolator.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/haintegration/EmbeddedObjectTest.java
Log:
ANN-471 lazily resolve default message
ANN-458 left unresolved key unchanged
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/DefaultMessageInterpolator.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/DefaultMessageInterpolator.java 2006-10-20 10:07:59 UTC (rev 10637)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/interpolator/DefaultMessageInterpolator.java 2006-10-20 16:31:39 UTC (rev 10638)
@@ -63,8 +63,8 @@
if (annotationMessage == null) {
throw new IllegalArgumentException( "Annotation " + clazz + " does not have an (accessible) message attribute");
}
- interpolateMessage = replace( annotationMessage );
- }
+ //do not resolve the property eagerly to allow validator.apply to work wo interpolator
+ }
private String replace(String message) {
StringTokenizer tokens = new StringTokenizer( message, "#{}", true );
@@ -104,11 +104,8 @@
string = defaultMessageBundle.getString( token );
}
catch( MissingResourceException e) {
- throw new MissingResourceException(
- "Can't find resource in validator bundles, key " + token,
- defaultMessageBundle.getClass().getName(),
- token
- );
+ //return the unchanged string
+ buf.append('{').append(token).append('}');
}
}
if ( string != null ) buf.append( replace( string ) );
@@ -121,7 +118,10 @@
public String interpolate(String message, Validator validator, MessageInterpolator defaultInterpolator) {
if ( annotationMessage.equals( message ) ) {
//short cut
- return interpolateMessage;
+ if (interpolateMessage == null) {
+ interpolateMessage = replace( annotationMessage );
+ }
+ return interpolateMessage;
}
else {
//TODO keep them in a weak hash map, but this might not even be useful
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/haintegration/Building.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/haintegration/Building.java 2006-10-20 10:07:59 UTC (rev 10637)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/haintegration/Building.java 2006-10-20 16:31:39 UTC (rev 10638)
@@ -0,0 +1,38 @@
+//$Id: $
+package org.hibernate.validator.test.haintegration;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.hibernate.validator.NotNull;
+import org.hibernate.validator.Length;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Building {
+ @Id
+ @GeneratedValue private Long id;
+
+ @Length(min=1, message = "{notpresent.Key} and #{key.notPresent} and {key.notPresent2} {min}")
+ private String address;
+
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+}
Modified: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/haintegration/EmbeddedObjectTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/haintegration/EmbeddedObjectTest.java 2006-10-20 10:07:59 UTC (rev 10637)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/haintegration/EmbeddedObjectTest.java 2006-10-20 16:31:39 UTC (rev 10638)
@@ -3,8 +3,15 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.event.PreInsertEventListener;
+import org.hibernate.event.PreUpdateEventListener;
+import org.hibernate.cfg.Configuration;
import org.hibernate.test.annotations.TestCase;
import org.hibernate.validator.ClassValidator;
+import org.hibernate.validator.Environment;
+import org.hibernate.validator.event.ValidatePreInsertEventListener;
+import org.hibernate.validator.event.ValidatePreUpdateEventListener;
+import org.hibernate.validator.test.PrefixMessageInterpolator;
/**
* @author Emmanuel Bernard
@@ -34,4 +41,11 @@
CreditCard.class
};
}
+
+ protected void configure(Configuration cfg) {
+ cfg.getEventListeners()
+ .setPreInsertEventListeners( new PreInsertEventListener[]{new ValidatePreInsertEventListener()} );
+ cfg.getEventListeners()
+ .setPreUpdateEventListeners( new PreUpdateEventListener[]{new ValidatePreUpdateEventListener()} );
+ }
}
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/haintegration/InterpolationTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/haintegration/InterpolationTest.java 2006-10-20 10:07:59 UTC (rev 10637)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/haintegration/InterpolationTest.java 2006-10-20 16:31:39 UTC (rev 10638)
@@ -0,0 +1,70 @@
+//$Id: $
+package org.hibernate.validator.test.haintegration;
+
+import java.util.MissingResourceException;
+
+import org.hibernate.test.annotations.TestCase;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.event.PreInsertEventListener;
+import org.hibernate.event.PreUpdateEventListener;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.validator.InvalidStateException;
+import org.hibernate.validator.Environment;
+import org.hibernate.validator.event.ValidatePreInsertEventListener;
+import org.hibernate.validator.event.ValidatePreUpdateEventListener;
+import org.hibernate.validator.test.PrefixMessageInterpolator;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class InterpolationTest extends TestCase {
+ public void testMissingKey() {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ Building b = new Building();
+ b.setAddress( "2323 Younge St");
+ try {
+ s.persist( b );
+ s.flush();
+ }
+ catch (MissingResourceException e) {
+ fail("message should be interpolated lazily in DefaultMessageInterpolator");
+ }
+ tx.rollback();
+ s.close();
+
+ s = openSession();
+ tx = s.beginTransaction();
+ b = new Building();
+ b.setAddress("");
+ boolean failure = false;
+ try {
+ s.persist( b );
+ s.flush();
+ fail("Insert should fail");
+ }
+ catch (InvalidStateException e) {
+ assertEquals( "Missing key should be left unchanged",
+ "{notpresent.Key} and #{key.notPresent} and {key.notPresent2} 1",
+ e.getInvalidValues()[0].getMessage() );
+ failure = true;
+ }
+ assertTrue( "No invalid state found", failure );
+ tx.rollback();
+ s.close();
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ Building.class
+ };
+ }
+
+ protected void configure(Configuration cfg) {
+ cfg.getEventListeners()
+ .setPreInsertEventListeners( new PreInsertEventListener[]{new ValidatePreInsertEventListener()} );
+ cfg.getEventListeners()
+ .setPreUpdateEventListeners( new PreUpdateEventListener[]{new ValidatePreUpdateEventListener()} );
+ }
+}
18 years, 1 month
Hibernate SVN: r10637 - in branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool: . ant hbm2x hbm2x/hbm2hbmxml hbm2x/query hbmlint ide/completion stat test test/jdbc2cfg
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-10-20 06:07:59 -0400 (Fri, 20 Oct 2006)
New Revision: 10637
Modified:
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/JDBCMetaDataBinderTestCase.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ToolAllTests.java
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/SeamAntTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/GenerateFromJDBCTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/HashcodeEqualsTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/IncrementalSchemaReadingTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/InheritanceTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/query/QueryExporterTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/FakeNonLazy.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ide/completion/CompletionHelperTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ide/completion/HqlAnalyzerTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/stat/Group.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/stat/SessionAttribute.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/DriverMetaDataTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/OverrideBinderTest.java
Log:
imports
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/JDBCMetaDataBinderTestCase.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/JDBCMetaDataBinderTestCase.java 2006-10-20 08:39:57 UTC (rev 10636)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/JDBCMetaDataBinderTestCase.java 2006-10-20 10:07:59 UTC (rev 10637)
@@ -10,12 +10,10 @@
import java.sql.Statement;
import java.util.Iterator;
-
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.JDBCMetaDataConfiguration;
import org.hibernate.cfg.Settings;
import org.hibernate.cfg.reveng.TableIdentifier;
-import org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect;
import org.hibernate.mapping.ForeignKey;
import org.hibernate.mapping.Table;
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ToolAllTests.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ToolAllTests.java 2006-10-20 08:39:57 UTC (rev 10636)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ToolAllTests.java 2006-10-20 10:07:59 UTC (rev 10637)
@@ -1,12 +1,12 @@
package org.hibernate.tool;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
import org.hibernate.tool.hbm2x.query.QueryAllTests;
import org.hibernate.tool.hbmlint.HbmLintAllTests;
import org.hibernate.tool.ide.completion.CompletionAllTests;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
public class ToolAllTests {
public static Test suite() {
Modified: 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-10-20 08:39:57 UTC (rev 10636)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/HibernateToolTest.java 2006-10-20 10:07:59 UTC (rev 10637)
@@ -6,12 +6,12 @@
import java.io.File;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
import org.apache.tools.ant.BuildException;
import org.hibernate.tool.test.TestHelper;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
/**
* @author max
*
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/SeamAntTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/SeamAntTest.java 2006-10-20 08:39:57 UTC (rev 10636)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/SeamAntTest.java 2006-10-20 10:07:59 UTC (rev 10637)
@@ -5,7 +5,6 @@
package org.hibernate.tool.ant;
import java.io.File;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -16,9 +15,6 @@
import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;
import org.hibernate.tool.test.TestHelper;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
/**
* A temporary test class for controlling the seam template generation
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/GenerateFromJDBCTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/GenerateFromJDBCTest.java 2006-10-20 08:39:57 UTC (rev 10636)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/GenerateFromJDBCTest.java 2006-10-20 10:07:59 UTC (rev 10637)
@@ -5,9 +5,7 @@
package org.hibernate.tool.hbm2x;
import java.io.File;
-import java.util.HashMap;
import java.util.Iterator;
-import java.util.Map;
import org.dom4j.Document;
import org.dom4j.DocumentException;
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/HashcodeEqualsTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/HashcodeEqualsTest.java 2006-10-20 08:39:57 UTC (rev 10636)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/HashcodeEqualsTest.java 2006-10-20 10:07:59 UTC (rev 10637)
@@ -6,24 +6,8 @@
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 org.hibernate.mapping.Component;
-import org.hibernate.mapping.MetaAttribute;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Property;
-import org.hibernate.mapping.RootClass;
-import org.hibernate.mapping.SingleTableSubclass;
-import org.hibernate.mapping.Value;
import org.hibernate.tool.NonReflectiveTestCase;
-import org.hibernate.tool.hbm2x.pojo.BasicPOJOClass;
-import org.hibernate.tool.hbm2x.pojo.ImportContext;
-import org.hibernate.tool.hbm2x.pojo.ImportContextImpl;
-import org.hibernate.tool.hbm2x.pojo.NoopImportContext;
-import org.hibernate.tool.hbm2x.pojo.POJOClass;
import org.hibernate.tool.test.TestHelper;
/**
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/IncrementalSchemaReadingTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/IncrementalSchemaReadingTest.java 2006-10-20 08:39:57 UTC (rev 10636)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/IncrementalSchemaReadingTest.java 2006-10-20 10:07:59 UTC (rev 10637)
@@ -5,12 +5,9 @@
package org.hibernate.tool.hbm2x;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Set;
-import org.hibernate.cfg.Environment;
import org.hibernate.cfg.JDBCMetaDataConfiguration;
import org.hibernate.cfg.JDBCReaderFactory;
import org.hibernate.cfg.Settings;
@@ -18,9 +15,7 @@
import org.hibernate.cfg.reveng.DefaultDatabaseCollector;
import org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.JDBCReader;
-import org.hibernate.cfg.reveng.OverrideRepository;
import org.hibernate.cfg.reveng.SchemaSelection;
-import org.hibernate.cfg.reveng.TableIdentifier;
import org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect;
import org.hibernate.mapping.Table;
import org.hibernate.tool.JDBCMetaDataBinderTestCase;
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/InheritanceTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/InheritanceTest.java 2006-10-20 08:39:57 UTC (rev 10636)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/InheritanceTest.java 2006-10-20 10:07:59 UTC (rev 10637)
@@ -8,16 +8,10 @@
package org.hibernate.tool.hbm2x.hbm2hbmxml;
import java.io.File;
-import java.util.List;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.dom4j.Document;
-import org.dom4j.DocumentException;
-import org.dom4j.DocumentHelper;
-import org.dom4j.Element;
-import org.dom4j.XPath;
import org.dom4j.io.SAXReader;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.NonReflectiveTestCase;
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/query/QueryExporterTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/query/QueryExporterTest.java 2006-10-20 08:39:57 UTC (rev 10636)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/query/QueryExporterTest.java 2006-10-20 10:07:59 UTC (rev 10637)
@@ -5,7 +5,6 @@
import java.util.List;
import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
import org.hibernate.cfg.Environment;
import org.hibernate.classic.Session;
import org.hibernate.tool.NonReflectiveTestCase;
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/FakeNonLazy.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/FakeNonLazy.java 2006-10-20 08:39:57 UTC (rev 10636)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/FakeNonLazy.java 2006-10-20 10:07:59 UTC (rev 10637)
@@ -1,11 +1,11 @@
package org.hibernate.tool.hbmlint;
+import net.sf.cglib.transform.impl.InterceptFieldCallback;
+import net.sf.cglib.transform.impl.InterceptFieldEnabled;
+
import org.hibernate.bytecode.javassist.FieldHandled;
import org.hibernate.bytecode.javassist.FieldHandler;
-import net.sf.cglib.transform.impl.InterceptFieldCallback;
-import net.sf.cglib.transform.impl.InterceptFieldEnabled;
-
public class FakeNonLazy implements InterceptFieldEnabled, FieldHandled {
long id;
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ide/completion/CompletionHelperTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ide/completion/CompletionHelperTest.java 2006-10-20 08:39:57 UTC (rev 10636)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ide/completion/CompletionHelperTest.java 2006-10-20 10:07:59 UTC (rev 10637)
@@ -19,6 +19,7 @@
import java.util.ArrayList;
import java.util.List;
+
import junit.framework.TestCase;
/**
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ide/completion/HqlAnalyzerTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ide/completion/HqlAnalyzerTest.java 2006-10-20 08:39:57 UTC (rev 10636)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ide/completion/HqlAnalyzerTest.java 2006-10-20 10:07:59 UTC (rev 10637)
@@ -19,6 +19,7 @@
import java.util.Iterator;
import java.util.List;
+
import junit.framework.TestCase;
/**
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/stat/Group.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/stat/Group.java 2006-10-20 08:39:57 UTC (rev 10636)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/stat/Group.java 2006-10-20 10:07:59 UTC (rev 10637)
@@ -1,9 +1,7 @@
//$Id: Group.java 5686 2005-02-12 07:27:32Z steveebersole $
package org.hibernate.tool.stat;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
/**
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/stat/SessionAttribute.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/stat/SessionAttribute.java 2006-10-20 08:39:57 UTC (rev 10636)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/stat/SessionAttribute.java 2006-10-20 10:07:59 UTC (rev 10637)
@@ -1,7 +1,6 @@
//$Id: SessionAttribute.java 5686 2005-02-12 07:27:32Z steveebersole $
package org.hibernate.tool.stat;
-import java.io.Serializable;
/**
* @author Gavin King
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/DriverMetaDataTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/DriverMetaDataTest.java 2006-10-20 08:39:57 UTC (rev 10636)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/DriverMetaDataTest.java 2006-10-20 10:07:59 UTC (rev 10637)
@@ -3,7 +3,6 @@
import java.util.Iterator;
import java.util.Map;
-import org.hibernate.cfg.JDBCReaderFactory;
import org.hibernate.cfg.Settings;
import org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect;
import org.hibernate.cfg.reveng.dialect.MetaDataDialect;
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/OverrideBinderTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/OverrideBinderTest.java 2006-10-20 08:39:57 UTC (rev 10636)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/OverrideBinderTest.java 2006-10-20 10:07:59 UTC (rev 10637)
@@ -4,7 +4,6 @@
*/
package org.hibernate.tool.test.jdbc2cfg;
-import java.io.File;
import java.sql.Types;
import java.util.Iterator;
import java.util.List;
@@ -13,7 +12,6 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.cfg.JDBCMetaDataConfiguration;
import org.hibernate.cfg.Settings;
@@ -34,7 +32,6 @@
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.tool.JDBCMetaDataBinderTestCase;
-import org.hibernate.tool.hbm2x.HibernateMappingExporter;
/**
* @author max
18 years, 1 month
Hibernate SVN: r10636 - branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-10-20 04:39:57 -0400 (Fri, 20 Oct 2006)
New Revision: 10636
Modified:
branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/package-info.java
Log:
fixed non-compilable package-info
Modified: branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/package-info.java
===================================================================
--- branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/package-info.java 2006-10-20 08:39:42 UTC (rev 10635)
+++ branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/package-info.java 2006-10-20 08:39:57 UTC (rev 10636)
@@ -1,3 +1,4 @@
@NamedQuery(name = "countItems", query = "select count(i) from Item i") package org.hibernate.ejb.test;
-import javax.persistence.NamedQuery;
\ No newline at end of file
+import org.hibernate.annotations.NamedQuery;
+
18 years, 1 month
Hibernate SVN: r10635 - in branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack: defaultpar explodedpar
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-10-20 04:39:42 -0400 (Fri, 20 Oct 2006)
New Revision: 10635
Modified:
branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/defaultpar/package-info.java
branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/explodedpar/package-info.java
Log:
fixed non-compilable package-info
Modified: branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/defaultpar/package-info.java
===================================================================
--- branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/defaultpar/package-info.java 2006-10-20 08:35:35 UTC (rev 10634)
+++ branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/defaultpar/package-info.java 2006-10-20 08:39:42 UTC (rev 10635)
@@ -1,4 +1,5 @@
@NamedQuery(name = "allMouse",
query = "select m from ApplicationServer m") package org.hibernate.ejb.test.pack.defaultpar;
-import javax.persistence.NamedQuery;
\ No newline at end of file
+import org.hibernate.annotations.NamedQuery;
+
Modified: branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/explodedpar/package-info.java
===================================================================
--- branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/explodedpar/package-info.java 2006-10-20 08:35:35 UTC (rev 10634)
+++ branches/Branch_3_2/HibernateExt/ejb/src/test/org/hibernate/ejb/test/pack/explodedpar/package-info.java 2006-10-20 08:39:42 UTC (rev 10635)
@@ -1,3 +1,4 @@
@NamedQuery(name = "allCarpet", query = "select c from Carpet c") package org.hibernate.ejb.test.pack.explodedpar;
-import javax.persistence.NamedQuery;
\ No newline at end of file
+import org.hibernate.annotations.NamedQuery;
+
18 years, 1 month
Hibernate SVN: r10634 - in branches/Branch_3_2/HibernateExt/tools: doc/reference/en/modules etc src/java/org/hibernate/cfg/reveng src/java/org/hibernate/tool/ant src/test/org/hibernate/tool src/test/org/hibernate/tool/hbm2x src/test/org/hibernate/tool/hbmlint src/test/org/hibernate/tool/test src/test/org/hibernate/tool/test/jdbc2cfg src/testsupport/generictemplates/pojo
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-10-20 04:35:35 -0400 (Fri, 20 Oct 2006)
New Revision: 10634
Added:
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenLazy.hbm.xml
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenLazy.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenNonLazy.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/CachingSettings.hbm.xml
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/FakeNonLazy.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/HbmLintAllTests.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/HbmLintTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/IdentifierIssues.hbm.xml
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/SchemaAnalyzerTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/SchemaIssues.hbm.xml
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/newformat.reveng
Removed:
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenLazy.hbm.xml
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenLazy.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenNonLazy.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/CachingSettings.hbm.xml
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/FakeNonLazy.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/HbmLintAllTests.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/HbmLintTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/IdentifierIssues.hbm.xml
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/SchemaAnalyzerTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/SchemaIssues.hbm.xml
Modified:
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/ant.xml
branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/codegen.xml
branches/Branch_3_2/HibernateExt/tools/etc/hibernate.properties
branches/Branch_3_2/HibernateExt/tools/etc/log4j.properties
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideRepository.java
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/ant/HibernateToolTask.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/JDBCMetaDataBinderTestCase.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java
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/test/DriverMetaDataTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/CompositeIdTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/PersistentClassesTest.java
branches/Branch_3_2/HibernateExt/tools/src/testsupport/generictemplates/pojo/generic-class.ftl
Log:
merge from trunk to 3.2
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/ant.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/ant.xml 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/ant.xml 2006-10-20 08:35:35 UTC (rev 10634)
@@ -22,8 +22,9 @@
e.g. Hibernate 3.2 jar's with e.g. an Hibernate 3.1 project since
the output generated will work with previous Hibernate 3 versions.
</para>
-
- <section>
+ </section>
+
+ <section>
<title>The <literal><hibernatetool></literal> ant Task</title>
<para>To use the ant tasks you need to have the hibernatetool task
@@ -825,5 +826,4 @@
</section>
</section>
</section>
- </section>
</chapter>
Modified: branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/codegen.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/codegen.xml 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/doc/reference/en/modules/codegen.xml 2006-10-20 08:35:35 UTC (rev 10634)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<chapter id="codegen">
<title>Controlling POJO code generation</title>
@@ -24,26 +24,26 @@
<para>The following example shows how to use various <meta>
attributes and the resulting java code.</para>
- <programlisting><![CDATA[<class name="Person">
- <meta attribute="class-description">
+ <programlisting><class name="Person">
+ <meta attribute="class-description">
Javadoc for the Person class
@author Frodo
- </meta>
- <meta attribute="implements">IAuditable</meta>
- <id name="id" type="long">
- <meta attribute="scope-set">protected</meta>
- <generator class="increment"/>
- </id>
- <property name="name" type="string">
- <meta attribute="field-description">The name of the person</meta>
- </property>
-</class>]]></programlisting>
+ </meta>
+ <meta attribute="implements">IAuditable</meta>
+ <id name="id" type="long">
+ <meta attribute="scope-set">protected</meta>
+ <generator class="increment"/>
+ </id>
+ <property name="name" type="string">
+ <meta attribute="field-description">The name of the person</meta>
+ </property>
+</class></programlisting>
<para>The above hbm.xml will produce something like the following (code
shortened for better understanding). Notice the Javadoc comment and the
protected set methods:</para>
- <programlisting><![CDATA[// default package
+ <programlisting>// default package
import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
@@ -86,7 +86,7 @@
this.name = name;
}
-}]]></programlisting>
+}</programlisting>
<table frame="topbot">
<title>Supported meta tags</title>
@@ -244,5 +244,294 @@
attribute, e.g. <literal><meta attribute="scope-class"
inherit="false">public abstract</meta></literal> will restrict
the "class-scope" to the current class, not the subclasses.</para>
+
+ <section>
+ <title>Recomendations</title>
+
+ <para>The following are some good practices when using
+ <literal><meta></literal> attributes.</para>
+
+ <section>
+ <title>Dangers of a class level <literal>use-in-string and
+ use-in-equals</literal> meta attributes when having bi-directional
+ associations</title>
+
+ <para>If we have two entities with a bi-directional association
+ between them and define at class scope level the meta attributes:
+ <literal>use-in-string, use-in-equals</literal>:</para>
+
+ <programlisting><hibernate-mapping>
+ <class name="Person">
+ <meta attribute="use-in-tostring">true</meta>
+ <meta attribute="use-in-equals">true</meta>
+ ...
+ </class>
+</hibernate-mapping></programlisting>
+
+ <para>and for <literal>Event.hbm</literal> file:</para>
+
+ <programlisting><hibernate-mapping>
+ <class name="events.Event" table="EVENTS">
+ <meta attribute="use-in-tostring">true</meta>
+ <meta attribute="use-in-equals">true</meta>
+ <id name="id" column="EVENT_ID">
+ <generator class="native"/>
+ </id>
+ <property name="date" type="timestamp" column="EVENT_DATE"/>
+ <property name="title"/>
+ <set name="participants" table="PERSON_EVENT" inverse="true">
+ <key column="EVENT_ID"/>
+ <many-to-many column="PERSON_ID" class="events.Person"/>
+ </set>
+ </class>
+</hibernate-mapping></programlisting>
+
+ <para>Then <literal><hbm2java></literal> will assume you want to
+ include all properties and collections in the
+ <literal>toString()/equals()</literal> methods and this can result in
+ infinite recursive calls.</para>
+
+ <para>To remedy this you have to decide which side of the association
+ will include the other part (if at all) in the
+ <literal>toString()/equals()</literal> methods. Therefore it is not a
+ good practice to put at class scope such meta attributes, unless you
+ are defining a class without bi-directional associations</para>
+
+ <para>We recomend instead to add the <literal>meta</literal>
+ attributes at the property level:</para>
+
+ <programlisting><hibernate-mapping>
+ <class name="events.Event" table="EVENTS">
+ <id name="id" column="EVENT_ID">
+ <meta attribute="use-in-tostring">true</meta>
+ <generator class="native"/>
+ </id>
+ <property name="date" type="timestamp" column="EVENT_DATE"/>
+ <property name="title">
+ <meta attribute="use-in-tostring">true</meta>
+ <meta attribute="use-in-equals">true</meta>
+ </property>
+ <set name="participants" table="PERSON_EVENT" inverse="true">
+ <key column="EVENT_ID"/>
+ <many-to-many column="PERSON_ID" class="events.Person"/>
+ </set>
+ </class>
+</hibernate-mapping></programlisting>
+
+ <para>and now for <literal>Person</literal>:</para>
+
+ <programlisting><hibernate-mapping>
+ <class name="Person">
+ <meta attribute="class-description">
+ Javadoc for the Person class
+ @author Frodo
+ </meta>
+ <meta attribute="implements">IAuditable</meta>
+ <id name="id" type="long">
+ <meta attribute="scope-set">protected</meta>
+ <meta attribute="use-in-tostring">true</meta>
+ <generator class="increment"/>
+ </id>
+ <property name="name" type="string">
+ <meta attribute="field-description">The name of the person</meta>
+ <meta attribute="use-in-tostring">true</meta>
+ </property>
+ </class>
+</hibernate-mapping></programlisting>
+ </section>
+
+ <section>
+ <title>Be aware of putting at class scope level
+ <literal><meta></literal> attribute
+ <literal>use-in-equals</literal></title>
+
+ <para>For <literal>equal()/hashCode()</literal> method generation, you
+ have to take into account that the attributes that participate on such
+ method definition, should take into account only attributes with
+ business meaning (the name, social security number, etc, but no
+ generated id's, for example).</para>
+
+ <para>This is important because Java's hashbased collections, such as
+ java.util.Set relies on equals() and hashcode() to be correct and not
+ change for objects in the set; this can be a problem if the id gets
+ assigned for an object after you inserted it into a set.</para>
+
+ <para>Therefore automatically configuration the generation of
+ <literal>equals()/hashCode()</literal> methods specifying at class
+ scope level the <literal><meta></literal> attribute
+ <literal>use-in-equals</literal> could be a dangerous decision that
+ could produce non expected side-effect.</para>
+
+ <para>See http://www.hibernate.org/109.html for an more in-depth
+ explanation on the subject of equals() and hashcode().</para>
+ </section>
+ </section>
+
+ <section>
+ <title>Advanced <literal><meta></literal> attribute
+ examples</title>
+
+ <para>This section shows an example for using meta attributes (including
+ userspecific attributes) together with the code generation features in
+ Hibernate Tools.</para>
+
+ <para>The usecase being implemented is to automatically insert some pre-
+ and post-conditions into the getter and setters of the generated POJO.
+ </para>
+
+ <section>
+ <title>Generate pre/post-conditions for methods</title>
+
+ <para>With an <literal><meta attribute="class-code"></literal>,
+ you can add addional methods on a given class, nevertheless such
+ <literal><meta></literal> attribute can not be used at property
+ scope level and Hibernatetools does not provide such
+ <literal><meta></literal> attributes.</para>
+
+ <para>A possibly solution for this is to modify the freemarker
+ templates responsable for generating the POJO's. If you look inside
+ <literal>hibernate-tools.jar</literal>, you can find the template:
+ <literal>pojo/PojoPropertyAccessor.ftl</literal></para>
+
+ <para>This file is as the named indicates used to generate property
+ accessors for pojo's.</para>
+
+ <para>Extract the <literal>PojoPropertyAccessor.ftl</literal> into a
+ local folder i.e. <literal>${hbm.template.path}</literal>, respecting
+ the whole path, for example:
+ <literal>${hbm.template.path}/pojo/PojoPropertyAccessor.ftl</literal></para>
+
+ <para>The contents of the file is something like this:</para>
+
+ <programlisting><#foreach property in pojo.getAllPropertiesIterator()>
+ ${pojo.getPropertyGetModifiers(property)} ${pojo.getJavaTypeName(property, jdk5)} ${pojo.getGetterSignature(property)}() {
+ return this.${property.name};
+ }
+
+ ${pojo.getPropertySetModifiers(property)} void set${pojo.getPropertyName(property)}(${pojo.getJavaTypeName(property, jdk5)} ${property.name}) {
+ this.${property.name} = ${property.name};
+ }
+</#foreach></programlisting>
+
+ <para>We can add conditionally pre/post-conditions on our
+ <literal>set</literal> method generation just adding a little
+ Freemarker syntax to the above source code:</para>
+
+ <programlisting><#foreach property in pojo.getAllPropertiesIterator()>
+ ${pojo.getPropertyGetModifiers(property)} ${pojo.getJavaTypeName(property, jdk5)} ${pojo.getGetterSignature(property)}() {
+ return this.${property.name};
+ }
+
+ ${pojo.getPropertySetModifiers(property)} void set${pojo.getPropertyName(property)}(${pojo.getJavaTypeName(property, jdk5)} ${property.name}) {
+ <#if pojo.hasMetaAttribute(property, "pre-cond")>
+ ${c2j.getMetaAsString(property, "pre-cond","\n")}
+ </#if>
+ this.${property.name} = ${property.name};
+ <#if pojo.hasMetaAttribute(property, "post-cond")>
+ ${c2j.getMetaAsString(property, "post-cond","\n")}
+ </#if>
+}
+</#foreach>
+</programlisting>
+
+ <para>Now if in any <literal>*hbm.xml</literal> file we define the
+ <literal><meta></literal> attributes:
+ <literal>pre-cond</literal> or <literal>post-cond</literal>, their
+ contents will be generated into the body of the relevant
+ <literal>set</literal> method.</para>
+
+ <para>As an examlpe let us add a pre-condition for property
+ <literal>name</literal> preventing no <literal>Person</literal> can
+ have an empty name. So we have to modify the
+ <literal>Person.hbm.xml</literal> file like this:</para>
+
+ <programlisting><hibernate-mapping>
+ <class name="Person">
+ <id name="id" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="firstName" type="string">
+ <meta attribute="pre-cond"><![CDATA[
+ if ((firstName != null) && (firstName.length() == 0) ) {
+ throw new IllegalArgumentException("firstName can not be an empty String");
+ }]]>
+ </meta>
+ </property>
+</class>
+</hibernate-mapping></programlisting>
+
+ <para>Notes: i) If you don't use <literal><[[CDATA[]]></literal>
+ you have to scape the & symbol, i.e.: &amp; ii). Note that we
+ are referring to "firstName" directly and this is the parameter name
+ not the actual field name. If you want to refer the field you have to
+ use "this.firstName" instead. </para>
+
+ <para>Finally we have to generate the <literal>Person.java</literal>
+ class, for this we can use both Eclipse and Ant as long as you
+ remember to set or fill in the templatepath setting. For Ant we
+ configure <literal><hibernatetool></literal> task via
+ <literal>the templatepath</literal> attribute as in:</para>
+
+ <programlisting>
+ <target name="hbm2java">
+ <taskdef name="hibernatetool"
+ classname="org.hibernate.tool.ant.HibernateToolTask"
+ classpathref="lib.classpath"/>
+ <hibernatetool destdir="${hbm2java.dest.dir}"
+ templatepath="${hbm.template.path}">
+ <classpath>
+ <path refid="pojo.classpath"/>
+ </classpath>
+ <configuration>
+ <fileset dir="${hbm2java.src.dir}">
+ <include name="**/*.hbm.xml"/>
+ </fileset>
+ </configuration>
+ <hbm2java/>
+ </hibernatetool>
+ </target></programlisting>
+
+ <para>Invoking the target <literal><hbm2java></literal> will
+ generate on the <literal>${hbm2java.dest.dir}</literal> the file:
+ <literal>Person.java</literal>:</para>
+
+ <programlisting>// default package
+import java.io.Serializable;
+public class Person implements Serializable {
+
+ public Long id;
+
+ public String name;
+
+ public Person(java.lang.String name) {
+ this.name = name;
+ }
+
+ public Person() {
+ }
+
+ public java.lang.Long getId() {
+ return this.id;
+ }
+
+ public void setId(java.lang.Long id) {
+ this.id = id;
+ }
+
+ public java.lang.String getName() {
+ return this.name;
+ }
+
+ public void setName(java.lang.String name) {
+ if ((name != null) && (name.length() == 0)) {
+ throw new IllegalArgumentException("name can not be an empty String");
+ }
+ this.name = name;
+ }
+}</programlisting>
+
+ <para></para>
+ </section>
+ </section>
</section>
</chapter>
\ No newline at end of file
Modified: branches/Branch_3_2/HibernateExt/tools/etc/hibernate.properties
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/etc/hibernate.properties 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/etc/hibernate.properties 2006-10-20 08:35:35 UTC (rev 10634)
@@ -15,7 +15,7 @@
## JNDI Datasource
#hibernate.connection.datasource jdbc/test
-#hibernate.connection.username db2
+##hibernate.connection.username db2
#hibernate.connection.password db2
@@ -40,7 +40,7 @@
#hibernate.connection.url jdbc:hsqldb:hsql://localhost
hibernate.connection.url jdbc:hsqldb:testdb/hsqldb;shutdown=true
#hibernate.connection.url jdbc:hsqldb:.
-#hibernate.connection.shutdown=true
+hibernate.connection.shutdown=true
## Derby
@@ -68,7 +68,7 @@
#hibernate.dialect org.hibernate.dialect.OracleDialect
#hibernate.dialect org.hibernate.dialect.Oracle9Dialect
#hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
-#hibernate.connection.url jdbc:oracle:thin:@localhost:1522:XE
+#hibernate.connection.url jdbc:oracle:thin:@localhost:1521:XE
## PostgreSQL
@@ -315,7 +315,7 @@
## specify a default schema and catalog for unqualified tablenames
-hibernate.default_schema PUBLIC
+#hibernate.default_schema PUBLIC
#hibernate.default_catalog PUBLIC
@@ -406,7 +406,7 @@
## choose a cache implementation
-#hibernate.cache.provider_class org.hibernate.cache.EhCacheProvider
+hibernate.cache.provider_class org.hibernate.cache.EhCacheProvider
#hibernate.cache.provider_class org.hibernate.cache.EmptyCacheProvider
#hibernate.cache.provider_class org.hibernate.cache.HashtableCacheProvider
#hibernate.cache.provider_class org.hibernate.cache.TreeCacheProvider
Modified: branches/Branch_3_2/HibernateExt/tools/etc/log4j.properties
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/etc/log4j.properties 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/etc/log4j.properties 2006-10-20 08:35:35 UTC (rev 10634)
@@ -14,18 +14,19 @@
log4j.rootLogger=info, stdout
-log4j.logger.org.hibernate=warn
+log4j.logger.org.hibernate=info
log4j.logger.org.hibernate.cfg.reveng=debug
log4j.logger.org.hibernate.cfg.JDBCMetaDataConfiguration=debug
+#log4j.logger.freemarker=debug
### log just the SQL
-log4j.logger.org.hibernate.SQL=debug
+#log4j.logger.org.hibernate.SQL=debug
### log JDBC bind parameters ###
-log4j.logger.org.hibernate.type=info
+#log4j.logger.org.hibernate.type=info
### log schema export/update ###
-log4j.logger.org.hibernate.tool.hbm2ddl=debug
+#log4j.logger.org.hibernate.tool.hbm2ddl=debug
### log cache activity ###
#log4j.logger.org.hibernate.cache=debug
@@ -37,6 +38,6 @@
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace
-log4j.logger.org.hibernate.tool=debug
-log4j.logger.org.hibernate.tool.hbm2x.TemplateHelper=info
+#log4j.logger.org.hibernate.tool=debug
+#log4j.logger.org.hibernate.tool.hbm2x.TemplateHelper=info
#log4j.logger.org.apache.velocity=off
\ No newline at end of file
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideRepository.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideRepository.java 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/OverrideRepository.java 2006-10-20 08:35:35 UTC (rev 10634)
@@ -217,9 +217,11 @@
}
public boolean equals(Object obj) {
+ if(obj==null) return false;
+ if(!(obj instanceof TypeMappingKey)) return false;
TypeMappingKey other = (TypeMappingKey) obj;
- if(obj==null) return false;
+
return type==other.type && length==other.length;
}
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-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/ant/HibernateToolTask.java 2006-10-20 08:35:35 UTC (rev 10634)
@@ -75,38 +75,42 @@
public ExporterTask createHbm2DDL() {
ExporterTask generator = new Hbm2DDLExporterTask(this);
- generators.add(generator);
+ addGenerator( generator );
return generator;
}
public ExporterTask createHbmTemplate() {
ExporterTask generator = new GenericExporterTask(this);
- generators.add(generator);
+ addGenerator( generator );
return generator;
}
public ExporterTask createHbm2CfgXml() {
ExporterTask generator = new Hbm2CfgXmlExporterTask(this);
- generators.add(generator);
+ addGenerator( generator );
return generator;
}
+
+ protected boolean addGenerator(ExporterTask generator) {
+ return generators.add(generator);
+ }
public ExporterTask createHbm2Java() {
ExporterTask generator = new Hbm2JavaExporterTask(this);
- generators.add(generator);
+ addGenerator( generator );
return generator;
}
public ExporterTask createHbm2HbmXml() {
ExporterTask generator= new Hbm2HbmXmlExporterTask(this);
- generators.add(generator);
+ addGenerator( generator );
return generator;
}
public ExporterTask createHbm2Doc() {
ExporterTask generator= new Hbm2DocExporterTask(this);
- generators.add(generator);
+ addGenerator( generator );
return generator;
}
@@ -118,7 +122,7 @@
public ExporterTask createHbm2DAO(){
ExporterTask generator= new Hbm2DAOExporterTask(this);
- generators.add(generator);
+ addGenerator( generator );
return generator;
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/JDBCMetaDataBinderTestCase.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/JDBCMetaDataBinderTestCase.java 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/JDBCMetaDataBinderTestCase.java 2006-10-20 08:35:35 UTC (rev 10634)
@@ -76,6 +76,7 @@
return; // don't do anything to avoid crippled db
}
+ Statement statement = null;
Connection con = null;
try {
@@ -85,10 +86,11 @@
storesLowerCaseIdentifiers = metaData.storesLowerCaseIdentifiers();
storesUpperCaseIdentifiers = metaData.storesUpperCaseIdentifiers();
- Statement statement = con.createStatement();
+ statement = con.createStatement();
+
for (int i = 0; i < sqls.length; i++) {
String ddlsql = sqls[i];
System.out.println("Execute: " + ddlsql);
@@ -104,10 +106,11 @@
}
}
}
- if (statement!=null) statement.close();
con.commit();
} finally {
+ if (statement!=null) statement.close();
testSettings.getConnectionProvider().closeConnection(con);
+
}
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/DocExporterTest.java 2006-10-20 08:35:35 UTC (rev 10634)
@@ -36,7 +36,7 @@
}
protected void tearDown() throws Exception {
- //super.tearDown();
+ super.tearDown();
}
public void testExporter() {
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-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/GenericExporterTest.java 2006-10-20 08:35:35 UTC (rev 10634)
@@ -107,8 +107,10 @@
ge.setOutputDirectory(getOutputDir());
Properties p = new Properties();
p.setProperty("proptest", "A value");
+ p.setProperty( "refproperty", "proptest=${proptest}" );
p.setProperty("hibernatetool.booleanProperty", "true");
p.setProperty("hibernatetool.myTool.toolclass", "org.hibernate.tool.hbm2x.Cfg2JavaTool");
+
ge.setProperties(p);
ge.setTemplateName("generictemplates/pojo/generic-class.ftl");
ge.setFilePattern("{package-name}/generic{class-name}.txt");
@@ -121,6 +123,8 @@
assertEquals(generated.getProperty("hibernatetool.booleanProperty"), "true");
assertNull(generated.getProperty("booleanWasTrue"));
assertEquals(generated.getProperty("myTool.value"), "value");
+ assertEquals(generated.getProperty("refproperty"), "proptest=A value");
+
}
protected String getBaseForMappings() {
Copied: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint (from rev 10633, trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint)
Deleted: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenLazy.hbm.xml
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenLazy.hbm.xml 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenLazy.hbm.xml 2006-10-20 08:35:35 UTC (rev 10634)
@@ -1,32 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping package="org.hibernate.tool.hbmlint">
-
- <!-- category has caching for collection but its target is not cached -->
- <class name="BrokenLazy" lazy="true">
-
- <id name="id" type="long">
- <generator class="native"/>
- </id>
-
- </class>
-
- <class name="BrokenNonLazy" lazy="false">
- <id name="id" type="long">
- <generator class="native" />
- </id>
-
- </class>
-
- <class name="FakeNonLazy" lazy="false">
- <id name="id" type="long">
- <generator class="native" />
- </id>
-
- </class>
-
-
-</hibernate-mapping>
Copied: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenLazy.hbm.xml (from rev 10633, trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenLazy.hbm.xml)
Deleted: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenLazy.java
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenLazy.java 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenLazy.java 2006-10-20 08:35:35 UTC (rev 10634)
@@ -1,11 +0,0 @@
-package org.hibernate.tool.hbmlint;
-
-public class BrokenLazy {
-
- long id;
-
- public BrokenLazy(long id) {
- this.id = id;
- }
-}
-
Copied: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenLazy.java (from rev 10633, trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenLazy.java)
Deleted: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenNonLazy.java
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenNonLazy.java 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenNonLazy.java 2006-10-20 08:35:35 UTC (rev 10634)
@@ -1,11 +0,0 @@
-package org.hibernate.tool.hbmlint;
-
-public class BrokenNonLazy {
-
- long id;
-
- public BrokenNonLazy(long id) {
- this.id = id;
- }
-}
-
Copied: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenNonLazy.java (from rev 10633, trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/BrokenNonLazy.java)
Deleted: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/CachingSettings.hbm.xml
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/CachingSettings.hbm.xml 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/CachingSettings.hbm.xml 2006-10-20 08:35:35 UTC (rev 10634)
@@ -1,29 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping package="org.hibernate.tool.hbmlint">
-
- <!-- category has caching for collection but its target is not cached -->
- <class name="Category">
-
- <id name="id" type="long">
- <generator class="native"/>
- </id>
-
- <set name="childCategories">
- <cache usage="read-only"/>
- <key column="PARENT_ID"/>
- <one-to-many class="Category"/>
- </set>
-
- </class>
-
- <class name="NoTable">
- <id name="id" type="long">
- <generator class="native"/>
- </id>
-
- </class>
-</hibernate-mapping>
Copied: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/CachingSettings.hbm.xml (from rev 10633, trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/CachingSettings.hbm.xml)
Deleted: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/FakeNonLazy.java
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/FakeNonLazy.java 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/FakeNonLazy.java 2006-10-20 08:35:35 UTC (rev 10634)
@@ -1,37 +0,0 @@
-package org.hibernate.tool.hbmlint;
-
-import org.hibernate.bytecode.javassist.FieldHandled;
-import org.hibernate.bytecode.javassist.FieldHandler;
-
-import net.sf.cglib.transform.impl.InterceptFieldCallback;
-import net.sf.cglib.transform.impl.InterceptFieldEnabled;
-
-public class FakeNonLazy implements InterceptFieldEnabled, FieldHandled {
-
- long id;
-
- public FakeNonLazy(long id) {
- this.id = id;
- }
-
- public InterceptFieldCallback getInterceptFieldCallback() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void setInterceptFieldCallback(InterceptFieldCallback callback) {
- // TODO Auto-generated method stub
-
- }
-
- public FieldHandler getFieldHandler() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void setFieldHandler(FieldHandler handler) {
- // TODO Auto-generated method stub
-
- }
-}
-
Copied: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/FakeNonLazy.java (from rev 10633, trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/FakeNonLazy.java)
Deleted: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/HbmLintAllTests.java
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/HbmLintAllTests.java 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/HbmLintAllTests.java 2006-10-20 08:35:35 UTC (rev 10634)
@@ -1,17 +0,0 @@
-package org.hibernate.tool.hbmlint;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class HbmLintAllTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite( "Test for org.hibernate.tool.hbmlint" );
- //$JUnit-BEGIN$
- suite.addTestSuite( HbmLintTest.class );
- suite.addTestSuite( SchemaAnalyzerTest.class );
- //$JUnit-END$
- return suite;
- }
-
-}
Copied: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/HbmLintAllTests.java (from rev 10633, trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/HbmLintAllTests.java)
Deleted: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/HbmLintTest.java
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/HbmLintTest.java 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/HbmLintTest.java 2006-10-20 08:35:35 UTC (rev 10634)
@@ -1,94 +0,0 @@
-package org.hibernate.tool.hbmlint;
-
-import java.util.List;
-
-import org.hibernate.cfg.Configuration;
-import org.hibernate.tool.JDBCMetaDataBinderTestCase;
-import org.hibernate.tool.hbm2x.HbmLintExporter;
-import org.hibernate.tool.hbmlint.detector.BadCachingDetector;
-import org.hibernate.tool.hbmlint.detector.InstrumentationDetector;
-import org.hibernate.tool.hbmlint.detector.ShadowedIdentifierDetector;
-
-public class HbmLintTest extends JDBCMetaDataBinderTestCase {
-
- public HbmLintTest() {
- super();
- }
-
- protected String[] getMappings() {
- return new String[] { "hbmlint/CachingSettings.hbm.xml", "hbmlint/IdentifierIssues.hbm.xml", "hbmlint/BrokenLazy.hbm.xml" };
- }
-
- public void testExporter() {
-
- Configuration cfg = new Configuration();
- addMappings( getMappings(), cfg );
- cfg.buildMappings();
-
- new HbmLintExporter(cfg, getOutputDir()).start();
-
- }
- public void testValidateCache() {
-
- Configuration cfg = new Configuration();
- addMappings( getMappings(), cfg );
- cfg.buildMappings();
-
- HbmLint analyzer = new HbmLint(new Detector[] { new BadCachingDetector() });
-
- analyzer.analyze(cfg);
-
- List result = analyzer.getResults();
-
- assertEquals(1,result.size());
-
- System.out.println(result);
-
- }
-
- public void testValidateIdentifier() {
-
- Configuration cfg = new Configuration();
- addMappings( getMappings(), cfg );
- cfg.buildMappings();
-
- HbmLint analyzer = new HbmLint(new Detector[] { new ShadowedIdentifierDetector() });
-
- analyzer.analyze(cfg);
-
- List result = analyzer.getResults();
-
- assertEquals(1,result.size());
-
- System.out.println(result);
-
- }
-
- public void testBytecodeRestrictions() {
-
- Configuration cfg = new Configuration();
- addMappings( getMappings(), cfg );
- cfg.buildMappings();
-
- HbmLint analyzer = new HbmLint(new Detector[] { new InstrumentationDetector() });
-
- analyzer.analyze(cfg);
-
- List result = analyzer.getResults();
-
- assertEquals(2,result.size());
-
- System.out.println(result);
-
- }
-
- protected String[] getCreateSQL() {
- return new String[0];// { "create table Category (id numeric(5), parent_id numeric(5))" };
- }
-
- protected String[] getDropSQL() {
- return new String[0];// { "drop table Category" };
- }
-
-
-}
Copied: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/HbmLintTest.java (from rev 10633, trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/HbmLintTest.java)
Deleted: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/IdentifierIssues.hbm.xml
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/IdentifierIssues.hbm.xml 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/IdentifierIssues.hbm.xml 2006-10-20 08:35:35 UTC (rev 10634)
@@ -1,19 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping package="org.hibernate.tool.hbmlint">
-
- <!-- category has caching for collection but its target is not cached -->
- <class name="IdentifierProblem">
-
- <id name="name" type="long">
- <generator class="native"/>
- </id>
-
- <property name="id" type="string"/>
-
- </class>
-
-</hibernate-mapping>
Copied: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/IdentifierIssues.hbm.xml (from rev 10633, trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/IdentifierIssues.hbm.xml)
Deleted: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/SchemaAnalyzerTest.java
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/SchemaAnalyzerTest.java 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/SchemaAnalyzerTest.java 2006-10-20 08:35:35 UTC (rev 10634)
@@ -1,100 +0,0 @@
-package org.hibernate.tool.hbmlint;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.hibernate.cfg.Configuration;
-import org.hibernate.mapping.Table;
-import org.hibernate.tool.JDBCMetaDataBinderTestCase;
-import org.hibernate.tool.hbm2x.HbmLintExporter;
-import org.hibernate.tool.hbmlint.detector.SchemaByMetaDataDetector;
-
-public class SchemaAnalyzerTest extends JDBCMetaDataBinderTestCase {
-
- public SchemaAnalyzerTest() {
- super();
- }
-
- protected String[] getMappings() {
- return new String[] { "hbmlint/SchemaIssues.hbm.xml" };
- }
-
- static class MockCollector implements IssueCollector {
- List problems = new ArrayList();
-
- public void reportIssue(Issue analyze) {
-
- problems.add(analyze);
- }
- }
-
- public void testSchemaAnalyzer() {
- Configuration cfg = new Configuration();
- addMappings( getMappings(), cfg );
- cfg.buildMappings();
-
- SchemaByMetaDataDetector analyzer = new SchemaByMetaDataDetector();
- analyzer.initialize( cfg, cfg.buildSettings() );
-
- Iterator tableMappings = cfg.getTableMappings();
-
-
- while ( tableMappings.hasNext() ) {
- Table table = (Table) tableMappings.next();
-
- MockCollector mc = new MockCollector();
-
- if(table.getName().equalsIgnoreCase( "missingtable" )) {
- analyzer.visit( cfg, table, mc );
- assertEquals(mc.problems.size(),1);
- Issue ap = (Issue) mc.problems.get( 0 );
- assertTrue(ap.getDescription().indexOf( "Missing table" ) >=0);
- } else if(table.getName().equalsIgnoreCase( "category" )) {
- analyzer.visit( cfg, table, mc );
- assertEquals(mc.problems.size(),1);
- Issue ap = (Issue) mc.problems.get( 0 );
- assertTrue(ap.getDescription().indexOf( "missing column: name" ) >=0);
- } else if(table.getName().equalsIgnoreCase( "badtype" )) {
- analyzer.visit( cfg, table, mc );
- assertEquals(mc.problems.size(),1);
- Issue ap = (Issue) mc.problems.get( 0 );
- assertTrue(ap.getDescription().indexOf( "wrong column type for name" ) >=0);
- } else {
- fail("Unkown table " + table);
- }
- }
-
- MockCollector mc = new MockCollector();
- analyzer.visitGenerators( cfg, mc );
- assertEquals(1,mc.problems.size());
- Issue issue = (Issue) mc.problems.get( 0 );
- assertTrue(issue.getDescription().indexOf( "hibernate_unique_key" ) >=0);
-
- }
-
-
-
- public void testExporter() {
-
- Configuration cfg = new Configuration();
- addMappings( getMappings(), cfg );
- cfg.buildMappings();
-
- new HbmLintExporter(cfg, getOutputDir()).start();
-
- }
-
- protected String[] getCreateSQL() {
- return new String[] { "create table Category (id int, parent_id numeric(5))",
- "create table BadType (id int, name varchar(100))",
- "create sequence should_be_there start with 1",
- "create table hilo_table (id int)"};
- }
-
- protected String[] getDropSQL() {
- return new String[] { "drop table Category", "drop table BadType", "drop sequence should_be_there", "drop table hilo_table" };
- }
-
-
-}
Copied: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/SchemaAnalyzerTest.java (from rev 10633, trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/SchemaAnalyzerTest.java)
Deleted: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/SchemaIssues.hbm.xml
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/SchemaIssues.hbm.xml 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/SchemaIssues.hbm.xml 2006-10-20 08:35:35 UTC (rev 10634)
@@ -1,37 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping package="org.hibernate.tool.hbmlint">
-
- <class name="Category">
-
- <id name="id" type="int">
- <generator class="sequence">
- <param name="sequence">should_be_there</param>
- </generator>
- </id>
-
- <property name="name" type="string"/>
-
- </class>
-
- <class name="BadType">
-
- <id name="id" type="int">
- <generator class="hilo"/>
- </id>
-
- <property name="name" type="text"/>
-
- </class>
-
- <class name="MissingTable">
- <id name="id" type="long">
- <generator class="hilo">
- <param name="table">hilo_table</param>
- </generator>
- </id>
- </class>
-</hibernate-mapping>
Copied: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/SchemaIssues.hbm.xml (from rev 10633, trunk/HibernateExt/tools/src/test/org/hibernate/tool/hbmlint/SchemaIssues.hbm.xml)
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/DriverMetaDataTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/DriverMetaDataTest.java 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/DriverMetaDataTest.java 2006-10-20 08:35:35 UTC (rev 10634)
@@ -86,8 +86,23 @@
System.out.println(map);
}
+ }
+
+ public void testCaseTest() {
-
+
+ MetaDataDialect dialect = new JDBCMetaDataDialect();
+
+ Settings settings = cfg.buildSettings();
+
+ dialect.configure( settings.getConnectionProvider(), settings.getSQLExceptionConverter() );
+
+ Iterator tables = dialect.getTables( settings.getDefaultCatalogName(), settings.getDefaultSchemaName(), identifier( "TAB_MASTER"));
+
+ assertHasNext( 1, tables );
+
+
+
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/CompositeIdTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/CompositeIdTest.java 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/CompositeIdTest.java 2006-10-20 08:35:35 UTC (rev 10634)
@@ -265,8 +265,10 @@
}
assertFalse("hashcode should be different from system", hash==System.identityHashCode(object));
+ factory.close();
Thread.currentThread().setContextClassLoader(ucl.getParent() );
+
TestHelper.deleteDir(outputdir);
}
protected String getCustomerOrderQuery() {
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/PersistentClassesTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/PersistentClassesTest.java 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/PersistentClassesTest.java 2006-10-20 08:35:35 UTC (rev 10634)
@@ -169,6 +169,7 @@
assertFalse(Hibernate.isInitialized(order.getItemsForOrderId() ) );
t.commit();
session.close();
+ sf.close();
}
/**
Copied: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/newformat.reveng (from rev 10633, trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/newformat.reveng)
Modified: branches/Branch_3_2/HibernateExt/tools/src/testsupport/generictemplates/pojo/generic-class.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/testsupport/generictemplates/pojo/generic-class.ftl 2006-10-19 17:38:50 UTC (rev 10633)
+++ branches/Branch_3_2/HibernateExt/tools/src/testsupport/generictemplates/pojo/generic-class.ftl 2006-10-20 08:35:35 UTC (rev 10634)
@@ -6,3 +6,7 @@
booleanProperty=${booleanProperty?if_exists?string}
<#if booleanProperty?exists && !booleanProperty>booleanWasTrue=true</#if>
myTool.value=<#if myTool?exists>${myTool.unqualify("myTool.value")}</#if>
+<#if refproperty?exists>
+<#assign inline= refproperty?interpret>
+refproperty=<@inline/>
+</#if>
18 years, 1 month
Hibernate SVN: r10633 - trunk/HibernateExt/tools/etc
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-10-19 13:38:50 -0400 (Thu, 19 Oct 2006)
New Revision: 10633
Modified:
trunk/HibernateExt/tools/etc/hibernate.properties
Log:
Modified: trunk/HibernateExt/tools/etc/hibernate.properties
===================================================================
--- trunk/HibernateExt/tools/etc/hibernate.properties 2006-10-19 17:37:34 UTC (rev 10632)
+++ trunk/HibernateExt/tools/etc/hibernate.properties 2006-10-19 17:38:50 UTC (rev 10633)
@@ -15,7 +15,7 @@
## JNDI Datasource
#hibernate.connection.datasource jdbc/test
-#hibernate.connection.username db2
+##hibernate.connection.username db2
#hibernate.connection.password db2
@@ -40,7 +40,7 @@
#hibernate.connection.url jdbc:hsqldb:hsql://localhost
hibernate.connection.url jdbc:hsqldb:testdb/hsqldb;shutdown=true
#hibernate.connection.url jdbc:hsqldb:.
-#hibernate.connection.shutdown=true
+hibernate.connection.shutdown=true
## Derby
@@ -68,7 +68,7 @@
#hibernate.dialect org.hibernate.dialect.OracleDialect
#hibernate.dialect org.hibernate.dialect.Oracle9Dialect
#hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
-#hibernate.connection.url jdbc:oracle:thin:@localhost:1522:XE
+#hibernate.connection.url jdbc:oracle:thin:@localhost:1521:XE
## PostgreSQL
@@ -315,7 +315,7 @@
## specify a default schema and catalog for unqualified tablenames
-hibernate.default_schema PUBLIC
+#hibernate.default_schema PUBLIC
#hibernate.default_catalog PUBLIC
@@ -406,7 +406,7 @@
## choose a cache implementation
-#hibernate.cache.provider_class org.hibernate.cache.EhCacheProvider
+hibernate.cache.provider_class org.hibernate.cache.EhCacheProvider
#hibernate.cache.provider_class org.hibernate.cache.EmptyCacheProvider
#hibernate.cache.provider_class org.hibernate.cache.HashtableCacheProvider
#hibernate.cache.provider_class org.hibernate.cache.TreeCacheProvider
18 years, 1 month
Hibernate SVN: r10632 - trunk/HibernateExt/tools/etc
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-10-19 13:37:34 -0400 (Thu, 19 Oct 2006)
New Revision: 10632
Modified:
trunk/HibernateExt/tools/etc/log4j.properties
Log:
Modified: trunk/HibernateExt/tools/etc/log4j.properties
===================================================================
--- trunk/HibernateExt/tools/etc/log4j.properties 2006-10-19 17:36:49 UTC (rev 10631)
+++ trunk/HibernateExt/tools/etc/log4j.properties 2006-10-19 17:37:34 UTC (rev 10632)
@@ -14,18 +14,19 @@
log4j.rootLogger=info, stdout
-log4j.logger.org.hibernate=warn
+log4j.logger.org.hibernate=info
log4j.logger.org.hibernate.cfg.reveng=debug
log4j.logger.org.hibernate.cfg.JDBCMetaDataConfiguration=debug
+#log4j.logger.freemarker=debug
### log just the SQL
-log4j.logger.org.hibernate.SQL=debug
+#log4j.logger.org.hibernate.SQL=debug
### log JDBC bind parameters ###
-log4j.logger.org.hibernate.type=info
+#log4j.logger.org.hibernate.type=info
### log schema export/update ###
-log4j.logger.org.hibernate.tool.hbm2ddl=debug
+#log4j.logger.org.hibernate.tool.hbm2ddl=debug
### log cache activity ###
#log4j.logger.org.hibernate.cache=debug
@@ -37,6 +38,6 @@
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace
-log4j.logger.org.hibernate.tool=debug
-log4j.logger.org.hibernate.tool.hbm2x.TemplateHelper=info
+#log4j.logger.org.hibernate.tool=debug
+#log4j.logger.org.hibernate.tool.hbm2x.TemplateHelper=info
#log4j.logger.org.apache.velocity=off
\ No newline at end of file
18 years, 1 month
Hibernate SVN: r10631 - trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-10-19 13:36:49 -0400 (Thu, 19 Oct 2006)
New Revision: 10631
Added:
trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/newformat.reveng
Log:
future example to not forget
Added: trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/newformat.reveng
===================================================================
--- trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/newformat.reveng 2006-10-19 17:14:49 UTC (rev 10630)
+++ trunk/HibernateExt/tools/src/test/org/hibernate/tool/test/jdbc2cfg/newformat.reveng 2006-10-19 17:36:49 UTC (rev 10631)
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-reverse-engineering SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
+
+<hibernate-reverse-engineering> <!-- case-match="exact|upper|lower" -->
+
+ <!-- .* is valid, will be translated into % -->
+ <schema-selection match-catalog="PUBLIC.*" match-schema="OVRTEST" match-table=".*"/>
+
+ <type-mapping>
+ <sql-type jdbc-type="VARCHAR" length='20'> <!-- should have a native-type -->
+ <!-- <hibernate-type name="SomeUserType"><param></param></hibernate-type> -->
+ </sql-type>
+ </type-mapping>
+
+ <!-- <entity package="org.werd"/> -->
+ <table-filter match-schema=".*" match-name="TBL_.*"/>
+
+
+ <table-filter match-name="DEFUNCT_TABLE" exclude="true" />
+ <table-filter match-name="DoNotWantIt" exclude="true" />
+ <table-filter match-name="WantedTable" />
+ <table-filter match-catalog="BAD" match-schema="SCHEMA"
+ match-name=".*" exclude="true" />
+
+ <table-filter match-catalog=".*" match-schema=".*"
+ match-name="BIN$.*" exclude="true" />
+
+ <table-filter match-name=".*" exclude="false"/>
+ <!--
+ <table name="CUSTOMER" package="org.funk" class-name="MyCustomer">
+ <column name="order" property-name="orderName" />
+ </table>
+
+ <table name="CUSTOMER">
+ <column name="ORDER" />
+ </table>
+
+ <table catalog="CUSTOMER" schema="WHATEVER" name="ORDER">
+ <column name="name" exclude="true">
+ <meta attribute="property-name">Name</meta>
+ </column>
+ </table>
+ -->
+
+<!-- hack for disable many-to-many
+ <table name="CategoryItem">
+ <foreign-key constraint-name="CAT_FK" foreign-table="CATEGORY" >
+ <column-ref local-column="catid" foreign-column="id" />
+ <many-to-one name="dfdf"/>
+ </foreign-key>
+ </table>
+-->
+ <!--
+ alter table Customer add constraint 'max' foreign key (addressid, x) references address (dfdf)
+
+ default_schema PUBLIC
+ -->
+ <table name="ORDERS" class="Order">
+ <primary-key property="id" id-class="OrderId">
+ <generator class="sequence">
+ <param name="table">seq_table</param>
+ </generator>
+ <key-column name="CUSTID1" property="val1" type="string"/> <!-- no exclude -->
+ <key-column name="CUSTID2" />
+ <key-column name="CUSTID3" />
+ </primary-key>
+
+ <column name="generated" exclude="true" property="price"/>
+<!--
+ <for-columns exclude="false" property="price" type="MonetaryAmount">
+ <column name="PRICE"/>
+ <column name="CURRENCY"/>
+ </for-columns>
+ -->
+ <!-- if constraint-name exist in db, use it! ignore foreign-x -->
+ <foreign-key constraint-name="SYS_CP20" foreign-table="PARENT" >
+ <column-ref local-column="parentid" foreign-column="id" />
+ <column-ref local-column="extraparentid" foreign-column="extraid" />
+ <many-to-one property="order"/>
+ <set property="orders"/>
+ </foreign-key>
+
+
+ <foreign-key constraint-name="SYS_CP20" foreign-table="PARENT" >
+ <column-ref local-column="parentid" foreign-column="id" />
+ <column-ref local-column="extraparentid" foreign-column="extraid" />
+ <many-to-one property="order"/>
+ <!-- <map name="orders">
+ <map-key column="xxx"/>
+ </map> -->
+ </foreign-key>
+
+ <foreign-key foreign-table="PARENT">
+ <column-ref local-column="parentid" foreign-column="id" />
+ <column-ref local-column="extraparentid" foreign-column="extraid" />
+ </foreign-key>
+
+
+
+
+
+
+ </table>
+
+
+ <table name="CHILDREN">
+ <foreign-key foreign-table="PARENT">
+ <column-ref local-column="parentid" foreign-column="id" />
+ <column-ref local-column="extraparentid"
+ foreign-column="extraid" />
+ </foreign-key>
+ </table>
+
+ <table name="EXCOLUMNS">
+ <column name="EXCOLUMN" exclude="true"/>
+ </table>
+
+ <table name="TblTest" class="org.test.Test"/>
+
+
+</hibernate-reverse-engineering>
\ No newline at end of file
18 years, 1 month