You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(22) |
Nov
(308) |
Dec
(131) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(369) |
Feb
(171) |
Mar
(236) |
Apr
(187) |
May
(218) |
Jun
(217) |
Jul
(127) |
Aug
(448) |
Sep
(270) |
Oct
(231) |
Nov
(422) |
Dec
(255) |
2004 |
Jan
(111) |
Feb
(73) |
Mar
(338) |
Apr
(351) |
May
(349) |
Jun
(495) |
Jul
(394) |
Aug
(1048) |
Sep
(499) |
Oct
(142) |
Nov
(269) |
Dec
(638) |
2005 |
Jan
(825) |
Feb
(1272) |
Mar
(593) |
Apr
(690) |
May
(950) |
Jun
(958) |
Jul
(767) |
Aug
(839) |
Sep
(525) |
Oct
(449) |
Nov
(585) |
Dec
(455) |
2006 |
Jan
(603) |
Feb
(656) |
Mar
(195) |
Apr
(114) |
May
(136) |
Jun
(100) |
Jul
(128) |
Aug
(68) |
Sep
(7) |
Oct
(1) |
Nov
(1) |
Dec
(8) |
2007 |
Jan
(4) |
Feb
(3) |
Mar
(8) |
Apr
(16) |
May
(5) |
Jun
(4) |
Jul
(6) |
Aug
(23) |
Sep
(15) |
Oct
(5) |
Nov
(7) |
Dec
(5) |
2008 |
Jan
(5) |
Feb
(1) |
Mar
(1) |
Apr
(5) |
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
(1) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(3) |
Dec
(2) |
2013 |
Jan
(1) |
Feb
|
Mar
(2) |
Apr
(1) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(2) |
Jun
(1) |
Jul
|
Aug
(1) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <one...@us...> - 2002-12-30 12:48:55
|
Update of /cvsroot/hibernate/Hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv30673 Modified Files: build.xml changelog.txt Log Message: fixed JDK1.2 compile brob Index: build.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate/build.xml,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** build.xml 30 Dec 2002 10:58:15 -0000 1.32 --- build.xml 30 Dec 2002 12:48:51 -0000 1.33 *************** *** 211,215 **** </target> ! <target name="dist" depends="jar,javadoc,copysource,copylib,aft,extras" description="Build everything"> <zip zipfile = "${dist.dir}.zip"> <zipfileset prefix="${name}-${version}" dir="${dist.dir}"/> --- 211,215 ---- </target> ! <target name="dist" depends="jar,javadoc,copysource,copylib,extras" description="Build everything"> <zip zipfile = "${dist.dir}.zip"> <zipfileset prefix="${name}-${version}" dir="${dist.dir}"/> Index: changelog.txt =================================================================== RCS file: /cvsroot/hibernate/Hibernate/changelog.txt,v retrieving revision 1.291 retrieving revision 1.292 diff -C2 -d -r1.291 -r1.292 *** changelog.txt 28 Dec 2002 02:25:47 -0000 1.291 --- changelog.txt 30 Dec 2002 12:48:51 -0000 1.292 *************** *** 23,26 **** --- 23,29 ---- * setMaxResults() now behaves sensibly on SAPDB (Russel Smyth) * added Query.setProperties() and Query.getNamedParameters(), fixed a bug in Query.getReturnTypes() + * CodeGenerator now generates equals() and hashCode() for composite-id classes (and toString() for all classes) + * CodeGenerator now includes superclass properties in subclass constructors (Max Andersen) + * added Hibernate.custom() Changes in version 1.2 final (7.12.2002) |
From: <one...@us...> - 2002-12-30 11:55:12
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen In directory sc8-pr-cvs1:/tmp/cvs-serv32208 Modified Files: ClassMapping.java Log Message: entities implement pk equality Index: ClassMapping.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen/ClassMapping.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ClassMapping.java 30 Dec 2002 11:32:49 -0000 1.22 --- ClassMapping.java 30 Dec 2002 11:55:09 -0000 1.23 *************** *** 87,101 **** Element id = classElement.getChild("id"); ! if (id != null) propertyList.add(0, id); ! // ! // composite id Element cmpid = classElement.getChild("composite-id"); if (cmpid != null) { String cmpname = cmpid.getAttributeValue("name"); String cmpclass = cmpid.getAttributeValue("class"); if ( cmpclass==null || cmpclass.equals("") ) { //Embedded composite id ! implementEquals(); propertyList.addAll(0, cmpid.getChildren("key-property") ); manyToOneList.addAll(0, cmpid.getChildren("key-many-to-one") ); --- 87,104 ---- Element id = classElement.getChild("id"); ! if (id != null) { ! propertyList.add(0, id); ! implementEquals(); ! } + // composite id Element cmpid = classElement.getChild("composite-id"); if (cmpid != null) { + implementEquals(); String cmpname = cmpid.getAttributeValue("name"); String cmpclass = cmpid.getAttributeValue("class"); if ( cmpclass==null || cmpclass.equals("") ) { //Embedded composite id ! //implementEquals(); propertyList.addAll(0, cmpid.getChildren("key-property") ); manyToOneList.addAll(0, cmpid.getChildren("key-many-to-one") ); |
From: <one...@us...> - 2002-12-30 11:34:30
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv22021/hibernate Modified Files: Hibernate.java Log Message: added Hibernate.custom() Index: Hibernate.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/Hibernate.java,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** Hibernate.java 25 Dec 2002 02:00:14 -0000 1.65 --- Hibernate.java 30 Dec 2002 11:34:27 -0000 1.66 *************** *** 153,160 **** --- 153,168 ---- /** * A Hibernate persistent object (entity) type + * @param persistentClass a mapped entity class */ public static Type association(Class persistentClass) { // not really a many-to-one association *necessarily* return new ManyToOneType(persistentClass); + } + /** + * A Hibernate custom type + * @param userTypeClass a class that implements <tt>UserType</tt> + */ + public static Type custom(Class userTypeClass) throws HibernateException { + return new CustomType(userTypeClass); } /** |
From: <one...@us...> - 2002-12-30 11:32:53
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen In directory sc8-pr-cvs1:/tmp/cvs-serv21178 Modified Files: BasicRenderer.java ClassMapping.java ClassName.java Field.java Log Message: integrated Max Andersen's patch to fix subclass constructors improved generated comments Index: BasicRenderer.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen/BasicRenderer.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** BasicRenderer.java 29 Dec 2002 01:30:55 -0000 1.14 --- BasicRenderer.java 30 Dec 2002 11:32:49 -0000 1.15 *************** *** 4,8 **** --- 4,10 ---- import java.io.PrintWriter; import java.util.Iterator; + import java.util.List; import java.util.Map; + import java.util.TreeSet; public class BasicRenderer implements Renderer { *************** *** 17,21 **** */ String getTrueTypeName(Field field, Map class2classmap) { ! String name=field.getClassType()!=null?field.getClassType().getFullyQualifiedName():field.getType(); ClassMapping cmap = (ClassMapping) class2classmap.get(name); --- 19,25 ---- */ String getTrueTypeName(Field field, Map class2classmap) { ! String name = ( field.getClassType()!=null ) ? ! field.getClassType().getFullyQualifiedName(): ! field.getType(); ClassMapping cmap = (ClassMapping) class2classmap.get(name); *************** *** 32,36 **** } else { ! writer.println("//warning: default package"); } writer.println(); --- 36,40 ---- } else { ! writer.println("// default package"); } writer.println(); *************** *** 50,58 **** // class declaration ! writer.print("public class " + classMapping.getName()); // subclass if (classMapping.getSuperClass() != null) { ! writer.print(" extends " + classMapping.getSuperClass()); } --- 54,63 ---- // class declaration ! writer.println("/** @author Hibernate CodeGenerator */"); ! writer.print( "public class " + classMapping.getName() ); // subclass if (classMapping.getSuperClass() != null) { ! writer.print( " extends " + classMapping.getSuperClass() ); } *************** *** 72,102 **** // fields ! for (Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { Field field = (Field) fields.next(); ! writer.println(" private " + field.getType() + ' ' + field.getName() + ! ( field.isIdentifier() ? "; //identifier" : "; //persistent") ); } - writer.println(); // full constructor ! int fullConsArgCount = 0; String fullCons = " public " + classMapping.getName() + "("; ! for(Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { Field field = (Field) fields.next(); ! if(!field.isIdentifier() || (field.isIdentifier() && !field.isGenerated())) { ! fullCons = fullCons + field.getType() + " " + field.getName(); ! fullCons = fullCons + ", "; ! fullConsArgCount++; ! } } ! if ( fullCons.endsWith(", ") ) fullCons = fullCons.substring(0, fullCons.length()-2); ! writer.println(fullCons + ") {"); ! for(Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { ! Field field = (Field) fields.next(); ! if(!field.isIdentifier() || (field.isIdentifier() && !field.isGenerated())) { ! writer.println(" this." + field.getName() + " = " + field.getName() + ";"); } } writer.println(" }"); --- 77,131 ---- // fields ! for ( Iterator fields = classMapping.getFields().iterator(); fields.hasNext(); ) { Field field = (Field) fields.next(); ! writer.println( ! " /** " + ! ( field.isNullable() && !field.isIdentifier() ? "nullable " : "" ) + ! ( field.isIdentifier() ? "identifier" : "persistent" ) ! + " field */"); ! writer.println( ! " private " + ! shortenType( field.getType(), classMapping.getImports() ) + ! ' ' + ! field.getName() + ! ';' ); + writer.println(); } // full constructor ! List allFieldsForFullConstructor = classMapping.getAllFieldsForFullConstructor(); ! ! writer.println(" /** full constructor */"); String fullCons = " public " + classMapping.getName() + "("; ! ! ! for(Iterator fields = allFieldsForFullConstructor.iterator(); fields.hasNext();) { Field field = (Field) fields.next(); ! fullCons = fullCons + shortenType(getTrueTypeName(field, class2classmap), classMapping.getImports()) + " " + field.getName(); ! if(fields.hasNext()) { ! fullCons = fullCons + ", "; ! } } ! writer.println(fullCons + ") {"); ! //invoke super to initialize superclass... ! List supersConstructorFields = classMapping.getFieldsForSupersFullConstructor(); ! if (!supersConstructorFields.isEmpty()) { ! writer.print(" super("); ! for (Iterator fields = supersConstructorFields.iterator(); fields.hasNext();) { ! Field field = (Field) fields.next(); ! writer.print(field.getName()); ! if(fields.hasNext()) { ! writer.print(", "); ! } } + writer.println(");"); + } + + // initialisation of localfields + for(Iterator fields = classMapping.getLocalFieldsForFullConstructor().iterator(); fields.hasNext();) { + Field field = (Field) fields.next(); + writer.println(" this." + field.getName() + " = " + field.getName() + ";"); } writer.println(" }"); *************** *** 104,108 **** // no args constructor (if fullconstructor had any arguments!) ! if (fullConsArgCount > 0) { writer.println(" public " + classMapping.getName() + "() {"); writer.println(" }"); --- 133,138 ---- // no args constructor (if fullconstructor had any arguments!) ! if (allFieldsForFullConstructor.size() > 0) { ! writer.println(" /** default constructor */"); writer.println(" public " + classMapping.getName() + "() {"); writer.println(" }"); *************** *** 110,139 **** } ! // minimal constructor (only if the fullconstructor had any arguments) ! if(fullConsArgCount>0) { ! if( classMapping.needsMinimalConstructor() ) { ! String minCons = " public " + classMapping.getName() + "("; ! for(Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { ! Field field = (Field) fields.next(); ! if((!field.isIdentifier() && !field.isNullable()) || ! (field.isIdentifier() && !field.isGenerated())) { ! minCons = minCons + field.getType() + " " + field.getName(); ! minCons = minCons + ", "; ! } ! } ! if ( minCons.endsWith(", ") ) minCons = minCons.substring(0, minCons.length()-2); ! ! writer.println(minCons + ") {"); ! for(Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { ! Field field = (Field) fields.next(); ! if((!field.isIdentifier() && !field.isNullable()) || ! (field.isIdentifier() && !field.isGenerated())) { ! writer.println(" this." + field.getName() + " = " + field.getName() + ";"); ! } ! } ! writer.println(" }"); ! writer.println(); ! } } --- 140,180 ---- } ! // minimal constructor (only if the fullconstructor had any arguments) ! if ((allFieldsForFullConstructor.size() > 0) && classMapping.needsMinimalConstructor()) { ! ! List allFieldsForMinimalConstructor = classMapping.getAllFieldsForMinimalConstructor(); ! writer.println(" /** minimal constructor */"); ! String minCons = " public " + classMapping.getName() + "("; ! for (Iterator fields = allFieldsForMinimalConstructor.iterator(); fields.hasNext();) { ! Field field = (Field) fields.next(); ! minCons = minCons + shortenType(getTrueTypeName(field, class2classmap), classMapping.getImports()) + " " + field.getName(); ! if (fields.hasNext()) { ! minCons = minCons + ", "; ! } ! } ! ! writer.println(minCons + ") {"); ! // invoke super to initialize superclass... ! List supersMinConstructorFields = classMapping.getFieldsForSupersMinimalConstructor(); ! if (!supersMinConstructorFields.isEmpty()) { ! writer.print(" super("); ! for (Iterator fields = supersMinConstructorFields.iterator(); fields.hasNext();) { ! Field field = (Field) fields.next(); ! writer.print(field.getName()); ! if(fields.hasNext()) { ! writer.print(", "); ! } ! } ! writer.println(");"); ! } ! ! // initialisation of localfields ! for (Iterator fields = classMapping.getLocalFieldsForMinimalConstructor().iterator(); fields.hasNext();) { ! Field field = (Field) fields.next(); ! writer.println(" this." + field.getName() + " = " + field.getName() + ";"); ! } ! writer.println(" }"); ! writer.println(); } *************** *** 192,195 **** --- 233,258 ---- writer.println("}"); + } + /** + * Returns the last part of type if it is in the set of imports. + * e.g. java.util.Date would become Date, if imports contains + * java.util.Date. + * + * @param type + * @param imports + * @return String + */ + private String shortenType(String type, TreeSet imports) { + if( imports.contains(type) ) { + return type.substring( type.lastIndexOf('.')+1 ); + } + else { + if( type.endsWith("[]") ) { + return shortenType( type.substring(0, type.length()-2), imports ) + "[]"; + } + else { + return type; + } + } } Index: ClassMapping.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen/ClassMapping.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ClassMapping.java 29 Dec 2002 01:30:55 -0000 1.21 --- ClassMapping.java 30 Dec 2002 11:32:49 -0000 1.22 *************** *** 21,24 **** --- 21,25 ---- private ClassName name = null; private String superClass = null; + private ClassMapping superClassMapping = null; private String proxyClass = null; private List fields = new ArrayList(); *************** *** 28,31 **** --- 29,53 ---- private boolean mustImplementEquals = false; + public ClassMapping(ClassName superClass, ClassMapping superClassMapping, Element classElement) throws Exception { + this(superClass, classElement); + + this.superClassMapping = superClassMapping; + + if(this.superClassMapping!=null) { + List l = this.superClassMapping.getAllFieldsForFullConstructor(); + for (Iterator iter = l.iterator(); iter.hasNext();) { + Field element = (Field) iter.next(); + ClassName ct = element.getClassType(); + if(ct!=null) { // add imports for superclasses possible fields. + addImport(ct); + } else { + addImport(element.getType()); + } + } + + + } + } + public ClassMapping(ClassName superClass, Element classElement) throws Exception { this(classElement); *************** *** 87,91 **** // add an import and field for this property addImport(classType); ! fields.add( new Field(cmpname, classType.getName(), false, true, false) ); components.put( mapping.getCanonicalName(), mapping ); } --- 109,113 ---- // add an import and field for this property addImport(classType); ! fields.add( new Field(cmpname, classType, false, true, false) ); components.put( mapping.getCanonicalName(), mapping ); } *************** *** 178,183 **** // add an import and field for this property addImport(classType); ! Field f = new Field( name, classType.getName(), nullable && !key, key, false ); ! f.setClassType(classType); fields.add(f); } --- 200,204 ---- // add an import and field for this property addImport(classType); ! Field f = new Field( name, classType, nullable && !key, key, false ); fields.add(f); } *************** *** 192,208 **** - // subclasses - for ( Iterator iter = classElement.getChildren("subclass").iterator(); iter.hasNext(); ) { - Element subclass = (Element) iter.next(); - ClassMapping subclassMapping = new ClassMapping(name, subclass); - subclasses.add(subclassMapping); - } - - for ( Iterator iter = classElement.getChildren("joined-subclass").iterator(); iter.hasNext(); ) { - Element subclass = (Element) iter.next(); - ClassMapping subclassMapping = new ClassMapping(name, subclass); - subclasses.add(subclassMapping); - } //components --- 213,217 ---- *************** *** 222,228 **** // add an import and field for this property addImport(classType); ! fields.add( new Field(cmpname, classType.getName(), false) ); components.put( mapping.getCanonicalName(), mapping ); } } --- 231,251 ---- // add an import and field for this property addImport(classType); ! fields.add( new Field(cmpname, classType, false) ); components.put( mapping.getCanonicalName(), mapping ); } + + // subclasses (done last so they can access this superclass for info) + + for ( Iterator iter = classElement.getChildren("subclass").iterator(); iter.hasNext(); ) { + Element subclass = (Element) iter.next(); + ClassMapping subclassMapping = new ClassMapping(name, this,subclass); + subclasses.add(subclassMapping); + } + + for ( Iterator iter = classElement.getChildren("joined-subclass").iterator(); iter.hasNext(); ) { + Element subclass = (Element) iter.next(); + ClassMapping subclassMapping = new ClassMapping(name, this, subclass); + subclasses.add(subclassMapping); + } } *************** *** 294,304 **** } private void addImport(ClassName className) { // if the package is java.lang or our own package don't add ! if ( !className.inJavaLang() && !className.inSamePackage(name) ) { ! imports.add( className.getFullyQualifiedName() ); } } public static Iterator getComponents() { return components.values().iterator(); --- 317,402 ---- } + public List getLocalFieldsForFullConstructor() { + List result = new ArrayList(); + for(Iterator fields = getFields().iterator(); fields.hasNext();) { + Field field = (Field) fields.next(); + if(!field.isIdentifier() || (field.isIdentifier() && !field.isGenerated())) { + result.add(field); + } + } + + return result; + } + + public List getFieldsForSupersFullConstructor() { + List result = new ArrayList(); + if(getSuperClassMapping()!=null) { + // The correct sequence is vital here, as the subclass should be + // able to invoke the fullconstructor based on the sequence returned + // by this method! + result.addAll(getSuperClassMapping().getFieldsForSupersFullConstructor()); + result.addAll(getSuperClassMapping().getLocalFieldsForFullConstructor()); + } + + return result; + } + + public List getLocalFieldsForMinimalConstructor() { + List result = new ArrayList(); + for (Iterator fields = getFields().iterator(); fields.hasNext();) { + Field field = (Field) fields.next(); + if ((!field.isIdentifier() && !field.isNullable()) || + (field.isIdentifier() && !field.isGenerated())) { + result.add(field); + } + } + return result; + } + public List getAllFieldsForFullConstructor() { + + List result = getFieldsForSupersFullConstructor(); + result.addAll(getLocalFieldsForFullConstructor()); + return result; + } + + public List getFieldsForSupersMinimalConstructor() { + List result = new ArrayList(); + if(getSuperClassMapping()!=null) { + // The correct sequence is vital here, as the subclass should be + // able to invoke the fullconstructor based on the sequence returned + // by this method! + result.addAll(getSuperClassMapping().getFieldsForSupersMinimalConstructor()); + result.addAll(getSuperClassMapping().getLocalFieldsForMinimalConstructor()); + } + + return result; + } + + public List getAllFieldsForMinimalConstructor() { + + List result = getFieldsForSupersMinimalConstructor(); + result.addAll(getLocalFieldsForMinimalConstructor()); + return result; + } + private void addImport(ClassName className) { // if the package is java.lang or our own package don't add ! if ( !className.inJavaLang() && !className.inSamePackage(name) && !className.isPrimitive()) { ! if(className.isArray()) { ! imports.add( className.getFullyQualifiedName().substring(0,className.getFullyQualifiedName().length()-2) ); // remove [] ! } else { ! imports.add( className.getFullyQualifiedName() ); ! } } } + private void addImport(String className) { + ClassName cn = new ClassName(); + cn.setFullyQualifiedName(className); + addImport(cn); + + } + + public static Iterator getComponents() { return components.values().iterator(); *************** *** 320,326 **** // add an import and field for this collection addImport(interfaceClassName); ! addImport(implementingClassName); ! fields.add(new Field(name, interfaceClassName.getName(), "new " + implementingClassName.getName() + "()", false) ); if (collection.getChildren("composite-element") != null) { for (Iterator compositeElements = collection.getChildren("composite-element").iterator(); compositeElements.hasNext(); ) { --- 418,427 ---- // add an import and field for this collection addImport(interfaceClassName); ! // import implementingClassName should only be ! // added if the initialisaiton code of the field ! // is actually used - and currently it isn't! ! //addImport(implementingClassName); ! fields.add(new Field(name, interfaceClassName, "new " + implementingClassName.getName() + "()", false) ); if (collection.getChildren("composite-element") != null) { for (Iterator compositeElements = collection.getChildren("composite-element").iterator(); compositeElements.hasNext(); ) { *************** *** 360,375 **** if (elementClass==null) elementClass=elt.getAttributeValue("class"); } ! fields.add( new Field( role, getFieldType(elementClass) + "[]", false ) ); } } ! private String getFieldType(String hibernateType) { return getFieldType(hibernateType, false); } ! private String getFieldType(String hibernateType, boolean needObject) { // deal with hibernate binary type if ( hibernateType.equals("binary") ) { ! return "byte[]"; } else { --- 461,481 ---- if (elementClass==null) elementClass=elt.getAttributeValue("class"); } ! ClassName cn = getFieldType(elementClass); ! cn.setFullyQualifiedName(cn.getFullyQualifiedName() + "[]",cn.isPrimitive()); ! cn.setIsArray(true); ! fields.add( new Field( role, cn, false ) ); } } ! private ClassName getFieldType(String hibernateType) { return getFieldType(hibernateType, false); } ! private ClassName getFieldType(String hibernateType, boolean needObject) { // deal with hibernate binary type + ClassName cn = new ClassName(); if ( hibernateType.equals("binary") ) { ! cn.setFullyQualifiedName("byte[]",true); ! return cn; } else { *************** *** 382,389 **** !needObject ) { ! return ( (PrimitiveType) basicType ).primitiveClass().getName(); } else { ! return basicType.returnedClass().getName(); } --- 488,497 ---- !needObject ) { ! cn.setFullyQualifiedName(( (PrimitiveType) basicType ).primitiveClass().getName(),true); ! return cn; } else { ! cn.setFullyQualifiedName(basicType.returnedClass().getName()); ! return cn; } *************** *** 394,403 **** // add an import and field for this property addImport(classType); ! return classType.getName(); } } } ! } --- 502,530 ---- // add an import and field for this property addImport(classType); ! return classType; } } } + ! /** ! * Returns the superClassMapping. ! * @return ClassMapping ! */ ! public ClassMapping getSuperClassMapping() { ! return superClassMapping; ! } ! ! /** ! * Sets the superClassMapping. ! * @param superClassMapping The superClassMapping to set ! */ ! public void setSuperClassMapping(ClassMapping superClassMapping) { ! this.superClassMapping = superClassMapping; } + + } + + + Index: ClassName.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen/ClassName.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ClassName.java 9 Oct 2002 03:52:10 -0000 1.3 --- ClassName.java 30 Dec 2002 11:32:49 -0000 1.4 *************** *** 7,23 **** private String packageName = null; private String name = null; ! public void setFullyQualifiedName(String fullyQualifiedName) { ! this.fullyQualifiedName = fullyQualifiedName; ! int lastDot = fullyQualifiedName.lastIndexOf("."); ! if (lastDot<0 ) { ! name = fullyQualifiedName; ! packageName = null; ! } ! else { ! name = fullyQualifiedName.substring(lastDot + 1); ! packageName = fullyQualifiedName.substring(0, lastDot); ! } } public String getFullyQualifiedName() { --- 7,38 ---- private String packageName = null; private String name = null; ! private boolean primitive = false; ! private boolean isArray = false; ! public void setFullyQualifiedName(String fullyQualifiedName) { ! setFullyQualifiedName(fullyQualifiedName,false); } + + public void setFullyQualifiedName(String fullyQualifiedName, boolean isPrimitive) { + this.fullyQualifiedName = fullyQualifiedName; + primitive = isPrimitive; + if (!isPrimitive) { + + if (fullyQualifiedName != null) { + + int lastDot = fullyQualifiedName.lastIndexOf("."); + if (lastDot < 0) { + name = fullyQualifiedName; + packageName = null; + } else { + name = fullyQualifiedName.substring(lastDot + 1); + packageName = fullyQualifiedName.substring(0, lastDot); + } + } else { + name = fullyQualifiedName; + packageName = null; + } + } + } public String getFullyQualifiedName() { *************** *** 46,48 **** --- 61,85 ---- return otherClassName.fullyQualifiedName.equals(fullyQualifiedName); } + /** + * Method isPrimitive. + * @return boolean + */ + public boolean isPrimitive() { + return primitive; + } + /** + * Method setIsArray. + * @param b + */ + public void setIsArray(boolean b) { + isArray=b; + } + /** + * Method isArray. + * @return boolean + */ + public boolean isArray() { + return isArray; + } + } Index: Field.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen/Field.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Field.java 29 Dec 2002 01:30:55 -0000 1.6 --- Field.java 30 Dec 2002 11:32:49 -0000 1.7 *************** *** 5,9 **** public class Field { private String name = null; ! private String type = null; private String initialisation = null; private String asSuffix = null; --- 5,9 ---- public class Field { private String name = null; ! // private String type = null; private String initialisation = null; private String asSuffix = null; *************** *** 13,19 **** private ClassName classType; ! public Field(String name, String type, boolean nullable) { this.name = name; ! this.type = type; this.nullable = nullable; --- 13,19 ---- private ClassName classType; ! public Field(String name, ClassName type, boolean nullable) { this.name = name; ! setType(type); this.nullable = nullable; *************** *** 21,27 **** } ! public Field(String name, String type, boolean nullable, boolean id, boolean generated) { this.name = name; ! this.type = type; this.id = id; this.nullable = nullable; //? --- 21,27 ---- } ! public Field(String name, ClassName type, boolean nullable, boolean id, boolean generated) { this.name = name; ! setType(type); this.id = id; this.nullable = nullable; //? *************** *** 30,34 **** } ! public Field(String name, String type, String initialisation, boolean nullable) { this(name, type, nullable); --- 30,34 ---- } ! public Field(String name, ClassName type, String initialisation, boolean nullable) { this(name, type, nullable); *************** *** 49,52 **** --- 49,53 ---- public String getType() { + String type = classType.getFullyQualifiedName(); int loc = type.indexOf("java.lang."); if ( loc<0 ) { *************** *** 73,83 **** return getType() + ":" + getName(); } ! /** ! * Method setClassType. ! * @param classType ! */ ! public void setClassType(ClassName classType) { ! this.classType = classType; ! } /** * Returns the classType. Can be null as it is not always possible to get --- 74,78 ---- return getType() + ":" + getName(); } ! /** * Returns the classType. Can be null as it is not always possible to get *************** *** 88,91 **** --- 83,92 ---- return classType; } + + private void setType(ClassName type) { + this.classType = type; + } + + } |
From: <one...@us...> - 2002-12-30 11:32:53
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen/test In directory sc8-pr-cvs1:/tmp/cvs-serv21178/test Modified Files: Test.hbm.xml Test2.hbm.xml Log Message: integrated Max Andersen's patch to fix subclass constructors improved generated comments Index: Test.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen/test/Test.hbm.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Test.hbm.xml 25 Dec 2002 04:44:02 -0000 1.4 --- Test.hbm.xml 30 Dec 2002 11:32:50 -0000 1.5 *************** *** 53,56 **** --- 53,57 ---- type="date"/> </subclass> + <subclass name="codegen.test.Group"> <list role="members" *************** *** 62,65 **** --- 63,77 ---- </list> </subclass> + + <!-- To test referring to subclass in another package --> + <subclass name="codegen.test.other.Group"> + <property name="simpleAttrib" type="string"/> + + <array role="otherGroups" element-class="codegen.test.User"> + <key column="principal"/> + <one-to-many class="codegen.test.User"/> + </array> + </subclass> + </class> Index: Test2.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen/test/Test2.hbm.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Test2.hbm.xml 29 Dec 2002 01:30:54 -0000 1.3 --- Test2.hbm.xml 30 Dec 2002 11:32:50 -0000 1.4 *************** *** 5,18 **** <hibernate-mapping> <!-- Needs a identifier of type Long and no minimal constructor --> ! <class name="ObjIdNoMin"> <id name="id" type="long" unsaved-value="null"> <generator class="vm.long"/> </id> <property name="one" type="string" not-null="true"/> ! <many-to-one name="two" class="ClassB" not-null="true"/> </class> <!-- Needs constructors including the identifier and no minimal constructor --> ! <class name="ConstructorIdNoMin"> <id name="id" type="long"> <generator class="assigned"/> --- 5,18 ---- <hibernate-mapping> <!-- Needs a identifier of type Long and no minimal constructor --> ! <class name="codegen.test.ObjIdNoMin"> <id name="id" type="long" unsaved-value="null"> <generator class="vm.long"/> </id> <property name="one" type="string" not-null="true"/> ! <many-to-one name="two" class="codegen.test.ClassB" not-null="true"/> </class> <!-- Needs constructors including the identifier and no minimal constructor --> ! <class name="codegen.test.ConstructorIdNoMin"> <id name="id" type="long"> <generator class="assigned"/> *************** *** 22,26 **** <!-- Needs a constructor including the identifier and a minimal constructor --> ! <class name="ConstructorIdAndMin"> <id name="id" type="long"> <generator class="assigned"/> --- 22,26 ---- <!-- Needs a constructor including the identifier and a minimal constructor --> ! <class name="codegen.test.ConstructorIdAndMin"> <id name="id" type="long"> <generator class="assigned"/> *************** *** 30,34 **** <!-- Need both full and minimal constructor, includes a collection --> ! <class name="BothConstructors"> <id name="id" type="string"> <generator class="uuid.hex"/> --- 30,34 ---- <!-- Need both full and minimal constructor, includes a collection --> ! <class name="codegen.test.BothConstructors"> <id name="id" type="string"> <generator class="uuid.hex"/> *************** *** 38,42 **** <set role="recursiveColl"> <key type="long" column="bcid"/> ! <one-to-many class="BothConstructors"/> </set> </class> --- 38,42 ---- <set role="recursiveColl"> <key type="long" column="bcid"/> ! <one-to-many class="codegen.test.BothConstructors"/> </set> </class> *************** *** 44,48 **** <!-- dummy classes to make the test complete --> <!-- also tests support for classes with no properties --> ! <class name="ClassB"> <id name="id" type="int"> <generator class="uuid.hex"/> --- 44,48 ---- <!-- dummy classes to make the test complete --> <!-- also tests support for classes with no properties --> ! <class name="codegen.test.ClassB"> <id name="id" type="int"> <generator class="uuid.hex"/> *************** *** 50,54 **** </class> ! <class name="ClassA"> <id name="id" type="int"> <generator class="uuid.hex"/> --- 50,54 ---- </class> ! <class name="codegen.test.ClassA"> <id name="id" type="int"> <generator class="uuid.hex"/> *************** *** 56,62 **** </class> ! <class name="CompositeIdClass"> ! <composite-id name="composite" class="CompositeId"> ! <key-many-to-one name="classA" class="ClassA"/> <key-property name="name" type="string"/> </composite-id> --- 56,62 ---- </class> ! <class name="codegen.test.CompositeIdClass"> ! <composite-id name="composite" class="codegen.test.CompositeId"> ! <key-many-to-one name="classA" class="codegen.test.ClassA"/> <key-property name="name" type="string"/> </composite-id> *************** *** 65,71 **** </class> ! <class name="EmbeddedCompositeIdClass"> <composite-id> ! <key-many-to-one name="classA" class="ClassA"/> <key-property name="name" type="string"/> </composite-id> --- 65,71 ---- </class> ! <class name="codegen.test.EmbeddedCompositeIdClass"> <composite-id> ! <key-many-to-one name="classA" class="codegen.test.ClassA"/> <key-property name="name" type="string"/> </composite-id> |
From: <one...@us...> - 2002-12-30 10:58:20
|
Update of /cvsroot/hibernate/Hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv1259 Modified Files: build.xml Log Message: removed todo.txt Index: build.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate/build.xml,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** build.xml 11 Nov 2002 11:30:00 -0000 1.31 --- build.xml 30 Dec 2002 10:58:15 -0000 1.32 *************** *** 197,201 **** <copy file="cache.ccf" todir="${dist.dir}"/> <copy file="readme.txt" todir="${dist.dir}"/> - <copy file="todo.txt" todir="${dist.dir}"/> <copy file="lgpl.txt" todir="${dist.dir}"/> <copy file="changelog.txt" todir="${dist.dir}"/> --- 197,200 ---- |
From: <one...@us...> - 2002-12-29 01:30:59
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen/test In directory sc8-pr-cvs1:/tmp/cvs-serv29617/cirrus/hibernate/tools/codegen/test Modified Files: Test2.hbm.xml Log Message: * CodeGenerator Improvements: - fixed some problems with composite-ids - composite-id classes now implement equals(), hashCCode() - all generated classes implement toString() * Use ObjectUtil.equals() in a bunch of places Index: Test2.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen/test/Test2.hbm.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Test2.hbm.xml 10 Nov 2002 15:19:49 -0000 1.2 --- Test2.hbm.xml 29 Dec 2002 01:30:54 -0000 1.3 *************** *** 1,4 **** <?xml version="1.0"?> ! <!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping.dtd" > --- 1,4 ---- <?xml version="1.0"?> ! <!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd" > *************** *** 55,57 **** </id> </class> ! </hibernate-mapping> \ No newline at end of file --- 55,76 ---- </id> </class> ! ! <class name="CompositeIdClass"> ! <composite-id name="composite" class="CompositeId"> ! <key-many-to-one name="classA" class="ClassA"/> ! <key-property name="name" type="string"/> ! </composite-id> ! <property name="address" type="string" not-null="true"/> ! <property name="longValue" type="java.lang.Long"/> ! </class> ! ! <class name="EmbeddedCompositeIdClass"> ! <composite-id> ! <key-many-to-one name="classA" class="ClassA"/> ! <key-property name="name" type="string"/> ! </composite-id> ! <property name="address" type="string" not-null="true"/> ! <property name="longValue" type="java.lang.Long"/> ! </class> ! ! </hibernate-mapping> \ No newline at end of file |
From: <one...@us...> - 2002-12-29 01:30:59
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv29617/cirrus/hibernate/test Modified Files: CustomPersister.java Log Message: * CodeGenerator Improvements: - fixed some problems with composite-ids - composite-id classes now implement equals(), hashCCode() - all generated classes implement toString() * Use ObjectUtil.equals() in a bunch of places Index: CustomPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/CustomPersister.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** CustomPersister.java 26 Nov 2002 03:35:44 -0000 1.15 --- CustomPersister.java 29 Dec 2002 01:30:55 -0000 1.16 *************** *** 7,10 **** --- 7,12 ---- import java.util.Hashtable; + import org.apache.commons.lang.ObjectUtils; + import cirrus.hibernate.Hibernate; import cirrus.hibernate.HibernateException; *************** *** 173,177 **** SessionImplementor session) throws HibernateException { ! if ( x[0]!=y[0] && ( x[0]==null || y[0]==null || !x[0].equals(y[0]) ) ) { return new int[] { 0 }; } --- 175,179 ---- SessionImplementor session) throws HibernateException { ! if ( !ObjectUtils.equals( x[0], y[0] ) ) { return new int[] { 0 }; } |
From: <one...@us...> - 2002-12-29 01:30:59
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen In directory sc8-pr-cvs1:/tmp/cvs-serv29617/cirrus/hibernate/tools/codegen Modified Files: Generator.java Field.java ClassMapping.java BasicRenderer.java Log Message: * CodeGenerator Improvements: - fixed some problems with composite-ids - composite-id classes now implement equals(), hashCCode() - all generated classes implement toString() * Use ObjectUtil.equals() in a bunch of places Index: Generator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen/Generator.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Generator.java 21 Oct 2002 03:45:04 -0000 1.8 --- Generator.java 29 Dec 2002 01:30:55 -0000 1.9 *************** *** 59,67 **** // set lowerFirstLetter value = generateElement.getAttributeValue("lowerFirstLetter"); ! if ((value == null) || (value.equals("false"))) { this.lowerFirstLetter = false; ! } else if (value.equals("true")) { this.lowerFirstLetter = true; ! } else { throw new Exception("invalid value for element lowerFirstLeter. should be true or false."); } --- 59,69 ---- // set lowerFirstLetter value = generateElement.getAttributeValue("lowerFirstLetter"); ! if ( (value == null) || ( value.equals("false") ) ) { this.lowerFirstLetter = false; ! } ! else if ( value.equals("true") ) { this.lowerFirstLetter = true; ! } ! else { throw new Exception("invalid value for element lowerFirstLeter. should be true or false."); } Index: Field.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen/Field.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Field.java 21 Oct 2002 03:45:04 -0000 1.5 --- Field.java 29 Dec 2002 01:30:55 -0000 1.6 *************** *** 21,28 **** } ! public Field(String name, String type, boolean id, boolean generated) { this.name = name; this.type = type; this.id = id; this.generated = generated; this.asSuffix = name.substring(0, 1).toUpperCase() + name.substring(1); --- 21,29 ---- } ! public Field(String name, String type, boolean nullable, boolean id, boolean generated) { this.name = name; this.type = type; this.id = id; + this.nullable = nullable; //? this.generated = generated; this.asSuffix = name.substring(0, 1).toUpperCase() + name.substring(1); Index: ClassMapping.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen/ClassMapping.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** ClassMapping.java 28 Dec 2002 02:25:48 -0000 1.20 --- ClassMapping.java 29 Dec 2002 01:30:55 -0000 1.21 *************** *** 26,30 **** private List subclasses = new ArrayList(); private static final Map components = new HashMap(); ! public ClassMapping(ClassName superClass, Element classElement) throws Exception { --- 26,30 ---- private List subclasses = new ArrayList(); private static final Map components = new HashMap(); ! private boolean mustImplementEquals = false; public ClassMapping(ClassName superClass, Element classElement) throws Exception { *************** *** 53,56 **** --- 53,62 ---- propertyList.addAll( classElement.getChildren("version") ); propertyList.addAll( classElement.getChildren("timestamp") ); + propertyList.addAll( classElement.getChildren("key-property") ); + + // get all many-to-one associations defined for the class + List manyToOneList = new ArrayList(); + manyToOneList.addAll( classElement.getChildren("many-to-one") ); + manyToOneList.addAll( classElement.getChildren("key-many-to-one") ); Attribute att = classElement.getAttribute("proxy"); *************** *** 68,90 **** String cmpclass = cmpid.getAttributeValue("class"); if ( cmpclass==null || cmpclass.equals("") ) { ! propertyList.addAll( cmpid.getChildren("key-property") ); ! for ( Iterator it = cmpid.getChildren("key-many-to-one").iterator(); it.hasNext(); ) { ! Element manyToOne = (Element) it.next(); ! ! ClassName classType = new ClassName(); ! classType.setFullyQualifiedName(manyToOne.getAttributeValue("class")); ! // add an import and field for this property ! addImport(classType); ! fields.add(new Field(manyToOne.getAttributeValue("name"), classType.getName(), false)); ! } } else { ClassMapping mapping = new ClassMapping(cmpid, true); ! ClassName classType = new ClassName(); classType.setFullyQualifiedName(cmpclass); // add an import and field for this property addImport(classType); ! fields.add(new Field(cmpname, classType.getName(), false)); components.put( mapping.getCanonicalName(), mapping ); } --- 74,91 ---- String cmpclass = cmpid.getAttributeValue("class"); if ( cmpclass==null || cmpclass.equals("") ) { ! //Embedded composite id ! implementEquals(); ! propertyList.addAll(0, cmpid.getChildren("key-property") ); ! manyToOneList.addAll(0, cmpid.getChildren("key-many-to-one") ); } else { + //Composite id class ClassMapping mapping = new ClassMapping(cmpid, true); ! mapping.implementEquals(); ClassName classType = new ClassName(); classType.setFullyQualifiedName(cmpclass); // add an import and field for this property addImport(classType); ! fields.add( new Field(cmpname, classType.getName(), false, true, false) ); components.put( mapping.getCanonicalName(), mapping ); } *************** *** 113,125 **** // ids may be generated and may need to be of object type in order to support // the unsaved-value "null" value. ! // Properties may be nullable (whilst ids can not) ! if(property == id) { Element generator = property.getChild("generator"); String unsavedValue = property.getAttributeValue("unsaved-value"); ! boolean needObject = (unsavedValue != null && unsavedValue.equals("null")); boolean generated = !generator.getAttributeValue("class").equals("assigned"); ! Field idField = new Field(name, getFieldType(type, needObject), true, generated); fields.add(idField); ! } else { String notnull = property.getAttributeValue("not-null"); // if not-null property is missing lets see if it has been --- 114,127 ---- // ids may be generated and may need to be of object type in order to support // the unsaved-value "null" value. ! // Properties may be nullable (ids may not) ! if (property == id) { Element generator = property.getChild("generator"); String unsavedValue = property.getAttributeValue("unsaved-value"); ! boolean needObject = ( unsavedValue != null && unsavedValue.equals("null") ); boolean generated = !generator.getAttributeValue("class").equals("assigned"); ! Field idField = new Field( name, getFieldType(type, needObject), false, true, generated ); fields.add(idField); ! } ! else { String notnull = property.getAttributeValue("not-null"); // if not-null property is missing lets see if it has been *************** *** 130,135 **** notnull = column.getAttributeValue("not-null"); } ! boolean nullable = (notnull == null || notnull.equals("false")); ! fields.add(new Field(name, getFieldType(type), nullable)); } } --- 132,138 ---- notnull = column.getAttributeValue("not-null"); } ! boolean nullable = ( notnull == null || notnull.equals("false") ); ! boolean key = property.getName().startsWith("key-"); //a composite id property ! fields.add( new Field(name, getFieldType(type), nullable && !key, key, false) ); } } *************** *** 137,141 **** // one to ones List onetooneList = classElement.getChildren("one-to-one"); ! for (Iterator onetoones = onetooneList.iterator(); onetoones.hasNext();) { Element onetoone = (Element) onetoones.next(); --- 140,144 ---- // one to ones List onetooneList = classElement.getChildren("one-to-one"); ! for ( Iterator onetoones = onetooneList.iterator(); onetoones.hasNext(); ) { Element onetoone = (Element) onetoones.next(); *************** *** 144,158 **** // ensure that the class is specified String clazz = onetoone.getAttributeValue("class"); ! if(StringUtils.isEmpty(clazz)) { System.out.println("one-to-one \"" + name + "\" in class " + getName() + " is missing a class attribute"); continue; } ! fields.add(new Field(name, getFieldType(clazz), true)); } // many to ones - TODO: consolidate with code above ! for (Iterator manytoOnes = classElement.getChildren("many-to-one").iterator(); manytoOnes.hasNext();) { Element manyToOne = (Element) manytoOnes.next(); --- 147,161 ---- // ensure that the class is specified String clazz = onetoone.getAttributeValue("class"); ! if( StringUtils.isEmpty(clazz) ) { System.out.println("one-to-one \"" + name + "\" in class " + getName() + " is missing a class attribute"); continue; } ! fields.add( new Field(name, getFieldType(clazz), true) ); } // many to ones - TODO: consolidate with code above ! for ( Iterator manytoOnes = manyToOneList.iterator(); manytoOnes.hasNext(); ) { Element manyToOne = (Element) manytoOnes.next(); *************** *** 170,178 **** // is it nullable? String notnull = manyToOne.getAttributeValue("not-null"); ! boolean nullable = (notnull == null || notnull.equals("false")); ! // add an import and field for this property addImport(classType); ! Field f = new Field( name, classType.getName(), nullable ); f.setClassType(classType); fields.add(f); --- 173,182 ---- // is it nullable? String notnull = manyToOne.getAttributeValue("not-null"); ! boolean nullable = ( notnull == null || notnull.equals("false") ); ! boolean key = manyToOne.getName().startsWith("key-"); //a composite id property ! // add an import and field for this property addImport(classType); ! Field f = new Field( name, classType.getName(), nullable && !key, key, false ); f.setClassType(classType); fields.add(f); *************** *** 218,226 **** // add an import and field for this property addImport(classType); ! fields.add(new Field(cmpname, classType.getName(), false)); components.put( mapping.getCanonicalName(), mapping ); } } public List getFields() { return fields; --- 222,238 ---- // add an import and field for this property addImport(classType); ! fields.add( new Field(cmpname, classType.getName(), false) ); components.put( mapping.getCanonicalName(), mapping ); } } + public void implementEquals() { + mustImplementEquals = true; + } + + public boolean mustImplementEquals() { + return mustImplementEquals; + } + public List getFields() { return fields; *************** *** 264,280 **** boolean missingId = true; int countNull = 0; ! for(Iterator it = fields.iterator(); it.hasNext(); ) { Field f = (Field) it.next(); ! if(f.isIdentifier()) { generatedId = f.isGenerated(); missingId = false; } else ! if(f.isNullable()) countNull++; } ! return !(countNull == 0 || ! ((countNull == (fields.size() - 1)) && generatedId) || ! ((countNull == (fields.size()) && missingId))); } --- 276,294 ---- boolean missingId = true; int countNull = 0; ! for( Iterator it = fields.iterator(); it.hasNext(); ) { Field f = (Field) it.next(); ! if( f.isIdentifier() ) { generatedId = f.isGenerated(); missingId = false; } else ! if( f.isNullable() ) countNull++; } ! return !( ! countNull == 0 || ! ( ( countNull == fields.size()-1 ) && generatedId ) || ! (countNull == fields.size() && missingId) ! ); } *************** *** 330,334 **** private void doArrays(Element classElement, String type) { ! for (Iterator arrays = classElement.getChildren(type).iterator(); arrays.hasNext();) { Element array = (Element) arrays.next(); String role = array.getAttributeValue("role"); --- 344,348 ---- private void doArrays(Element classElement, String type) { ! for ( Iterator arrays = classElement.getChildren(type).iterator(); arrays.hasNext(); ) { Element array = (Element) arrays.next(); String role = array.getAttributeValue("role"); *************** *** 365,369 **** if ( (basicType instanceof PrimitiveType) && ! !hibernateType.trim().equals( basicType.returnedClass().getName()) && !needObject ) { --- 379,383 ---- if ( (basicType instanceof PrimitiveType) && ! !hibernateType.trim().equals( basicType.returnedClass().getName() ) && !needObject ) { Index: BasicRenderer.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen/BasicRenderer.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** BasicRenderer.java 8 Nov 2002 23:49:47 -0000 1.13 --- BasicRenderer.java 29 Dec 2002 01:30:55 -0000 1.14 *************** *** 38,46 **** // imports classMapping.getImports().add("java.io.Serializable"); ! String item = null; ! for (Iterator imports = classMapping.getImports().iterator(); imports.hasNext();) { ! item = (String) imports.next(); ! writer.println("import " + item + ";"); } writer.println(); --- 38,49 ---- // imports classMapping.getImports().add("java.io.Serializable"); ! classMapping.getImports().add("org.apache.commons.lang.builder.ToStringBuilder"); ! if ( classMapping.mustImplementEquals() ) { ! classMapping.getImports().add("org.apache.commons.lang.builder.EqualsBuilder"); ! classMapping.getImports().add("org.apache.commons.lang.builder.HashCodeBuilder"); ! } ! for ( Iterator imports = classMapping.getImports().iterator(); imports.hasNext(); ) { ! writer.println("import " + imports.next() + ";"); } writer.println(); *************** *** 66,75 **** } writer.println(" {"); // fields - Field field = null; - for (Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { ! field = (Field) fields.next(); writer.println(" private " + field.getType() + ' ' + field.getName() + ( field.isIdentifier() ? "; //identifier" : "; //persistent") --- 69,77 ---- } writer.println(" {"); + writer.println(); // fields for (Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { ! Field field = (Field) fields.next(); writer.println(" private " + field.getType() + ' ' + field.getName() + ( field.isIdentifier() ? "; //identifier" : "; //persistent") *************** *** 82,86 **** String fullCons = " public " + classMapping.getName() + "("; for(Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { ! field = (Field) fields.next(); if(!field.isIdentifier() || (field.isIdentifier() && !field.isGenerated())) { fullCons = fullCons + field.getType() + " " + field.getName(); --- 84,88 ---- String fullCons = " public " + classMapping.getName() + "("; for(Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { ! Field field = (Field) fields.next(); if(!field.isIdentifier() || (field.isIdentifier() && !field.isGenerated())) { fullCons = fullCons + field.getType() + " " + field.getName(); *************** *** 93,97 **** writer.println(fullCons + ") {"); for(Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { ! field = (Field) fields.next(); if(!field.isIdentifier() || (field.isIdentifier() && !field.isGenerated())) { writer.println(" this." + field.getName() + " = " + field.getName() + ";"); --- 95,99 ---- writer.println(fullCons + ") {"); for(Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { ! Field field = (Field) fields.next(); if(!field.isIdentifier() || (field.isIdentifier() && !field.isGenerated())) { writer.println(" this." + field.getName() + " = " + field.getName() + ";"); *************** *** 111,144 **** if(fullConsArgCount>0) { ! if(classMapping.needsMinimalConstructor()) { ! String minCons = " public " + classMapping.getName() + "("; ! for(Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { ! field = (Field) fields.next(); ! if((!field.isIdentifier() && !field.isNullable()) || ! (field.isIdentifier() && !field.isGenerated())) { ! minCons = minCons + field.getType() + " " + field.getName(); ! minCons = minCons + ", "; ! } ! } ! if ( minCons.endsWith(", ") ) minCons = minCons.substring(0, minCons.length()-2); ! ! writer.println(minCons + ") {"); ! for(Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { ! field = (Field) fields.next(); ! if((!field.isIdentifier() && !field.isNullable()) || ! (field.isIdentifier() && !field.isGenerated())) { ! writer.println(" this." + field.getName() + " = " + field.getName() + ";"); ! } ! } ! writer.println(" }"); ! writer.println(); ! } } // field accessors for (Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { ! field = (Field) fields.next(); ! String getterType = (field.getType().toLowerCase().equals("boolean")) ? " is" : " get"; // getter --- 113,146 ---- if(fullConsArgCount>0) { ! if( classMapping.needsMinimalConstructor() ) { ! String minCons = " public " + classMapping.getName() + "("; ! for(Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { ! Field field = (Field) fields.next(); ! if((!field.isIdentifier() && !field.isNullable()) || ! (field.isIdentifier() && !field.isGenerated())) { ! minCons = minCons + field.getType() + " " + field.getName(); ! minCons = minCons + ", "; ! } ! } ! if ( minCons.endsWith(", ") ) minCons = minCons.substring(0, minCons.length()-2); ! ! writer.println(minCons + ") {"); ! for(Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { ! Field field = (Field) fields.next(); ! if((!field.isIdentifier() && !field.isNullable()) || ! (field.isIdentifier() && !field.isGenerated())) { ! writer.println(" this." + field.getName() + " = " + field.getName() + ";"); ! } ! } ! writer.println(" }"); ! writer.println(); ! } } // field accessors for (Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { ! Field field = (Field) fields.next(); ! String getterType = ( field.getType().toLowerCase().equals("boolean") ) ? " is" : " get"; // getter *************** *** 153,157 **** writer.println(" }"); } ! writer.println("}"); } --- 155,194 ---- writer.println(" }"); } ! ! writer.println(); ! writer.println(" public String toString() {"); ! //easier to use reflectionToString() than worry about superclasses ! writer.println(" return ToStringBuilder.reflectionToString(this);"); ! writer.println(" }"); ! writer.println(); ! ! if ( classMapping.mustImplementEquals() ) { ! writer.println(" public boolean equals(Object other) {"); ! writer.println(" if ( !(other instanceof " + className + ") ) return false;"); ! writer.println(" " + className + " castOther = (" + className + ") other;"); ! writer.println(" return new EqualsBuilder()"); ! for (Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { ! Field field = (Field) fields.next(); ! if ( field.isIdentifier() ) { ! writer.println(" .append(this." + field.getName() + ", castOther." + field.getName() + ")"); ! } ! } ! writer.println(" .isEquals();"); ! writer.println(" }"); ! writer.println(); ! ! writer.println(" public int hashCode() {"); ! writer.println(" return new HashCodeBuilder()"); ! for (Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { ! Field field = (Field) fields.next(); ! if ( field.isIdentifier() ) { ! writer.println(" .append(" + field.getName() + ")"); ! } ! } ! writer.println(" .toHashCode();"); ! writer.println(" }"); ! writer.println(); ! } ! writer.println("}"); } |
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/type In directory sc8-pr-cvs1:/tmp/cvs-serv29617/cirrus/hibernate/type Modified Files: TimeZoneType.java StringType.java PrimitiveType.java LocaleType.java CurrencyType.java ClassType.java Log Message: * CodeGenerator Improvements: - fixed some problems with composite-ids - composite-id classes now implement equals(), hashCCode() - all generated classes implement toString() * Use ObjectUtil.equals() in a bunch of places Index: TimeZoneType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/TimeZoneType.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TimeZoneType.java 26 Nov 2002 03:35:46 -0000 1.3 --- TimeZoneType.java 29 Dec 2002 01:30:54 -0000 1.4 *************** *** 7,10 **** --- 7,12 ---- import java.util.TimeZone; + import org.apache.commons.lang.ObjectUtils; + import cirrus.hibernate.Hibernate; import cirrus.hibernate.HibernateException; *************** *** 58,62 **** */ public boolean equals(Object x, Object y) throws HibernateException { ! return x==y || ( x!=null && y!=null && x.equals(y) ); } --- 60,64 ---- */ public boolean equals(Object x, Object y) throws HibernateException { ! return ObjectUtils.equals(x, y); } Index: StringType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/StringType.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** StringType.java 11 Oct 2002 05:39:15 -0000 1.17 --- StringType.java 29 Dec 2002 01:30:54 -0000 1.18 *************** *** 7,10 **** --- 7,12 ---- import java.sql.Types; + import org.apache.commons.lang.ObjectUtils; + public class StringType extends ImmutableType implements DiscriminatorType { *************** *** 36,43 **** public boolean equals(Object x, Object y) { ! if (x==y) return true; ! if (x==null || y==null) return false; ! // don't have to check class for String ! return x.equals(y); } public String toXML(Object value) { --- 38,42 ---- public boolean equals(Object x, Object y) { ! return ObjectUtils.equals(x, y); } public String toXML(Object value) { Index: PrimitiveType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/PrimitiveType.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PrimitiveType.java 28 Oct 2002 15:41:53 -0000 1.16 --- PrimitiveType.java 29 Dec 2002 01:30:54 -0000 1.17 *************** *** 2,5 **** --- 2,7 ---- package cirrus.hibernate.type; + import org.apache.commons.lang.ObjectUtils; + /** * Superclass of primitive / primitive wrapper types. *************** *** 10,17 **** public boolean equals(Object x, Object y) { ! if (x==y) return true; ! if (x==null || y==null) return false; ! // dont have to check class for primitive types ! return x.equals(y); } --- 12,16 ---- public boolean equals(Object x, Object y) { ! return ObjectUtils.equals(x, y); } Index: LocaleType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/LocaleType.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LocaleType.java 18 Dec 2002 12:50:39 -0000 1.4 --- LocaleType.java 29 Dec 2002 01:30:54 -0000 1.5 *************** *** 8,11 **** --- 8,13 ---- import java.util.StringTokenizer; + import org.apache.commons.lang.ObjectUtils; + import cirrus.hibernate.Hibernate; import cirrus.hibernate.HibernateException; *************** *** 44,51 **** public boolean equals(Object x, Object y) throws HibernateException { ! if (x==y) return true; ! if (x==null || y==null) return false; ! // don't have to check class for Locale ! return x.equals(y); } --- 46,50 ---- public boolean equals(Object x, Object y) throws HibernateException { ! return ObjectUtils.equals(x, y); } Index: CurrencyType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/CurrencyType.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CurrencyType.java 26 Nov 2002 03:35:45 -0000 1.6 --- CurrencyType.java 29 Dec 2002 01:30:54 -0000 1.7 *************** *** 7,10 **** --- 7,12 ---- import java.sql.SQLException; + import org.apache.commons.lang.ObjectUtils; + import cirrus.hibernate.AssertionFailure; import cirrus.hibernate.Hibernate; *************** *** 105,109 **** */ public boolean equals(Object x, Object y) throws HibernateException { ! return x==y || ( x!=null && y!=null && x.equals(y) ); } --- 107,111 ---- */ public boolean equals(Object x, Object y) throws HibernateException { ! return ObjectUtils.equals(x, y); } Index: ClassType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/ClassType.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ClassType.java 10 Sep 2002 17:59:16 -0000 1.1 --- ClassType.java 29 Dec 2002 01:30:54 -0000 1.2 *************** *** 6,9 **** --- 6,11 ---- import java.sql.SQLException; + import org.apache.commons.lang.ObjectUtils; + import cirrus.hibernate.Hibernate; import cirrus.hibernate.HibernateException; *************** *** 44,51 **** public boolean equals(Object x, Object y) throws HibernateException { ! if (x==y) return true; ! if (x==null || y==null) return false; ! // don't have to check class for Class ! return x.equals(y); } --- 46,50 ---- public boolean equals(Object x, Object y) throws HibernateException { ! return ObjectUtils.equals(x, y); } |
From: <one...@us...> - 2002-12-28 13:26:14
|
Update of /cvsroot/hibernate/Hibernate/lib In directory sc8-pr-cvs1:/tmp/cvs-serv12648/lib Modified Files: odmg.jar Log Message: rebuilt odmg.jar without src Index: odmg.jar =================================================================== RCS file: /cvsroot/hibernate/Hibernate/lib/odmg.jar,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvsgKoZzh and /tmp/cvs4S7IIo differ |
From: <one...@us...> - 2002-12-28 02:25:52
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/engine In directory sc8-pr-cvs1:/tmp/cvs-serv21213/cirrus/hibernate/engine Modified Files: SessionFactoryImplementor.java Log Message: added support for <joined-subclass> to CodeGenerator added Query.getNamedParameters(), Query.setProperties() fixed a bug in Query.getReturnTypes() Index: SessionFactoryImplementor.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/engine/SessionFactoryImplementor.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SessionFactoryImplementor.java 26 Nov 2002 03:35:41 -0000 1.5 --- SessionFactoryImplementor.java 28 Dec 2002 02:25:49 -0000 1.6 *************** *** 5,8 **** --- 5,9 ---- import java.sql.PreparedStatement; import java.sql.SQLException; + import java.util.Collection; import cirrus.hibernate.HibernateException; *************** *** 19,26 **** * @see cirrus.hibernate.impl.SessionFactoryImpl */ ! public interface SessionFactoryImplementor extends Mapping { /** * Get the persister for a class ! */ public ClassPersister getPersister(Class clazz) throws MappingException; /** * Get the persister for the named class --- 20,29 ---- * @see cirrus.hibernate.impl.SessionFactoryImpl */ ! public interface SessionFactoryImplementor extends Mapping { ! /** * Get the persister for a class ! */ ! public ClassPersister getPersister(Class clazz) throws MappingException; /** * Get the persister for the named class *************** *** 54,57 **** --- 57,65 ---- public Type[] getReturnTypes(String queryString) throws HibernateException; + /** + * Get the named parameter names for a query + * @return a collection of strings + */ + public Collection getNamedParameters(String queryString) throws HibernateException; /** * Obtain a JDBC connection |
From: <one...@us...> - 2002-12-28 02:25:52
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/helpers In directory sc8-pr-cvs1:/tmp/cvs-serv21213/cirrus/hibernate/helpers Modified Files: ReflectHelper.java ArrayHelper.java Log Message: added support for <joined-subclass> to CodeGenerator added Query.getNamedParameters(), Query.setProperties() fixed a bug in Query.getReturnTypes() Index: ReflectHelper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/helpers/ReflectHelper.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** ReflectHelper.java 7 Dec 2002 08:10:23 -0000 1.36 --- ReflectHelper.java 28 Dec 2002 02:25:49 -0000 1.37 *************** *** 10,14 **** import cirrus.hibernate.*; - import cirrus.hibernate.MappingException; import cirrus.hibernate.type.*; import cirrus.hibernate.type.Type; --- 10,13 ---- *************** *** 118,124 **** ! public static Method getMethod(Class theClass, String methodName) throws MappingException { ! if (theClass==Object.class || theClass==null) throw new MappingException( "Could not find a setter" ); // will be swallowed Method result; --- 117,123 ---- ! public static Method getMethod(Class theClass, String methodName) throws PropertyNotFoundException { ! if (theClass==Object.class || theClass==null) throw new PropertyNotFoundException( "Could not find a setter" ); // will be swallowed Method result; *************** *** 130,135 **** return getMethod( theClass.getSuperclass(), methodName ); } ! catch (MappingException me) { ! throw new MappingException( "Could not find method " + methodName + " in class " + theClass.getName() ); } } --- 129,134 ---- return getMethod( theClass.getSuperclass(), methodName ); } ! catch (PropertyNotFoundException me) { ! throw new PropertyNotFoundException( "Could not find method " + methodName + " in class " + theClass.getName() ); } } *************** *** 140,146 **** } ! public static Setter getSetter(Class theClass, String propertyName) throws MappingException { ! if (theClass==Object.class || theClass==null) throw new MappingException( "Could not find a setter" ); // will be swallowed Method result = setter(theClass, propertyName); --- 139,145 ---- } ! public static Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { ! if (theClass==Object.class || theClass==null) throw new PropertyNotFoundException( "Could not find a setter" ); // will be swallowed Method result = setter(theClass, propertyName); *************** *** 150,155 **** return getSetter( theClass.getSuperclass(), propertyName ); } ! catch (MappingException me) { ! throw new MappingException( "Could not find a setter for " + propertyName + " in class " + theClass.getName() ); } } --- 149,154 ---- return getSetter( theClass.getSuperclass(), propertyName ); } ! catch (PropertyNotFoundException me) { ! throw new PropertyNotFoundException( "Could not find a setter for " + propertyName + " in class " + theClass.getName() ); } } *************** *** 161,165 **** } ! private static Method setter(Class theClass, String propertyName) throws MappingException { Class returnType = getGetter(theClass, propertyName).getReturnType(); --- 160,164 ---- } ! private static Method setter(Class theClass, String propertyName) throws PropertyNotFoundException { Class returnType = getGetter(theClass, propertyName).getReturnType(); *************** *** 186,192 **** } ! public static Getter getGetter(Class theClass, String propertyName) throws MappingException { ! if (theClass==Object.class || theClass==null) throw new MappingException( "Could not find a getter" ); // will be swallowed Method result = getter(theClass, propertyName); --- 185,191 ---- } ! public static Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { ! if (theClass==Object.class || theClass==null) throw new PropertyNotFoundException( "Could not find a getter" ); // will be swallowed Method result = getter(theClass, propertyName); *************** *** 196,201 **** return getGetter( theClass.getSuperclass(), propertyName ); } ! catch (MappingException me) { ! throw new MappingException( "Could not find a getter for " + propertyName + " in class " + theClass.getName() ); } } --- 195,200 ---- return getGetter( theClass.getSuperclass(), propertyName ); } ! catch (PropertyNotFoundException me) { ! throw new PropertyNotFoundException( "Could not find a getter for " + propertyName + " in class " + theClass.getName() ); } } *************** *** 273,277 **** } ! public static Constructor getDefaultConstructor(Class clazz) throws MappingException { if (isAbstractClass(clazz)) return null; --- 272,276 ---- } ! public static Constructor getDefaultConstructor(Class clazz) throws PropertyNotFoundException { if (isAbstractClass(clazz)) return null; *************** *** 284,288 **** return constructor; } catch (NoSuchMethodException nme) { ! throw new MappingException( "Object class " + clazz.getName() + " must declare a default (no-argument) constructor" --- 283,287 ---- return constructor; } catch (NoSuchMethodException nme) { ! throw new PropertyNotFoundException( "Object class " + clazz.getName() + " must declare a default (no-argument) constructor" Index: ArrayHelper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/helpers/ArrayHelper.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ArrayHelper.java 28 Sep 2002 15:03:29 -0000 1.8 --- ArrayHelper.java 28 Dec 2002 02:25:49 -0000 1.9 *************** *** 18,28 **** } ! public static String[] toStringArray(java.util.List list) { ! return toStringArray( list.toArray() ); } ! public static int[] toIntArray(java.util.List list) { ! Iterator iter = list.iterator(); ! int[] arr = new int[ list.size() ]; int i=0; while( iter.hasNext() ) { --- 18,28 ---- } ! public static String[] toStringArray(java.util.Collection coll) { ! return toStringArray( coll.toArray() ); } ! public static int[] toIntArray(java.util.Collection coll) { ! Iterator iter = coll.iterator(); ! int[] arr = new int[ coll.size() ]; int i=0; while( iter.hasNext() ) { |
From: <one...@us...> - 2002-12-28 02:25:52
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv21213/cirrus/hibernate/impl Modified Files: SessionImpl.java SessionFactoryImpl.java QueryImpl.java Log Message: added support for <joined-subclass> to CodeGenerator added Query.getNamedParameters(), Query.setProperties() fixed a bug in Query.getReturnTypes() Index: SessionImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl/SessionImpl.java,v retrieving revision 1.159 retrieving revision 1.160 diff -C2 -d -r1.159 -r1.160 *** SessionImpl.java 17 Dec 2002 09:43:18 -0000 1.159 --- SessionImpl.java 28 Dec 2002 02:25:49 -0000 1.160 *************** *** 1106,1110 **** String[] concreteQueries = QueryTranslator.concreteQueries(query, factory); if ( concreteQueries.length>1 ) throw new HibernateException("This query cannot be scrolled: " + query); ! if ( concreteQueries.length==0 ) return null; //TODO: fix this and return an empty ScrollableResults QueryTranslator q = factory.getScalarQuery( concreteQueries[0] ); autoFlushIfRequired( q.getQuerySpaces() ); --- 1106,1110 ---- String[] concreteQueries = QueryTranslator.concreteQueries(query, factory); if ( concreteQueries.length>1 ) throw new HibernateException("This query cannot be scrolled: " + query); ! if ( concreteQueries.length==0 ) throw new HibernateException("Query does not refer to any persistent classes: " + query); QueryTranslator q = factory.getScalarQuery( concreteQueries[0] ); autoFlushIfRequired( q.getQuerySpaces() ); Index: SessionFactoryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl/SessionFactoryImpl.java,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** SessionFactoryImpl.java 28 Nov 2002 23:29:23 -0000 1.60 --- SessionFactoryImpl.java 28 Dec 2002 02:25:49 -0000 1.61 *************** *** 436,440 **** ); } ! Object readResolve() throws ObjectStreamException { log.trace("Resolving serialized SessionFactory"); // look for the instance by uuid --- 436,441 ---- ); } ! ! Object readResolve() throws ObjectStreamException { log.trace("Resolving serialized SessionFactory"); // look for the instance by uuid *************** *** 543,549 **** } ! public Type[] getReturnTypes(String queryString) ! throws HibernateException { ! return getScalarQuery(queryString).getReturnTypes(); } --- 544,557 ---- } ! public Type[] getReturnTypes(String queryString) throws HibernateException { ! String[] queries = QueryTranslator.concreteQueries(queryString, this); ! if ( queries.length==0 ) throw new HibernateException("Query does not refer to any persistent classes: " + queryString); ! return getScalarQuery( queries[0] ).getReturnTypes(); ! } ! ! public java.util.Collection getNamedParameters(String queryString) throws HibernateException { ! String[] queries = QueryTranslator.concreteQueries(queryString, this); ! if ( queries.length==0 ) throw new HibernateException("Query does not refer to any persistent classes: " + queryString); ! return getScalarQuery( queries[0] ).getNamedParameters(); } Index: QueryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl/QueryImpl.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** QueryImpl.java 27 Dec 2002 11:54:48 -0000 1.21 --- QueryImpl.java 28 Dec 2002 02:25:49 -0000 1.22 *************** *** 18,24 **** --- 18,27 ---- import cirrus.hibernate.HibernateException; import cirrus.hibernate.MappingException; + import cirrus.hibernate.PropertyNotFoundException; import cirrus.hibernate.Query; import cirrus.hibernate.ScrollableResults; import cirrus.hibernate.engine.*; + import cirrus.hibernate.helpers.ArrayHelper; + import cirrus.hibernate.helpers.ReflectHelper; import cirrus.hibernate.helpers.StringHelper; import cirrus.hibernate.type.Type; *************** *** 57,84 **** } - /* - * @see QueryTranslator#iterate() - */ public Iterator iterate() throws SQLException, HibernateException { return session.iterate(queryString, values.toArray(), (Type[]) types.toArray(NO_TYPES), selection, namedParams); } - /* - * @see cirrus.hibernate.Query#scroll() - */ public ScrollableResults scroll() throws SQLException, HibernateException { return session.scroll(queryString, values.toArray(), (Type[]) types.toArray(NO_TYPES), selection, namedParams); } - /* - * @see QueryTranslator#list() - */ public List list() throws SQLException, HibernateException { return session.find(queryString, values.toArray(), (Type[]) types.toArray(NO_TYPES), selection, namedParams); } - /* - * @see QueryTranslator#setMaxResults(int) - */ public void setMaxResults(int maxResults) { selection.maxRows = new Integer(maxResults); --- 60,75 ---- *************** *** 89,102 **** } - /* - * @see QueryTranslator#setFirstResult(int) - */ public void setFirstResult(int firstResult) { selection.firstRow = new Integer(firstResult); } - /* - * @see QueryTranslator#setParameter(int, Object, Type) - */ public void setParameter(int position, Object val, Type type) { int size = values.size(); --- 80,87 ---- *************** *** 115,233 **** } - /* - * @see QueryTranslator#setString(int, String) - */ public void setString(int position, String val) { setParameter(position, val, Hibernate.STRING); } - /* - * @see QueryTranslator#setChar(int, char) - */ public void setCharacter(int position, char val) { setParameter(position, new Character(val), Hibernate.CHARACTER); } - /* - * @see QueryTranslator#setBoolean(int, boolean) - */ public void setBoolean(int position, boolean val) { setParameter(position, new Boolean(val), Hibernate.BOOLEAN); } - /* - * @see QueryTranslator#setByte(int, byte) - */ public void setByte(int position, byte val) { setParameter(position, new Byte(val), Hibernate.BYTE); } - /* - * @see QueryTranslator#setShort(int, short) - */ public void setShort(int position, short val) { setParameter(position, new Short(val), Hibernate.SHORT); } - /* - * @see QueryTranslator#setInt(int, int) - */ public void setInteger(int position, int val) { setParameter(position, new Integer(val), Hibernate.INTEGER); } - /* - * @see QueryTranslator#setLong(int, long) - */ public void setLong(int position, long val) { setParameter(position, new Long(val), Hibernate.LONG); } - /* - * @see QueryTranslator#setFloat(int, long) - */ public void setFloat(int position, float val) { setParameter(position, new Float(val), Hibernate.FLOAT); } - /* - * @see QueryTranslator#setDouble(int, double) - */ public void setDouble(int position, double val) { setParameter(position, new Double(val), Hibernate.DOUBLE); } - /* - * @see QueryTranslator#setBinary(int, byte[]) - */ public void setBinary(int position, byte[] val) { setParameter(position, val, Hibernate.BINARY); } - /* - * @see QueryTranslator#setSerializable(int, Serializable) - */ public void setSerializable(int position, Serializable val) { setParameter(position, val, Hibernate.SERIALIZABLE); } - /* - * @see QueryTranslator#setDate(int, Date) - */ public void setDate(int position, Date date) { setParameter(position, date, Hibernate.DATE); } - /* - * @see QueryTranslator#setTime(int, Date) - */ public void setTime(int position, Date date) { setParameter(position, date, Hibernate.TIME); } - /* - * @see QueryTranslator#setTimestamp(int, Date) - */ public void setTimestamp(int position, Date date) { setParameter(position, date, Hibernate.TIMESTAMP); } - /* - * @see QueryTranslator#setEntity(int, Object) - */ public void setEntity(int position, Object val) { setParameter( position, val, Hibernate.association( val.getClass() ) ); } - /* - * @see QueryTranslator#setEnum(int, Object) - */ public void setEnum(int position, Object val) throws MappingException { setParameter( position, val, Hibernate.enum( val.getClass() ) ); } - /* - * @see QueryTranslator#setLocale(int, Locale) - */ public void setLocale(int position, Locale locale) { setParameter(position, locale, Hibernate.LOCALE); --- 100,167 ---- *************** *** 241,317 **** setParameter(position, calendar, Hibernate.CALENDAR_DATE); } ! /* ! * @see Query#setBinary(String, byte[]) ! */ public void setBinary(String name, byte[] val) { setParameter(name, val, Hibernate.BINARY); } - /* - * @see Query#setBoolean(String, boolean) - */ public void setBoolean(String name, boolean val) { setParameter(name, new Boolean(val), Hibernate.BOOLEAN); } - /* - * @see Query#setByte(String, byte) - */ public void setByte(String name, byte val) { setParameter(name, new Byte(val), Hibernate.BYTE); } - /* - * @see Query#setCharacter(String, char) - */ public void setCharacter(String name, char val) { setParameter(name, new Character(val), Hibernate.CHARACTER); } - /* - * @see Query#setDate(String, Date) - */ public void setDate(String name, Date date) { setParameter(name, date, Hibernate.DATE); } - /* - * @see Query#setDouble(String, double) - */ public void setDouble(String name, double val) { setParameter(name, new Double(val), Hibernate.DOUBLE); } - /* - * @see Query#setEntity(String, Object) - */ public void setEntity(String name, Object val) { setParameter( name, val, Hibernate.association( val.getClass() ) ); } - /* - * @see Query#setEnum(String, Object) - */ public void setEnum(String name, Object val) throws MappingException { setParameter( name, val, Hibernate.enum( val.getClass() ) ); } - /* - * @see Query#setFloat(String, long) - */ public void setFloat(String name, float val) { setParameter(name, new Float(val), Hibernate.FLOAT); } - /* - * @see Query#setInteger(String, int) - */ public void setInteger(String name, int val) { setParameter(name, new Integer(val), Hibernate.INTEGER); } - /* - * @see Query#setLocale(String, Locale) - */ public void setLocale(String name, Locale locale) { setParameter(name, locale, Hibernate.LOCALE); --- 175,219 ---- setParameter(position, calendar, Hibernate.CALENDAR_DATE); } ! public void setBinary(String name, byte[] val) { setParameter(name, val, Hibernate.BINARY); } public void setBoolean(String name, boolean val) { setParameter(name, new Boolean(val), Hibernate.BOOLEAN); } public void setByte(String name, byte val) { setParameter(name, new Byte(val), Hibernate.BYTE); } public void setCharacter(String name, char val) { setParameter(name, new Character(val), Hibernate.CHARACTER); } public void setDate(String name, Date date) { setParameter(name, date, Hibernate.DATE); } public void setDouble(String name, double val) { setParameter(name, new Double(val), Hibernate.DOUBLE); } public void setEntity(String name, Object val) { setParameter( name, val, Hibernate.association( val.getClass() ) ); } public void setEnum(String name, Object val) throws MappingException { setParameter( name, val, Hibernate.enum( val.getClass() ) ); } public void setFloat(String name, float val) { setParameter(name, new Float(val), Hibernate.FLOAT); } public void setInteger(String name, int val) { setParameter(name, new Integer(val), Hibernate.INTEGER); } public void setLocale(String name, Locale locale) { setParameter(name, locale, Hibernate.LOCALE); *************** *** 326,402 **** } - /* - * @see Query#setLong(String, long) - */ public void setLong(String name, long val) { setParameter(name, new Long(val), Hibernate.LONG); } - /* - * @see Query#setParameter(String, Object, Type) - */ public void setParameter(String name, Object val, Type type) { namedParams.put(name, new TypedValue(type, val) ); } - /* - * @see Query#setSerializable(String, Serializable) - */ public void setSerializable(String name, Serializable val) { setParameter(name, val, Hibernate.SERIALIZABLE); } - /* - * @see Query#setShort(String, short) - */ public void setShort(String name, short val) { setParameter(name, new Short(val), Hibernate.SHORT); } - /* - * @see Query#setString(String, String) - */ public void setString(String name, String val) { setParameter(name, val, Hibernate.STRING); } - /* - * @see Query#setTime(String, Date) - */ public void setTime(String name, Date date) { setParameter(name, date, Hibernate.TIME); } - /* - * @see Query#setTimestamp(String, Date) - */ public void setTimestamp(String name, Date date) { setParameter(name, date, Hibernate.TIMESTAMP); } - /* - * @see cirrus.hibernate.Query#setBigDecimal(int, BigDecimal) - */ public void setBigDecimal(int position, BigDecimal number) { setParameter(position, number, Hibernate.BIG_DECIMAL); } - /* - * @see cirrus.hibernate.Query#setBigDecimal(String, BigDecimal) - */ public void setBigDecimal(String name, BigDecimal number) { setParameter(name, number, Hibernate.BIG_DECIMAL); } - /* - * @see Query#setParameter(int, Object) - */ public void setParameter(int position, Object val) throws HibernateException { setParameter( position, val, guessType(val) ); } - /* - * @see Query#setParameter(String, Object) - */ public void setParameter(String name, Object val) throws HibernateException { setParameter( name, val, guessType(val) ); --- 228,271 ---- *************** *** 405,408 **** --- 274,281 ---- private Type guessType(Object param) throws HibernateException { Class clazz = param.getClass(); + return guessType(clazz); + } + + private Type guessType(Class clazz) throws HibernateException { String typename = clazz.getName(); Type type = TypeFactory.hueristicType(typename); *************** *** 424,432 **** } ! /* ! * @see cirrus.hibernate.Query#setParameterList(String, Collection, Type) ! */ ! public void setParameterList(String name, Collection vals, Type type) ! throws HibernateException { StringBuffer list = new StringBuffer(16); --- 297,301 ---- } ! public void setParameterList(String name, Collection vals, Type type) throws HibernateException { StringBuffer list = new StringBuffer(16); *************** *** 442,450 **** } - /* - * @see cirrus.hibernate.Query#setParameterList(String, Collection, Type) - */ public void setParameterList(String name, Collection vals) throws HibernateException { setParameterList(name, vals, guessType( vals.iterator().next() ) ); } --- 311,333 ---- } public void setParameterList(String name, Collection vals) throws HibernateException { setParameterList(name, vals, guessType( vals.iterator().next() ) ); + } + + public String[] getNamedParameters() throws HibernateException { + return ArrayHelper.toStringArray( session.getFactory().getNamedParameters(queryString) ); + } + + public void setProperties(Object bean) throws HibernateException { + Class clazz = bean.getClass(); + Iterator iter = session.getFactory().getNamedParameters(queryString).iterator(); + while ( iter.hasNext() ) { + String namedParam = (String) iter.next(); + try { + ReflectHelper.Getter getter = ReflectHelper.getGetter(clazz, namedParam); + setParameter( namedParam, getter.get(bean), guessType( getter.getReturnType() ) ); + } + catch (PropertyNotFoundException pnfe) {} + } } |
From: <one...@us...> - 2002-12-28 02:25:51
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/query In directory sc8-pr-cvs1:/tmp/cvs-serv21213/cirrus/hibernate/query Modified Files: QueryTranslator.java Log Message: added support for <joined-subclass> to CodeGenerator added Query.getNamedParameters(), Query.setProperties() fixed a bug in Query.getReturnTypes() Index: QueryTranslator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/query/QueryTranslator.java,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** QueryTranslator.java 25 Nov 2002 07:25:20 -0000 1.51 --- QueryTranslator.java 28 Dec 2002 02:25:49 -0000 1.52 *************** *** 1,9 **** //$Id$ package cirrus.hibernate.query; ! import java.io.Serializable; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; --- 1,11 ---- //$Id$ package cirrus.hibernate.query; ! ! import java.io.Serializable; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; + import java.util.Collection; import java.util.HashMap; import java.util.HashSet; *************** *** 284,293 **** } else { ! try { ! return (Queryable) factory.getPersister(typeName); ! } ! catch (MappingException me) { ! throw new QueryException( "persistent class not found: " + typeName ); ! } } } --- 286,292 ---- } else { ! Queryable persister = getPersister(typeName); ! if (persister==null) throw new QueryException( "persistent class not found: " + typeName ); ! return persister; } } *************** *** 417,420 **** --- 416,423 ---- } + public Collection getNamedParameters() { + return namedParameters.keySet(); + } + public static String scalarName(int x, int y) { return new StringBuffer().append('x').append(x).append('_').append(y).append('_').toString(); *************** *** 882,910 **** else if (check) { check = false; ! Class clazz=null; ! try { ! clazz = ReflectHelper.classForName(token); ! } ! catch (Exception e) { ! String[] imports = factory.getImports(); ! for (int i=0; i<imports.length; i++) { ! try { ! clazz=ReflectHelper.classForName( imports[i] + '.' + token ); ! } ! catch (Exception ex) {} ! if (clazz!=null) break; } - if (clazz==null) continue; - } - String[] implementors = factory.getImplementors(clazz); - String placeholder = "$clazz" + count + "$"; - query = StringHelper.replaceOnce(query, token, placeholder); - if ( implementors!=null ) { - placeholders.add(placeholder); - replacements.add(implementors); } } } return StringHelper.multiply( query, placeholders.iterator(), replacements.iterator() ); } --- 885,917 ---- else if (check) { check = false; ! Class clazz= getImportedClass(token, factory); ! if (clazz!=null) { ! String[] implementors = factory.getImplementors(clazz); ! String placeholder = "$clazz" + count + "$"; ! query = StringHelper.replaceOnce(query, token, placeholder); ! if ( implementors!=null ) { ! placeholders.add(placeholder); ! replacements.add(implementors); } } } } return StringHelper.multiply( query, placeholders.iterator(), replacements.iterator() ); + } + + private static Class getImportedClass(String name, SessionFactoryImplementor factory) { + try { + return ReflectHelper.classForName(name); + } + catch (Exception e) { + String[] imports = factory.getImports(); + for (int i=0; i<imports.length; i++) { + try { + return ReflectHelper.classForName( imports[i] + '.' + name ); + } + catch (Exception ex) {} + } + return null; + } } |
From: <one...@us...> - 2002-12-28 02:25:51
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv21213/cirrus/hibernate/test Modified Files: SQLFunctionsTest.java FooBarTest.java Log Message: added support for <joined-subclass> to CodeGenerator added Query.getNamedParameters(), Query.setProperties() fixed a bug in Query.getReturnTypes() Index: SQLFunctionsTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/SQLFunctionsTest.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** SQLFunctionsTest.java 27 Dec 2002 11:54:47 -0000 1.35 --- SQLFunctionsTest.java 28 Dec 2002 02:25:48 -0000 1.36 *************** *** 20,23 **** --- 20,37 ---- } + public void testSetProperties() throws Exception { + Session s = sessions.openSession(); + Transaction t = s.beginTransaction(); + Simple simple = new Simple(); + simple.setName("Simple 1"); + s.save(simple, new Long(10) ); + Query q = s.createQuery("from s in class Simple where s.name=:name and s.count=:count"); + q.setProperties(simple); + assertTrue( q.list().get(0)==simple ); + s.delete(simple); + t.commit(); + s.close(); + } + public void testSQLFunctions() throws Exception { Session s = sessions.openSession(); Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/FooBarTest.java,v retrieving revision 1.236 retrieving revision 1.237 diff -C2 -d -r1.236 -r1.237 *** FooBarTest.java 27 Dec 2002 11:54:47 -0000 1.236 --- FooBarTest.java 28 Dec 2002 02:25:48 -0000 1.237 *************** *** 911,914 **** --- 911,918 ---- assertTrue( s.find("from n0 in class Named, n1 in class Named where n0.name = n1.name").size()==7 ); + Query qu = s.createQuery("from n in class Named where n.name = :name"); + qu.getReturnTypes(); + qu.getNamedParameters(); + iter = s.iterate("from o in class java.lang.Object"); int c = 0; *************** *** 1608,1612 **** s.save( new Foo() ); s.save( new Bar() ); ! ScrollableResults iter = s.createQuery("select f, f.integer from f in class Foo").scroll(); assertTrue( iter.next() ); assertTrue( iter.scroll(1) ); --- 1612,1618 ---- s.save( new Foo() ); s.save( new Bar() ); ! Query query = s.createQuery("select f, f.integer from f in class Foo"); ! assertTrue( query.getReturnTypes().length==2 ); ! ScrollableResults iter = query.scroll(); assertTrue( iter.next() ); assertTrue( iter.scroll(1) ); |
From: <one...@us...> - 2002-12-28 02:25:51
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen In directory sc8-pr-cvs1:/tmp/cvs-serv21213/cirrus/hibernate/tools/codegen Modified Files: ClassMapping.java Log Message: added support for <joined-subclass> to CodeGenerator added Query.getNamedParameters(), Query.setProperties() fixed a bug in Query.getReturnTypes() Index: ClassMapping.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen/ClassMapping.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** ClassMapping.java 25 Dec 2002 04:44:02 -0000 1.19 --- ClassMapping.java 28 Dec 2002 02:25:48 -0000 1.20 *************** *** 196,199 **** --- 196,205 ---- } + for ( Iterator iter = classElement.getChildren("joined-subclass").iterator(); iter.hasNext(); ) { + Element subclass = (Element) iter.next(); + ClassMapping subclassMapping = new ClassMapping(name, subclass); + subclasses.add(subclassMapping); + } + //components |
From: <one...@us...> - 2002-12-28 02:25:51
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv21213/cirrus/hibernate Modified Files: Query.java Added Files: PropertyNotFoundException.java Log Message: added support for <joined-subclass> to CodeGenerator added Query.getNamedParameters(), Query.setProperties() fixed a bug in Query.getReturnTypes() --- NEW FILE: PropertyNotFoundException.java --- //$Id: PropertyNotFoundException.java,v 1.1 2002/12/28 02:25:48 oneovthafew Exp $ package cirrus.hibernate; /** * Indicates that an expected getter or setter method could not be * found on a class. */ public class PropertyNotFoundException extends MappingException { public PropertyNotFoundException(String msg, Throwable root) { super(msg, root); } public PropertyNotFoundException(Throwable root) { super(root); } public PropertyNotFoundException(String s) { super(s); } } Index: Query.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/Query.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Query.java 27 Dec 2002 11:54:48 -0000 1.17 --- Query.java 28 Dec 2002 02:25:48 -0000 1.18 *************** *** 53,61 **** public interface Query { /** ! * The Hibernate types of the query result set. * @return an array of types */ public Type[] getReturnTypes() throws HibernateException; /** * Return the query results as an <tt>Iterator</tt>. If the query * contains multiple results pre row, the results are returned in --- 53,66 ---- public interface Query { /** ! * Return the Hibernate types of the query result set. * @return an array of types */ public Type[] getReturnTypes() throws HibernateException; /** + * Return the names of all named parameters of the query. + * @return the parameter names, in no particular order + */ + public String[] getNamedParameters() throws HibernateException; + /** * Return the query results as an <tt>Iterator</tt>. If the query * contains multiple results pre row, the results are returned in *************** *** 167,170 **** --- 172,183 ---- */ public void setParameterList(String name, Collection vals) throws HibernateException; + + /** + * Bind the property values of the given bean to named parameters of the query, + * matching property names with parameter names and mapping property types to + * Hibernate types using hueristics. + * @param bean any JavaBean or POJO + */ + public void setProperties(Object bean) throws HibernateException; public void setString(int position, String val); |
From: <one...@us...> - 2002-12-28 02:25:51
|
Update of /cvsroot/hibernate/Hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv21213 Modified Files: changelog.txt Log Message: added support for <joined-subclass> to CodeGenerator added Query.getNamedParameters(), Query.setProperties() fixed a bug in Query.getReturnTypes() Index: changelog.txt =================================================================== RCS file: /cvsroot/hibernate/Hibernate/changelog.txt,v retrieving revision 1.290 retrieving revision 1.291 diff -C2 -d -r1.290 -r1.291 *** changelog.txt 27 Dec 2002 11:54:48 -0000 1.290 --- changelog.txt 28 Dec 2002 02:25:47 -0000 1.291 *************** *** 13,17 **** * fixed a bug introduced in 1.2 final where cascade save-update was sometimes ignored for readonly="true" bags * fixed a bug caching null-valued one-to-one associations ! * CodeGenerator now supports <bag> * fixed problem with TimestampType on DB2 (Jonas) * fixed a bug in generated SQL for collections with <joined-subclass> mappings (Robson Miranda) --- 13,17 ---- * fixed a bug introduced in 1.2 final where cascade save-update was sometimes ignored for readonly="true" bags * fixed a bug caching null-valued one-to-one associations ! * CodeGenerator now supports <bag> and <joined-subclass> * fixed problem with TimestampType on DB2 (Jonas) * fixed a bug in generated SQL for collections with <joined-subclass> mappings (Robson Miranda) *************** *** 22,25 **** --- 22,26 ---- * added Query.setTimeout() * setMaxResults() now behaves sensibly on SAPDB (Russel Smyth) + * added Query.setProperties() and Query.getNamedParameters(), fixed a bug in Query.getReturnTypes() Changes in version 1.2 final (7.12.2002) |
From: <one...@us...> - 2002-12-27 11:54:52
|
Update of /cvsroot/hibernate/Hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv2878 Modified Files: hibernate.properties changelog.txt Log Message: added validation settings to DBCP + C3P0 connection providers added Query.setTimeout() got tests working Index: hibernate.properties =================================================================== RCS file: /cvsroot/hibernate/Hibernate/hibernate.properties,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** hibernate.properties 8 Dec 2002 05:58:58 -0000 1.95 --- hibernate.properties 27 Dec 2002 11:54:48 -0000 1.96 *************** *** 174,177 **** --- 174,178 ---- #hibernate.c3p0.timeout 5000 #hibernate.c3p0.max_statements 100 + #hibernate.c3p0.validate false *************** *** 194,197 **** --- 195,202 ---- #hibernate.dbcp.ps.maxWait 120000 #hibernate.dbcp.ps.maxIdle 100 + + # optional query to validate pooled connections: + + #hibernate.dbcp.validationQuery select 1 from dual Index: changelog.txt =================================================================== RCS file: /cvsroot/hibernate/Hibernate/changelog.txt,v retrieving revision 1.289 retrieving revision 1.290 diff -C2 -d -r1.289 -r1.290 *** changelog.txt 25 Dec 2002 07:34:19 -0000 1.289 --- changelog.txt 27 Dec 2002 11:54:48 -0000 1.290 *************** *** 18,21 **** --- 18,25 ---- * fixed a bug caching Maps (Benoit Menendez) * SchemaExport now accepts a .jar file as a source of mappings + * hibernate.dbcp.validationQuery setting (Juozas Baliuka) + * hibernate.c3p0.validate setting + * added Query.setTimeout() + * setMaxResults() now behaves sensibly on SAPDB (Russel Smyth) Changes in version 1.2 final (7.12.2002) |
From: <one...@us...> - 2002-12-27 11:54:52
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/connection In directory sc8-pr-cvs1:/tmp/cvs-serv2878/cirrus/hibernate/connection Modified Files: DBCPConnectionProvider.java C3P0ConnectionProvider.java Log Message: added validation settings to DBCP + C3P0 connection providers added Query.setTimeout() got tests working Index: DBCPConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/connection/DBCPConnectionProvider.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DBCPConnectionProvider.java 23 Nov 2002 00:24:17 -0000 1.5 --- DBCPConnectionProvider.java 27 Dec 2002 11:54:48 -0000 1.6 *************** *** 114,118 **** // the "real" Connections created by the ConnectionFactory with // the classes that implement the pooling functionality. ! new PoolableConnectionFactory(connectionFactory, connectionPool, statementPool, null, false, false); // Finally, we create the PoolingDriver itself, --- 114,119 ---- // the "real" Connections created by the ConnectionFactory with // the classes that implement the pooling functionality. ! String validationQuery = props.getProperty(Environment.DBCP_VALIDATION_QUERY); ! new PoolableConnectionFactory(connectionFactory, connectionPool, statementPool, validationQuery, false, false); // Finally, we create the PoolingDriver itself, Index: C3P0ConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/connection/C3P0ConnectionProvider.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** C3P0ConnectionProvider.java 23 Nov 2002 00:24:17 -0000 1.17 --- C3P0ConnectionProvider.java 27 Dec 2002 11:54:48 -0000 1.18 *************** *** 85,88 **** --- 85,89 ---- int maxIdleTime = PropertiesHelper.getInt(Environment.C3P0_TIMEOUT, props, 0); int maxStatements = PropertiesHelper.getInt(Environment.C3P0_MAX_STATEMENTS, props, 0); + boolean validateConnection = PropertiesHelper.getBoolean(Environment.C3P0_VALIDATE_CONNECTION, props); PoolConfig pcfg = new PoolConfig(); *************** *** 92,102 **** pcfg.setMaxIdleTime(maxIdleTime); pcfg.setMaxStatements(maxStatements); ! ! /* ! * you probabably DON'T want to uncomment ! * the next line -- it really slows down ! * Connection acquisiton. ! */ ! //pcfg.setTestConnectionOnCheckout( true ); /*DataSource unpooled = DataSources.unpooledDataSource( --- 93,97 ---- pcfg.setMaxIdleTime(maxIdleTime); pcfg.setMaxStatements(maxStatements); ! pcfg.setTestConnectionOnCheckout(validateConnection); /*DataSource unpooled = DataSources.unpooledDataSource( |
From: <one...@us...> - 2002-12-27 11:54:51
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv2878/cirrus/hibernate Modified Files: Query.java Environment.java Log Message: added validation settings to DBCP + C3P0 connection providers added Query.setTimeout() got tests working Index: Query.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/Query.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Query.java 24 Nov 2002 06:30:11 -0000 1.16 --- Query.java 27 Dec 2002 11:54:48 -0000 1.17 *************** *** 111,114 **** --- 111,120 ---- /** + * Set a timeout for the underlying JDBC query. + * @param timeout the timeout in seconds + */ + public void setTimeout(int timeout); + + /** * Bind a value to a JDBC-style query parameter. * @param position the position of the parameter in the query Index: Environment.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/Environment.java,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** Environment.java 15 Dec 2002 05:12:40 -0000 1.79 --- Environment.java 27 Dec 2002 11:54:48 -0000 1.80 *************** *** 38,44 **** public final class Environment { ! private static final String VERSION = "1.2.1"; ! /** * <tt>ConnectionProvider</tt> implementor to use when obtaining connections --- 38,44 ---- public final class Environment { ! private static final String VERSION = "1.2.1"; ! /** * <tt>ConnectionProvider</tt> implementor to use when obtaining connections *************** *** 77,86 **** */ public static final String CONNECTION_PREFIX = "hibernate.connection"; ! /** * Maximum size for Hibernate's statement cache */ public static final String STATEMENT_CACHE_SIZE ="hibernate.statement_cache.size"; ! /** * JNDI initial context class, <tt>Context.INITIAL_CONTEXT_FACTORY</tt> --- 77,86 ---- */ public static final String CONNECTION_PREFIX = "hibernate.connection"; ! /** * Maximum size for Hibernate's statement cache */ public static final String STATEMENT_CACHE_SIZE ="hibernate.statement_cache.size"; ! /** * JNDI initial context class, <tt>Context.INITIAL_CONTEXT_FACTORY</tt> *************** *** 95,99 **** */ public static final String SESSION_FACTORY_NAME = "hibernate.session_factory_name"; ! /** * Hibernate SQL <tt>Dialect</tt> class --- 95,99 ---- */ public static final String SESSION_FACTORY_NAME = "hibernate.session_factory_name"; ! /** * Hibernate SQL <tt>Dialect</tt> class *************** *** 104,108 **** */ public static final String DEFAULT_SCHEMA = "hibernate.default_schema"; ! /** * Enable logging of generated SQL to the console --- 104,108 ---- */ public static final String DEFAULT_SCHEMA = "hibernate.default_schema"; ! /** * Enable logging of generated SQL to the console *************** *** 131,140 **** */ public static final String STATEMENT_BATCH_SIZE = "hibernate.jdbc.batch_size"; ! /** * An XSLT resource used to generate "custom" XML */ public static final String OUTPUT_STYLESHEET ="hibernate.xml.output_stylesheet"; ! /** * Maximum size of C3P0 connection pool --- 131,140 ---- */ public static final String STATEMENT_BATCH_SIZE = "hibernate.jdbc.batch_size"; ! /** * An XSLT resource used to generate "custom" XML */ public static final String OUTPUT_STYLESHEET ="hibernate.xml.output_stylesheet"; ! /** * Maximum size of C3P0 connection pool *************** *** 152,157 **** * Maximum size of C3P0 statement cache */ ! public static final String C3P0_MAX_STATEMENTS = "hibernate.c3p0.max_statements"; ! /** * Maximum number of checked out connections for DBCP connection pool --- 152,161 ---- * Maximum size of C3P0 statement cache */ ! public static final String C3P0_MAX_STATEMENTS = "hibernate.c3p0.max_statements"; ! /** ! * Should we validate the connection on checkout? (optional) ! */ ! public static final String C3P0_VALIDATE_CONNECTION = "hibernate.c3p0.validate"; ! /** * Maximum number of checked out connections for DBCP connection pool *************** *** 171,174 **** --- 175,182 ---- public static final String DBCP_WHENEXHAUSTED = "hibernate.dbcp.whenExhaustedAction"; /** + * Query to execute for connection validation (optional) + */ + public static final String DBCP_VALIDATION_QUERY = "hibernate.dbcp.validationQuery"; + /** * Maximum number of checked out statements for DBCP */ *************** *** 199,203 **** */ public static final String USER_TRANSACTION = "jta.UserTransaction"; ! /** * A comma-seperated list of token substitutions to use when translating a Hibernate --- 207,211 ---- */ public static final String USER_TRANSACTION = "jta.UserTransaction"; ! /** * A comma-seperated list of token substitutions to use when translating a Hibernate *************** *** 211,215 **** //Obsolete properties: ! private static final String OUTPUT_STYLESHEET_OLD ="hibernate.output_stylesheet"; private static final String CONNECTION_PROVIDER_OLD ="hibernate.connection_provider"; --- 219,223 ---- //Obsolete properties: ! private static final String OUTPUT_STYLESHEET_OLD ="hibernate.output_stylesheet"; private static final String CONNECTION_PROVIDER_OLD ="hibernate.connection_provider"; *************** *** 239,245 **** private static final HashMap isolationLevels = new HashMap(); private static final Map obsoleteProperties = new HashMap(); ! private static final Log log = LogFactory.getLog(Environment.class); ! /** * Issues warnings to the user when any obsolete property names are used. --- 247,253 ---- private static final HashMap isolationLevels = new HashMap(); private static final Map obsoleteProperties = new HashMap(); ! private static final Log log = LogFactory.getLog(Environment.class); ! /** * Issues warnings to the user when any obsolete property names are used. *************** *** 255,261 **** static { ! log.info("Hibernate " + VERSION); ! isolationLevels.put( new Integer(Connection.TRANSACTION_NONE), "NONE" ); isolationLevels.put( new Integer(Connection.TRANSACTION_READ_UNCOMMITTED), "READ_UNCOMMITTED" ); --- 263,269 ---- static { ! log.info("Hibernate " + VERSION); ! isolationLevels.put( new Integer(Connection.TRANSACTION_NONE), "NONE" ); isolationLevels.put( new Integer(Connection.TRANSACTION_READ_UNCOMMITTED), "READ_UNCOMMITTED" ); *************** *** 263,267 **** isolationLevels.put( new Integer(Connection.TRANSACTION_REPEATABLE_READ), "REPEATABLE_READ" ); isolationLevels.put( new Integer(Connection.TRANSACTION_SERIALIZABLE), "SERIALIZABLE" ); ! obsoleteProperties.put(CONNECTION_PROVIDER_OLD, CONNECTION_PROVIDER); obsoleteProperties.put(DRIVER_OLD, DRIVER); --- 271,275 ---- isolationLevels.put( new Integer(Connection.TRANSACTION_REPEATABLE_READ), "REPEATABLE_READ" ); isolationLevels.put( new Integer(Connection.TRANSACTION_SERIALIZABLE), "SERIALIZABLE" ); ! obsoleteProperties.put(CONNECTION_PROVIDER_OLD, CONNECTION_PROVIDER); obsoleteProperties.put(DRIVER_OLD, DRIVER); *************** *** 295,301 **** } } ! properties.putAll( System.getProperties() ); ! verifyProperties(properties); --- 303,309 ---- } } ! properties.putAll( System.getProperties() ); ! verifyProperties(properties); *************** *** 314,318 **** log.info("JVM proxy support: " + proxySupport); jvmSupportsProxies = proxySupport; ! boolean linkedHashSupport; try { --- 322,326 ---- log.info("JVM proxy support: " + proxySupport); jvmSupportsProxies = proxySupport; ! boolean linkedHashSupport; try { *************** *** 328,332 **** /** ! * Does this JVM support dynamic proxies? (Now return true because CGLIB * proxies work on all supported JDK) */ --- 336,340 ---- /** ! * Does this JVM support dynamic proxies? (Now return true because CGLIB * proxies work on all supported JDK) */ *************** *** 334,338 **** return true;//jvmSupportsProxies; } ! /** * Does this JVM support <tt>LinkedHashSet</tt>, <tt>LinkedHashMap</tt>? --- 342,346 ---- return true;//jvmSupportsProxies; } ! /** * Does this JVM support <tt>LinkedHashSet</tt>, <tt>LinkedHashMap</tt>? *************** *** 362,369 **** return properties; } ! /** * Get the name of a JDBC transaction isolation level ! * * @see java.sql.Connection * @param isolation as defined by <tt>java.sql.Connection</tt> --- 370,377 ---- return properties; } ! /** * Get the name of a JDBC transaction isolation level ! * * @see java.sql.Connection * @param isolation as defined by <tt>java.sql.Connection</tt> |
From: <one...@us...> - 2002-12-27 11:54:51
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader In directory sc8-pr-cvs1:/tmp/cvs-serv2878/cirrus/hibernate/loader Modified Files: Loader.java Log Message: added validation settings to DBCP + C3P0 connection providers added Query.setTimeout() got tests working Index: Loader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/Loader.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** Loader.java 24 Dec 2002 13:45:37 -0000 1.32 --- Loader.java 27 Dec 2002 11:54:48 -0000 1.33 *************** *** 418,421 **** --- 418,423 ---- try { + if (selection!=null && selection.timeout!=null) st.setQueryTimeout( selection.timeout.intValue() ); + int col=1; for ( int i=0; i<values.length; i++) { |
From: <one...@us...> - 2002-12-27 11:54:51
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv2878/cirrus/hibernate/test Modified Files: SQLFunctionsTest.java MultiTableTest.java FooBarTest.java FooBar.hbm.xml Log Message: added validation settings to DBCP + C3P0 connection providers added Query.setTimeout() got tests working Index: SQLFunctionsTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/SQLFunctionsTest.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** SQLFunctionsTest.java 24 Dec 2002 13:45:38 -0000 1.34 --- SQLFunctionsTest.java 27 Dec 2002 11:54:47 -0000 1.35 *************** *** 9,13 **** import cirrus.hibernate.sql.InterbaseDialect; import cirrus.hibernate.sql.MySQLDialect; - import cirrus.hibernate.sql.SAPDBDialect; import cirrus.hibernate.sql.SybaseDialect; --- 9,12 ---- Index: MultiTableTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/MultiTableTest.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** MultiTableTest.java 25 Dec 2002 06:47:11 -0000 1.20 --- MultiTableTest.java 27 Dec 2002 11:54:47 -0000 1.21 *************** *** 244,247 **** --- 244,248 ---- s.flush(); s.connection().commit(); + s.close(); s = sessions.openSession(); s.load(LessSimple.class, id); Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/FooBarTest.java,v retrieving revision 1.235 retrieving revision 1.236 diff -C2 -d -r1.235 -r1.236 *** FooBarTest.java 26 Dec 2002 03:35:08 -0000 1.235 --- FooBarTest.java 27 Dec 2002 11:54:47 -0000 1.236 *************** *** 449,453 **** s.close(); } ! public void testUpdate() throws Exception { Session s = sessions.openSession(); Foo foo = new Foo(); --- 449,454 ---- s.close(); } ! ! public void testUpdate() throws Exception { Session s = sessions.openSession(); Foo foo = new Foo(); Index: FooBar.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/FooBar.hbm.xml,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** FooBar.hbm.xml 26 Dec 2002 03:35:08 -0000 1.18 --- FooBar.hbm.xml 27 Dec 2002 11:54:47 -0000 1.19 *************** *** 44,54 **** </many-to-one> <property name="long"> ! <column name="long_" index="fbmtoidx" unique-key="abc"/> </property> <property name="integer"> ! <column name="integer_" unique-key="abc"/> </property> <property name="float"> ! <column name="float_" unique-key="abc"/> </property> <property name="double" column="double_"/> --- 44,54 ---- </many-to-one> <property name="long"> ! <column name="long_" index="fbmtoidx" unique-key="abc" not-null="true"/> </property> <property name="integer"> ! <column name="integer_" unique-key="abc" not-null="true"/> </property> <property name="float"> ! <column name="float_" unique-key="abc" not-null="true"/> </property> <property name="double" column="double_"/> |
From: <one...@us...> - 2002-12-27 11:54:51
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv2878/cirrus/hibernate/impl Modified Files: QueryImpl.java Log Message: added validation settings to DBCP + C3P0 connection providers added Query.setTimeout() got tests working Index: QueryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl/QueryImpl.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** QueryImpl.java 14 Dec 2002 09:27:55 -0000 1.20 --- QueryImpl.java 27 Dec 2002 11:54:48 -0000 1.21 *************** *** 54,57 **** --- 54,58 ---- public Integer firstRow; public Integer maxRows; + public Integer timeout; } *************** *** 82,85 **** --- 83,90 ---- public void setMaxResults(int maxResults) { selection.maxRows = new Integer(maxResults); + } + + public void setTimeout(int timeout) { + selection.timeout = new Integer(timeout); } |