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...> - 2003-01-16 20:52:41
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/ddl2hbm In directory sc8-pr-cvs1:/tmp/cvs-serv8417/net/sf/hibernate/tool/ddl2hbm Modified Files: MapGenerator.java Log Message: applied Max Andersen's patch for <meta>attributes in hbm2java Index: MapGenerator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/ddl2hbm/MapGenerator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MapGenerator.java 5 Jan 2003 02:11:23 -0000 1.3 --- MapGenerator.java 16 Jan 2003 20:52:38 -0000 1.4 *************** *** 16,19 **** --- 16,20 ---- import javax.xml.transform.stream.*; + import org.apache.commons.collections.MultiHashMap; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; *************** *** 89,95 **** ClassName cName = new ClassName(); cName.setFullyQualifiedName(getBaseClass()); ! cmap = new ClassMapping(cName, jdomBuilder.build(classElement)); } ! else cmap = new ClassMapping(jdomBuilder.build(classElement)); map.put(cmap.getCanonicalName(), cmap); } --- 90,96 ---- ClassName cName = new ClassName(); cName.setFullyQualifiedName(getBaseClass()); ! cmap = new ClassMapping(cName, jdomBuilder.build(classElement), new MultiHashMap()); } ! else cmap = new ClassMapping(jdomBuilder.build(classElement), new MultiHashMap()); map.put(cmap.getCanonicalName(), cmap); } |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java In directory sc8-pr-cvs1:/tmp/cvs-serv8417/net/sf/hibernate/tool/hbm2java Modified Files: BasicRenderer.java ClassMapping.java ClassName.java CodeGenerator.java Field.java Generator.java Log Message: applied Max Andersen's patch for <meta>attributes in hbm2java Index: BasicRenderer.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java/BasicRenderer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BasicRenderer.java 5 Jan 2003 02:11:24 -0000 1.3 --- BasicRenderer.java 16 Jan 2003 20:52:38 -0000 1.4 *************** *** 3,6 **** --- 3,8 ---- import java.io.PrintWriter; + import java.io.StringWriter; + import java.util.Collection; import java.util.Iterator; import java.util.List; *************** *** 8,13 **** import java.util.TreeSet; public class BasicRenderer implements Renderer { ! /** * Returns the true name for the given class name. By true name is --- 10,20 ---- import java.util.TreeSet; + import org.apache.commons.lang.StringUtils; + import org.apache.commons.logging.Log; + import org.apache.commons.logging.LogFactory; + public class BasicRenderer implements Renderer { ! ! static private Log log = LogFactory.getLog(BasicRenderer.class); /** * Returns the true name for the given class name. By true name is *************** *** 19,269 **** */ String getTrueTypeName(Field field, Map class2classmap) { ! String name = ( field.getClassType()!=null ) ? ! field.getClassType().getFullyQualifiedName(): ! field.getType(); ! ClassMapping cmap = (ClassMapping) class2classmap.get(name); ! ! if(cmap!=null) { ! if (cmap.getProxy()!=null) { ! return cmap.getProxy(); ! } ! } ! return name; ! } ! ! public void render(String className, ClassMapping classMapping, Map class2classmap, PrintWriter writer) throws Exception { ! if ( classMapping.getPackageName()!=null ) { ! writer.println("package " + classMapping.getPackageName() + ";"); ! } ! else { ! writer.println("// default package"); ! } ! writer.println(); ! ! // 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(); ! ! // class declaration ! writer.println("/** @author Hibernate CodeGenerator */"); ! writer.print( "public class " + classMapping.getName() ); ! ! // subclass ! if (classMapping.getSuperClass() != null) { ! writer.print( " extends " + classMapping.getSuperClass() ); ! } ! ! // always implements Serializable ! writer.print(" implements Serializable"); ! ! // implement proxy, but NOT if the proxy is the class it self! ! if ( ! classMapping.getProxy()!=null && ! ( !classMapping.getProxy().equals( classMapping.getCanonicalName() ) ) ! ) { ! writer.print(", "); ! writer.print( classMapping.getProxy() ); ! } ! writer.println(" {"); ! writer.println(); ! ! // 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(" }"); ! writer.println(); ! ! // no args constructor (if fullconstructor had any arguments!) ! if (allFieldsForFullConstructor.size() > 0) { ! writer.println(" /** default constructor */"); ! writer.println(" public " + classMapping.getName() + "() {"); ! writer.println(" }"); ! writer.println(); ! } ! ! // 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(); ! } ! ! // 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 ! writer.println(" public " + getTrueTypeName(field, class2classmap) + getterType + field.getAsSuffix() + "() {"); ! writer.println(" return this." + field.getName() + ";"); ! writer.println(" }"); ! writer.println(""); ! ! // setter ! writer.println(" public void set" + field.getAsSuffix() + "(" + getTrueTypeName(field, class2classmap) + " " + field.getName() + ") {"); ! writer.println(" this." + field.getName() + " = " + field.getName() + ";"); ! 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("}"); ! } ! /** ! * 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; ! } ! } ! } ! ! } ! ! ! ! --- 26,401 ---- */ String getTrueTypeName(Field field, Map class2classmap) { ! String name = ( field.getClassType()!=null ) ? ! field.getClassType().getFullyQualifiedName(): ! field.getType(); ! ClassMapping cmap = (ClassMapping) class2classmap.get(name); ! ! if(cmap!=null) { ! if (cmap.getProxy()!=null) { ! return cmap.getProxy(); ! } ! } ! return name; ! } ! ! String getTrueTypeName(ClassName cn, Map class2classmap) { ! String name = cn.getFullyQualifiedName(); ! ClassMapping cmap = (ClassMapping) class2classmap.get(name); ! ! ! if(cmap!=null) { ! if (cmap.getProxy()!=null) { ! return cmap.getProxy(); ! } ! } ! return name; ! } ! ! ! public void render(String packageName, ClassMapping classMapping, Map class2classmap, PrintWriter mainwriter) throws Exception { ! if ( classMapping.getGeneratedPackageName()!=null ) { ! mainwriter.println("package " + classMapping.getGeneratedPackageName() + ";"); ! } ! else { ! mainwriter.println("// default package"); ! } ! mainwriter.println(); ! ! // switch to another writer to be able to insert the actually ! // used imports when whole class has been rendered. ! StringWriter strWriter = new StringWriter(); ! PrintWriter writer = new PrintWriter(strWriter); ! ! ! // class declaration ! if(classMapping.getMeta("description")==null) { ! writer.println("/** @author Hibernate CodeGenerator */"); ! } else { ! writer.println("/** \n" + toJavaDoc(classMapping.getMetaAsString("description"),0) + "*/"); ! } ! ! String classScope = "public"; ! if(classMapping.getMeta("scope-class")!=null) { ! classScope = classMapping.getMetaAsString("scope-class").trim(); ! } ! if(classMapping.shouldBeAbstract()) { ! writer.print( "abstract " + classScope + " class " + classMapping.getGeneratedName() ); ! } else { ! writer.print( classScope + " class " + classMapping.getGeneratedName() ); ! } ! ! // subclass ! if (classMapping.getSuperClass() != null) { ! writer.print( " extends " + classMapping.getSuperClass() ); ! } else if (classMapping.getMeta("extends")!=null) { ! writer.print( " extends " + classMapping.getMetaAsString("extends")); ! } ! ! // always implements Serializable ! writer.print(" implements Serializable"); ! ! // implement proxy, but NOT if the proxy is the class it self! ! if ( ! classMapping.getProxy()!=null && ! ( !classMapping.getProxy().equals( classMapping.getCanonicalName() ) ) ! ) { ! writer.print(", "); ! writer.print( classMapping.getProxy() ); ! } ! ! if(classMapping.getMeta("implements")!=null) { ! Collection implementz = classMapping.getMeta("implements"); ! for (Iterator iter = implementz.iterator(); iter.hasNext();) { ! String iface = (String) iter.next(); ! writer.print(", "); ! writer.print(iface); ! } ! } ! ! writer.println(" {"); ! writer.println(); ! ! // fields ! for ( Iterator fields = classMapping.getFields().iterator(); fields.hasNext(); ) { ! Field field = (Field) fields.next(); ! ! String fieldScope = getFieldScope(field, "property-scope", "scope-field"); ! writer.println( ! " /** " + ! ( field.isNullable() && !field.isIdentifier() ? "nullable " : "" ) + ! ( field.isIdentifier() ? "identifier" : "persistent" ) ! + " field */"); ! writer.println( ! " " + fieldScope + " " + ! shortenType( field.getType(), classMapping.getImports() ) + ! ' ' + ! field.getName() + ! ';' ! ); ! ! writer.println(); ! } ! ! // full constructor ! List allFieldsForFullConstructor = classMapping.getAllFieldsForFullConstructor(); ! ! writer.println(" /** full constructor */"); ! String fullCons = " public " + classMapping.getGeneratedName() + "("; ! ! ! 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(" }"); ! writer.println(); ! ! // no args constructor (if fullconstructor had any arguments!) ! if (allFieldsForFullConstructor.size() > 0) { ! writer.println(" /** default constructor */"); ! writer.println(" public " + classMapping.getGeneratedName() + "() {"); ! writer.println(" }"); ! writer.println(); ! } ! ! // 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.getGeneratedName() + "("; ! 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(); ! } ! ! ! doFieldAccessors(classMapping, class2classmap, writer); ! ! 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 " + classMapping.getGeneratedName() + ") ) return false;"); ! writer.println(" " + classMapping.getGeneratedName() + " castOther = (" + classMapping.getGeneratedName() + ") 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("}"); ! ! ! // finally write the imports ! doImports(classMapping, mainwriter); ! mainwriter.print(strWriter.toString()); ! ! ! } + public void doFieldAccessors(ClassMapping classMapping, Map class2classmap, PrintWriter writer) { + // field accessors + for (Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { + Field field = (Field) fields.next(); + + // getter + String getAccessScope = getFieldScope(field, "scope", "scope-get"); + String getterType = ( field.getType().toLowerCase().equals("boolean") ) ? " is" : " get"; + + if(field.getMeta("description")!=null) { + writer.println(" /** \n" + toJavaDoc(field.getMetaAsString("description"), 4) + " */"); + } + writer.println(" " + getAccessScope + " " + getTrueTypeName(field, class2classmap) + getterType + field.getAsSuffix() + "() {"); + writer.println(" return this." + field.getName() + ";"); + writer.println(" }"); + writer.println(""); + + // setter + String setAccessScope = getFieldScope(field, "scope", "scope-set"); + writer.println(" " + setAccessScope + " void set" + field.getAsSuffix() + "(" + getTrueTypeName(field, class2classmap) + " " + field.getName() + ") {"); + writer.println(" this." + field.getName() + " = " + field.getName() + ";"); + writer.println(" }"); + writer.println(""); + + // add/remove'rs (commented out for now) + /* + if(field.getForeignClass()!=null) { + ClassName foreignClass = field.getForeignClass(); + + String trueforeign = getTrueTypeName(foreignClass, class2classmap); + classMapping.addImport(trueforeign); + + // Try to identify the matching set method on the child. + ClassMapping forignMap = (ClassMapping) class2classmap.get(foreignClass.getFullyQualifiedName()); + + if(forignMap!=null) { + Iterator foreignFields = forignMap.getFields().iterator(); + while (foreignFields.hasNext()) { + Field ffield = (Field) foreignFields.next(); + if(ffield.isIdentifier()) { + log.debug("Trying to match " + ffield.getName() + " with " + field.getForeignKeys()); + } + } + + } else { + log.error("Could not find foreign class's mapping - cannot provide bidirectional setters!"); + } + + String addAccessScope = getFieldScope(field, "scope", "scope-add"); + writer.println(" " + setAccessScope + " void add" + field.getAsSuffix() + "(" + shortenType(trueforeign, classMapping.getImports()) + " a" + field.getName() + ") {"); + writer.println(" this." + getterType + field.getAsSuffix() + "().add(a" + field.getName() + ");"); + writer.println(" a" + field.getName() + ".setXXX(this);"); + writer.println(" }"); + writer.println(""); + + + } + */ + } + + } + public void doImports(ClassMapping classMapping, PrintWriter writer) { + // 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(); + } + + public String getFieldScope(Field field, String defaultScopeName, String localScopeName) { + String defaultScope = ( field.getMeta(defaultScopeName)==null )? "public" : field.getMetaAsString(defaultScopeName); + String fieldScope = defaultScope; + if (field.getMeta(localScopeName) != null) { + fieldScope = field.getMetaAsString(localScopeName); + } + return fieldScope; + } + + /** + * Convert string into something that can be rendered nicely into a javadoc + * comment. + * Prefix each line with a star ('*'). + * @param string + */ + private String toJavaDoc(String string, int indent) { + StringBuffer result = new StringBuffer(); + + if(string!=null) { + String[] lines = StringUtils.split(string, "\n\r\f"); + for (int i = 0; i < lines.length; i++) { + String docline = " * " + lines[i] + "\n"; + result.append(StringUtils.leftPad(docline, docline.length() + indent)); + } + } + + return result.toString(); + } + + + /** + * 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/Hibernate2/src/net/sf/hibernate/tool/hbm2java/ClassMapping.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ClassMapping.java 5 Jan 2003 02:11:24 -0000 1.4 --- ClassMapping.java 16 Jan 2003 20:52:38 -0000 1.5 *************** *** 3,10 **** --- 3,13 ---- import java.util.ArrayList; + import java.util.Collection; import java.util.HashMap; + import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; + import java.util.Set; [...1148 lines suppressed...] + * @return boolean + */ + public boolean shouldBeAbstract() { + return shouldBeAbstract; + } + + // Based on some raw heuristics the following method validates the provided metaattribs. + void validateMetaAttribs() { + // Inform that "extends" is not used if this one is a genuine subclass + if(getSuperClass()!=null && getMeta("extends")!=null) { + log.warn("Warning: meta attribute extends='" + getMetaAsString("extends") + "' will be ignored for subclass " + name); + } + + + } + + + } Index: ClassName.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java/ClassName.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ClassName.java 5 Jan 2003 02:11:24 -0000 1.3 --- ClassName.java 16 Jan 2003 20:52:38 -0000 1.4 *************** *** 84,87 **** --- 84,91 ---- return isArray; } + + public String toString() { + return getFullyQualifiedName(); + } } Index: CodeGenerator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java/CodeGenerator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CodeGenerator.java 5 Jan 2003 02:11:24 -0000 1.3 --- CodeGenerator.java 16 Jan 2003 20:52:38 -0000 1.4 *************** *** 12,15 **** --- 12,20 ---- import java.util.Iterator; import java.util.List; + + import org.apache.commons.collections.MultiHashMap; + import org.apache.commons.collections.MultiMap; + import org.apache.commons.logging.Log; + import org.apache.commons.logging.LogFactory; import org.jdom.Document; import org.jdom.Element; *************** *** 23,101 **** */ public class CodeGenerator { ! ! public static void main(String[] args) { ! try { ! ArrayList mappingFiles = new ArrayList(); ! ! SAXBuilder builder = new SAXBuilder(); ! builder.setEntityResolver( new DTDEntityResolver() ); ! builder.setErrorHandler( new ErrorHandler() { ! public void error(SAXParseException error) { ! System.err.println( "Error parsing XML: " + error.getSystemId() + '(' + error.getLineNumber() + ')' ); ! error.printStackTrace(); ! } ! public void fatalError(SAXParseException error) { ! error(error); ! } ! public void warning(SAXParseException error) { ! System.err.println( "Warning parsing XML: " + error.getSystemId() + '(' + error.getLineNumber() + ')' ); ! } ! } ); ! ! String outputDir = null; ! ! List generators = new ArrayList(); ! ! // parse command line parameters ! for (int i = 0; i < args.length; i++) { ! if (args[i].startsWith("--")) { ! ! if ( args[i].startsWith("--config=") ) { ! // parse config xml file ! Document document = builder.build( new File( args[i].substring(9) ) ); ! Iterator generateElements = document.getRootElement().getChildren("generate").iterator(); ! ! while (generateElements.hasNext()) { ! generators.add( new Generator( (Element) generateElements.next() ) ); ! } ! } ! else if ( args[i].startsWith("--output=") ) { ! outputDir = args[i].substring(9); ! } ! ! } ! else { ! mappingFiles.add( args[i] ); ! } ! } ! ! // if no config xml file, add a default generator ! if (generators.size() == 0) { ! generators.add( new Generator() ); ! } ! ! HashMap classMappings = new HashMap(); ! ! for ( Iterator iter = mappingFiles.iterator(); iter.hasNext(); ) { ! // parse the mapping file ! Document document = builder.build( new File( (String) iter.next() ) ); ! Iterator classElements = document.getRootElement().getChildren("class").iterator(); ! while ( classElements.hasNext() ) { ! ClassMapping cmap = new ClassMapping( (Element) classElements.next()); ! classMappings.put(cmap.getCanonicalName(),cmap); ! } ! } ! ! // generate source files ! for ( Iterator iterator = generators.iterator(); iterator.hasNext(); ) { ! Generator g = (Generator) iterator.next(); ! g.setBaseDirName(outputDir); ! g.generate(classMappings); ! } ! } ! catch (Exception e) { ! e.printStackTrace(); ! } ! } } --- 28,111 ---- */ public class CodeGenerator { ! ! private static final Log log = LogFactory.getLog(CodeGenerator.class); ! ! public static void main(String[] args) { ! try { ! ArrayList mappingFiles = new ArrayList(); ! ! SAXBuilder builder = new SAXBuilder(); ! builder.setEntityResolver( new DTDEntityResolver() ); ! ! builder.setErrorHandler( new ErrorHandler() { ! public void error(SAXParseException error) { ! log.error("Error parsing XML: " + error.getSystemId() + '(' + error.getLineNumber() + ')',error); ! } ! public void fatalError(SAXParseException error) { ! error(error); ! } ! public void warning(SAXParseException error) { ! log.warn("Warning parsing XML: " + error.getSystemId() + '(' + error.getLineNumber() + ')' ); ! } ! } ); ! ! String outputDir = null; ! ! List generators = new ArrayList(); ! ! MultiMap globalMetas = new MultiHashMap(); ! // parse command line parameters ! for (int i = 0; i < args.length; i++) { ! if (args[i].startsWith("--")) { ! ! if ( args[i].startsWith("--config=") ) { ! // parse config xml file ! Document document = builder.build( new File( args[i].substring(9) ) ); ! globalMetas = MetaAttributeHelper.loadAndMergeMetaMap(document.getRootElement(), null); ! Iterator generateElements = document.getRootElement().getChildren("generate").iterator(); ! ! while (generateElements.hasNext()) { ! generators.add( new Generator( (Element) generateElements.next() ) ); ! } ! } ! else if ( args[i].startsWith("--output=") ) { ! outputDir = args[i].substring(9); ! } ! ! } ! else { ! mappingFiles.add( args[i] ); ! } ! } ! ! // if no config xml file, add a default generator ! if (generators.size() == 0) { ! generators.add( new Generator() ); ! } ! ! HashMap classMappings = new HashMap(); ! builder.setValidation(true); ! for ( Iterator iter = mappingFiles.iterator(); iter.hasNext(); ) { ! // parse the mapping file ! Document document = builder.build( new File( (String) iter.next() ) ); ! Iterator classElements = document.getRootElement().getChildren("class").iterator(); ! MultiMap mm = MetaAttributeHelper.loadAndMergeMetaMap(document.getRootElement(), globalMetas); ! while ( classElements.hasNext() ) { ! ClassMapping cmap = new ClassMapping( (Element) classElements.next(), mm); ! classMappings.put(cmap.getCanonicalName(),cmap); ! } ! } ! ! // generate source files ! for ( Iterator iterator = generators.iterator(); iterator.hasNext(); ) { ! Generator g = (Generator) iterator.next(); ! g.setBaseDirName(outputDir); ! g.generate(classMappings); ! } ! } ! catch (Exception e) { ! e.printStackTrace(); ! } ! } } Index: Field.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java/Field.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Field.java 5 Jan 2003 02:11:24 -0000 1.3 --- Field.java 16 Jan 2003 20:52:38 -0000 1.4 *************** *** 2,5 **** --- 2,11 ---- package net.sf.hibernate.tool.hbm2java; + import java.util.Collection; + import java.util.Iterator; + import java.util.Set; + + import org.apache.commons.collections.MultiMap; + public class Field { *************** *** 12,77 **** private boolean nullable = true; private ClassName classType; ! ! public Field(String name, ClassName type, boolean nullable) { ! this.name = name; ! setType(type); ! this.nullable = nullable; ! ! this.asSuffix = name.substring(0, 1).toUpperCase() + name.substring(1); ! } ! ! public Field(String name, ClassName type, boolean nullable, boolean id, boolean generated) { ! this.name = name; ! setType(type); ! this.id = id; ! this.nullable = nullable; //? ! this.generated = generated; ! this.asSuffix = name.substring(0, 1).toUpperCase() + name.substring(1); ! } ! ! public Field(String name, ClassName type, String initialisation, boolean nullable) { ! this(name, type, nullable); ! ! this.initialisation = initialisation; ! } ! ! public String getInitialisation() { ! return this.initialisation; ! } ! ! public String getName() { ! return this.name; ! } ! ! public String getAsSuffix() { ! return this.asSuffix; ! } ! ! public String getType() { ! String type = classType.getFullyQualifiedName(); ! int loc = type.indexOf("java.lang."); ! if ( loc<0 ) { ! return type; ! } ! else { ! return type.substring(10); ! } ! } ! ! public boolean isIdentifier() { ! return id; ! } ! ! public boolean isNullable() { ! return nullable; ! } ! ! public boolean isGenerated() { ! return generated; ! } ! ! public String toString() { ! return getType() + ":" + getName(); ! } /** --- 18,89 ---- private boolean nullable = true; private ClassName classType; ! private MultiMap metaattribs = null; ! private ClassName foreignClass; ! private Set foreignKeys; ! ! ! public Field(String name, ClassName type, boolean nullable, MultiMap metaattribs) { ! initWith(name, type, name, nullable, id, generated, null, null, metaattribs); ! } ! ! public Field(String name, ClassName type, boolean nullable, boolean id, boolean generated, MultiMap metaattribs) { ! initWith(name, type, initialisation, nullable, id, generated, null, null, metaattribs); ! } ! ! public Field(String name, ClassName type, String initialisation, boolean nullable, ClassName foreignClass, Set foreignKeys, MultiMap metaattribs) { ! initWith(name, type, initialisation, nullable, id, generated, foreignClass, foreignKeys, metaattribs); ! } ! ! protected void initWith(String name, ClassName type, String initialisation, boolean nullable, boolean id, boolean generated, ClassName foreignClass, Set foreignKeys, MultiMap metaattribs) { ! this.name = name; ! setType(type); ! this.initialisation = initialisation; ! this.nullable = nullable; ! this.id = id; ! this.generated = generated; ! this.asSuffix = name.substring(0, 1).toUpperCase() + name.substring(1); ! this.foreignClass = foreignClass; ! this.foreignKeys = foreignKeys; ! setMeta(metaattribs); ! } ! ! public String getInitialisation() { ! return this.initialisation; ! } ! ! public String getName() { ! return this.name; ! } ! ! public String getAsSuffix() { ! return this.asSuffix; ! } ! ! public String getType() { ! String type = classType.getFullyQualifiedName(); ! int loc = type.indexOf("java.lang."); ! if ( loc<0 ) { ! return type; ! } ! else { ! return type.substring(10); ! } ! } ! ! public boolean isIdentifier() { ! return id; ! } ! ! public boolean isNullable() { ! return nullable; ! } ! ! public boolean isGenerated() { ! return generated; ! } ! ! public String toString() { ! return getType() + ":" + getName(); ! } /** *************** *** 84,97 **** } ! private void setType(ClassName type) { ! this.classType = type; ! } ! ! ! } ! ! --- 96,159 ---- } ! private void setType(ClassName type) { ! this.classType = type; ! } ! /** ! * Method setMeta. ! * @param metaForProperty ! */ ! private void setMeta(MultiMap multiMap) { ! if(multiMap==null) { ! ! throw new RuntimeException("Forget it!"); ! } ! metaattribs = multiMap; ! } + Collection getMeta(String attribute) { + return (Collection) metaattribs.get(attribute); + } + /** + * Method getMetaAsString. + * @param string + * @return String + */ + public String getMetaAsString(String attribute) { + Collection c= getMeta(attribute); + + if(c==null) { + return ""; + } else { + StringBuffer sb = new StringBuffer(); + for (Iterator iter = c.iterator(); iter.hasNext();) { + Object element = (Object) iter.next(); + sb.append(element.toString()); + } + return sb.toString(); + } + } + /** + * Returns the foreignClass. + * @return ClassName + */ + public ClassName getForeignClass() { + return foreignClass; + } + /** + * Sets the foreignClass. + * @param foreignClass The foreignClass to set + */ + public void setForeignClass(ClassName foreignClass) { + this.foreignClass = foreignClass; + } + /** + * Returns the foreignKeys. + * @return Set + */ + public Set getForeignKeys() { + return foreignKeys; + } + } Index: Generator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java/Generator.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Generator.java 13 Jan 2003 08:57:43 -0000 1.4 --- Generator.java 16 Jan 2003 20:52:38 -0000 1.5 *************** *** 9,12 **** --- 9,14 ---- import java.util.Map; + import org.apache.commons.logging.Log; + import org.apache.commons.logging.LogFactory; import org.jdom.Element; *************** *** 16,94 **** */ public class Generator { ! private String rendererClass = "net.sf.hibernate.tool.hbm2java.BasicRenderer"; ! private String baseDirName = "generated"; ! private String packageName = null; ! private String suffix = ""; ! private String extension = "java"; ! private boolean lowerFirstLetter = false; ! ! /** ! * Constructs a new SchemaExport using the defaults. ! */ ! public Generator () {} ! ! /** ! * Constructs a new SchemaExport, configured from XML. ! */ ! public Generator(Element generateElement) throws Exception { ! String value = null; ! ! // set rendererClass field ! if ((this.rendererClass = generateElement.getAttributeValue("renderer")) == null) { ! throw new Exception("attribute renderer is required."); ! } ! ! // set dirName field ! if ((value = generateElement.getAttributeValue("dir")) != null) { ! this.baseDirName = value; ! } ! ! // set packageName field ! this.packageName = generateElement.getAttributeValue("package"); ! ! // set suffix ! if ((value = generateElement.getAttributeValue("suffix")) != null) { ! this.suffix = value; ! } ! ! // set extension ! if ((value = generateElement.getAttributeValue("extension")) != null) { ! this.extension = value; ! } ! ! // 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."); ! } ! } ! ! /** ! * ! */ ! public void generate(Map classMappingsCol) throws Exception { ! Renderer renderer = (Renderer) Class.forName(this.rendererClass).newInstance(); ! ! for (Iterator classMappings = classMappingsCol.values().iterator(); classMappings.hasNext();) { ! ClassMapping classMapping = (ClassMapping) classMappings.next(); ! writeRecur(classMapping, classMappingsCol, renderer); ! } ! for (Iterator cmpMappings = ClassMapping.getComponents(); cmpMappings.hasNext();) { ! ClassMapping mapping = (ClassMapping) cmpMappings.next(); ! write(mapping, classMappingsCol, renderer); ! } ! } ! ! private void writeRecur(ClassMapping classMapping, Map class2classmap, Renderer renderer) throws Exception { ! write(classMapping, class2classmap, renderer); ! if (!classMapping.getSubclasses().isEmpty()) { Iterator it = classMapping.getSubclasses().iterator(); --- 18,99 ---- */ public class Generator { ! ! private Log log = LogFactory.getLog(Generator.class); ! ! private String rendererClass = "net.sf.hibernate.tool.hbm2java.BasicRenderer"; ! private String baseDirName = "generated"; ! private String packageName = null; ! private String suffix = ""; ! private String extension = "java"; ! private boolean lowerFirstLetter = false; ! ! /** ! * Constructs a new Generator using the defaults. ! */ ! public Generator () {} ! ! /** ! * Constructs a new Generator, configured from XML. ! */ ! public Generator(Element generateElement) throws Exception { ! String value = null; ! ! // set rendererClass field ! if ((this.rendererClass = generateElement.getAttributeValue("renderer")) == null) { ! throw new Exception("attribute renderer is required."); ! } ! ! // set dirName field ! if ((value = generateElement.getAttributeValue("dir")) != null) { ! this.baseDirName = value; ! } ! ! // set packageName field ! this.packageName = generateElement.getAttributeValue("package"); ! ! // set suffix ! if ((value = generateElement.getAttributeValue("suffix")) != null) { ! this.suffix = value; ! } ! ! // set extension ! if ((value = generateElement.getAttributeValue("extension")) != null) { ! this.extension = value; ! } ! ! // 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."); ! } ! ! } ! ! /** ! * ! */ ! public void generate(Map classMappingsCol) throws Exception { ! Renderer renderer = (Renderer) Class.forName(this.rendererClass).newInstance(); ! ! for (Iterator classMappings = classMappingsCol.values().iterator(); classMappings.hasNext();) { ! ClassMapping classMapping = (ClassMapping) classMappings.next(); ! writeRecur(classMapping, classMappingsCol, renderer); ! } ! for (Iterator cmpMappings = ClassMapping.getComponents(); cmpMappings.hasNext();) { ! ClassMapping mapping = (ClassMapping) cmpMappings.next(); ! write(mapping, classMappingsCol, renderer); ! } ! } ! private void writeRecur(ClassMapping classMapping, Map class2classmap, Renderer renderer) throws Exception { ! write(classMapping, class2classmap, renderer); ! if (!classMapping.getSubclasses().isEmpty()) { Iterator it = classMapping.getSubclasses().iterator(); *************** *** 98,183 **** } } - - - /** - * - */ - private void write(ClassMapping classMapping, Map class2classmap, Renderer renderer) throws Exception { - File dir = this.getDir( classMapping.getPackageName() ); - File file = new File( dir, this.getFileName( classMapping.getName() ) ); - - PrintWriter writer = new PrintWriter(new FileOutputStream(file)); - - renderer.render( this.getName( classMapping.getName() ), classMapping, class2classmap, writer ); - writer.close(); - } - - /** - * - */ - private String getFileName(String className) { - return this.getName(className) + "." + this.extension; - } - - /** - * - */ - private String getName(String className) { - String name = null; - - if (this.lowerFirstLetter) { - name = className.substring(0, 1).toLowerCase() + className.substring(1, className.length()); - } - else { - name = className; - } - - return name + this.suffix; - } - - /** - * - */ - private File getDir(String packageName) throws Exception { - File baseDir = new File(this.baseDirName); - File dir = null; - - if (this.packageName == null) { - dir = new File(baseDir, packageName==null ? "" : packageName.replace('.', File.separatorChar)); - } - else { - dir = new File(baseDir, this.packageName.replace('.', File.separatorChar)); - } - - // if the directory exists, make sure it is a directory - if (dir.exists()) { - if (!dir.isDirectory()) { - throw new Exception("The path: " + dir.getCanonicalPath() + " exists, but is not a directory"); - } - } // else make the directory and any non-existent parent directories - else { - if (!dir.mkdirs()) { - throw new Exception("unable to create directory: " + dir.getCanonicalPath()); - } - } - - return dir; - } - - public String getBaseDirName() { - return baseDirName; - } - - public void setBaseDirName(String baseDirName) { - if (baseDirName != null) { - this.baseDirName = baseDirName; - } - } - - } --- 103,181 ---- } } + /** + * + */ + private void write(ClassMapping classMapping, Map class2classmap, Renderer renderer) throws Exception { + File dir = this.getDir(classMapping.getGeneratedPackageName()); + File file = new File(dir, this.getFileName(classMapping.getGeneratedName())); + log.debug("Writing " + file); + + PrintWriter writer = new PrintWriter(new FileOutputStream(file)); + + renderer.render(this.packageName, classMapping, class2classmap, writer); + writer.close(); + } + + /** + * + */ + private String getFileName(String className) { + return this.getName(className) + "." + this.extension; + } + /** + * + */ + private String getName(String className) { + String name = null; + if (this.lowerFirstLetter) { + name = className.substring(0, 1).toLowerCase() + className.substring(1, className.length()); + } else { + name = className; + } + return name + this.suffix; + } + /** + * + */ + private File getDir(String packageName) throws Exception { + File baseDir = new File(this.baseDirName); + File dir = null; + + if (this.packageName == null) { + dir = new File(baseDir, packageName==null ? "" : packageName.replace('.', File.separatorChar)); + } else { + dir = new File(baseDir, this.packageName.replace('.', File.separatorChar)); + } + + // if the directory exists, make sure it is a directory + if (dir.exists()) { + if (!dir.isDirectory()) { + throw new Exception("The path: " + dir.getCanonicalPath() + " exists, but is not a directory"); + } + } // else make the directory and any non-existent parent directories + else { + if (!dir.mkdirs()) { + throw new Exception("unable to create directory: " + dir.getCanonicalPath()); + } + } + + return dir; + } + + public String getBaseDirName() { + return baseDirName; + } + + public void setBaseDirName(String baseDirName) { + if (baseDirName != null) { + this.baseDirName = baseDirName; + } + } + + } |
From: <one...@us...> - 2003-01-16 20:52:41
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv8417/net/sf/hibernate Modified Files: hibernate-mapping-2.0.dtd Log Message: applied Max Andersen's patch for <meta>attributes in hbm2java Index: hibernate-mapping-2.0.dtd =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hibernate-mapping-2.0.dtd,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** hibernate-mapping-2.0.dtd 13 Jan 2003 08:57:43 -0000 1.6 --- hibernate-mapping-2.0.dtd 16 Jan 2003 20:52:38 -0000 1.7 *************** *** 19,23 **** <!-- The document root. --> ! <!ELEMENT hibernate-mapping (class*, query*)> <!ATTLIST hibernate-mapping schema CDATA #IMPLIED> <!-- default: none --> <!ATTLIST hibernate-mapping default-cascade (none|save-update|all) "none"> --- 19,23 ---- <!-- The document root. --> ! <!ELEMENT hibernate-mapping (meta*, class*, query*)> <!ATTLIST hibernate-mapping schema CDATA #IMPLIED> <!-- default: none --> <!ATTLIST hibernate-mapping default-cascade (none|save-update|all) "none"> *************** *** 26,29 **** --- 26,30 ---- <!ELEMENT class ( + meta*, jcs-cache?, (id|composite-id), *************** *** 47,51 **** through Session.getID()--> ! <!ELEMENT id (column*, generator)> <!ATTLIST id name CDATA #IMPLIED> <!ATTLIST id column CDATA #IMPLIED> --- 48,52 ---- through Session.getID()--> ! <!ELEMENT id (meta*, column*, generator)> <!ATTLIST id name CDATA #IMPLIED> <!ATTLIST id column CDATA #IMPLIED> *************** *** 87,90 **** --- 88,92 ---- <!ELEMENT subclass ( + meta*, (property|many-to-one|one-to-one|component|map|set|list|bag|array|primitive-array)*, subclass* *************** *** 97,100 **** --- 99,103 ---- <!ELEMENT joined-subclass ( + meta*, key, (property|many-to-one|one-to-one|component|map|set|list|bag|array|primitive-array)*, *************** *** 109,113 **** JavaBeans style properties are mapped to table columns. --> ! <!ELEMENT property (column*)> <!ATTLIST property name CDATA #REQUIRED> <!ATTLIST property type CDATA #IMPLIED> --- 112,116 ---- JavaBeans style properties are mapped to table columns. --> ! <!ELEMENT property (meta*,column*)> <!ATTLIST property name CDATA #REQUIRED> <!ATTLIST property type CDATA #IMPLIED> *************** *** 120,124 **** etc. to an entity). --> ! <!ELEMENT many-to-one (column*)> <!ATTLIST many-to-one name CDATA #REQUIRED> <!ATTLIST many-to-one class CDATA #IMPLIED> --- 123,127 ---- etc. to an entity). --> ! <!ELEMENT many-to-one (meta*,column*)> <!ATTLIST many-to-one name CDATA #REQUIRED> <!ATTLIST many-to-one class CDATA #IMPLIED> *************** *** 132,136 **** component element, etc. to an entity). --> ! <!ELEMENT one-to-one EMPTY> <!ATTLIST one-to-one name CDATA #REQUIRED> <!ATTLIST one-to-one class CDATA #IMPLIED> --- 135,139 ---- component element, etc. to an entity). --> ! <!ELEMENT one-to-one (meta*)> <!ATTLIST one-to-one name CDATA #REQUIRED> <!ATTLIST one-to-one class CDATA #IMPLIED> *************** *** 178,181 **** --- 181,185 ---- <!ELEMENT map ( + meta*, jcs-cache?, key, *************** *** 193,196 **** --- 197,201 ---- <!ELEMENT set ( + meta*, jcs-cache?, key, *************** *** 207,210 **** --- 212,216 ---- <!ELEMENT bag ( + meta*, jcs-cache?, key, *************** *** 220,223 **** --- 226,230 ---- <!ELEMENT list ( + meta*, jcs-cache?, key, *************** *** 233,236 **** --- 240,244 ---- <!ELEMENT array ( + meta*, jcs-cache?, key, *************** *** 244,248 **** <!ATTLIST array cascade (none|all|save-update|delete) #IMPLIED> <!-- default: none --> ! <!ELEMENT primitive-array (jcs-cache?, key, index, element)> <!ATTLIST primitive-array name CDATA #REQUIRED> <!ATTLIST primitive-array table CDATA #IMPLIED> <!-- default: name --> --- 252,256 ---- <!ATTLIST array cascade (none|all|save-update|delete) #IMPLIED> <!-- default: none --> ! <!ELEMENT primitive-array (meta*, jcs-cache?, key, index, element)> <!ATTLIST primitive-array name CDATA #REQUIRED> <!ATTLIST primitive-array table CDATA #IMPLIED> <!-- default: name --> *************** *** 269,273 **** element type of a collection and specifies a many-to-many relational model --> ! <!ELEMENT many-to-many (column*)> <!ATTLIST many-to-many class CDATA #REQUIRED> <!ATTLIST many-to-many column CDATA #IMPLIED> --- 277,281 ---- element type of a collection and specifies a many-to-many relational model --> ! <!ELEMENT many-to-many (meta*,column*)> <!ATTLIST many-to-many class CDATA #REQUIRED> <!ATTLIST many-to-many column CDATA #IMPLIED> *************** *** 349,350 **** --- 357,366 ---- <!ELEMENT query (#PCDATA)> <!ATTLIST query name CDATA #REQUIRED> + + <!-- The meta element is used to assign meta-level attributes to a class or property. + Is currently used by codegenerator as a placeholder for values that is not directly + related to OR mappings. --> + + <!ELEMENT meta (#PCDATA)> + <!ATTLIST meta attribute CDATA #REQUIRED> + \ No newline at end of file |
From: <one...@us...> - 2003-01-16 20:52:40
|
Update of /cvsroot/hibernate/Hibernate2/src In directory sc8-pr-cvs1:/tmp/cvs-serv8417 Modified Files: hibernate.properties Log Message: applied Max Andersen's patch for <meta>attributes in hbm2java Index: hibernate.properties =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/hibernate.properties,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** hibernate.properties 14 Jan 2003 13:42:05 -0000 1.10 --- hibernate.properties 16 Jan 2003 20:52:38 -0000 1.11 *************** *** 26,44 **** ## PostgreSQL ! #hibernate.dialect net.sf.hibernate.dialect.PostgreSQLDialect ! #hibernate.connection.driver_class org.postgresql.Driver ! #hibernate.connection.url jdbc:postgresql:template1 ! #hibernate.connection.username pg ! #hibernate.connection.password ! #hibernate.query.substitutions yes 'Y', no 'N' ## DB2 ! hibernate.dialect net.sf.hibernate.dialect.DB2Dialect ! hibernate.connection.driver_class COM.ibm.db2.jdbc.app.DB2Driver ! hibernate.connection.url jdbc:db2:test ! hibernate.connection.username db2 ! hibernate.connection.password db2 --- 26,44 ---- ## PostgreSQL ! hibernate.dialect net.sf.hibernate.dialect.PostgreSQLDialect ! hibernate.connection.driver_class org.postgresql.Driver ! hibernate.connection.url jdbc:postgresql:template1 ! hibernate.connection.username pg ! hibernate.connection.password ! hibernate.query.substitutions yes 'Y', no 'N' ## DB2 ! #hibernate.dialect net.sf.hibernate.dialect.DB2Dialect ! #hibernate.connection.driver_class COM.ibm.db2.jdbc.app.DB2Driver ! #hibernate.connection.url jdbc:db2:test ! #hibernate.connection.username db2 ! #hibernate.connection.password db2 |
From: <one...@us...> - 2003-01-16 08:56:05
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv19562/reference/src Modified Files: advanced_or_mapping.xml Log Message: minor fix Index: advanced_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/advanced_or_mapping.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** advanced_or_mapping.xml 16 Jan 2003 08:42:33 -0000 1.4 --- advanced_or_mapping.xml 16 Jan 2003 08:56:02 -0000 1.5 *************** *** 218,224 **** <para> ! A map from string indices to dates (this might be a useful mapping ! style if many different classes all had collections living in the one table, or ! if the map was a subcollection): </para> --- 218,222 ---- <para> ! A map from string indices to dates: </para> |
From: <one...@us...> - 2003-01-16 08:42:36
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv18366/reference/src Modified Files: advanced_or_mapping.xml Log Message: minor fix Index: advanced_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/advanced_or_mapping.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** advanced_or_mapping.xml 16 Jan 2003 08:39:24 -0000 1.3 --- advanced_or_mapping.xml 16 Jan 2003 08:42:33 -0000 1.4 *************** *** 225,229 **** <programlisting><![CDATA[<map name="holidays" table="holidays" schema="dbo" order-by="hol_name asc"> ! <generated-key column="id"/> <index column="hol_name" type="string"/> <element column="hol_date" type="date"/> --- 225,229 ---- <programlisting><![CDATA[<map name="holidays" table="holidays" schema="dbo" order-by="hol_name asc"> ! <key column="id"/> <index column="hol_name" type="string"/> <element column="hol_date" type="date"/> |
From: <one...@us...> - 2003-01-16 08:39:27
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv18223/reference/src Modified Files: advanced_or_mapping.xml examples.xml Log Message: document change to inverse Index: advanced_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/advanced_or_mapping.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** advanced_or_mapping.xml 16 Jan 2003 08:28:45 -0000 1.2 --- advanced_or_mapping.xml 16 Jan 2003 08:39:24 -0000 1.3 *************** *** 428,432 **** You may specify a bidirectional many-to-many association simply by mapping two nested, many-to-many sets/bags to the same database table and declaring one end as ! <emphasis>readonly</emphasis>. Heres an example of a bidirectional many-to-many association from a class back to <emphasis>itself</emphasis>: </para> --- 428,432 ---- You may specify a bidirectional many-to-many association simply by mapping two nested, many-to-many sets/bags to the same database table and declaring one end as ! <emphasis>inverse</emphasis>. Heres an example of a bidirectional many-to-many association from a class back to <emphasis>itself</emphasis>: </para> *************** *** 439,443 **** <many-to-many class="eg.Node" column="from_node_id"/> </bag> ! <bag name="accessibleFrom" table="node_access" readonly="true" lazy="true"> <!-- readonly end --> <key column="from_node_id"/> <many-to-many class="eg.Node" column="to_node_id"/> --- 439,443 ---- <many-to-many class="eg.Node" column="from_node_id"/> </bag> ! <bag name="accessibleFrom" table="node_access" inverse="true" lazy="true"> <!-- inverse end --> <key column="from_node_id"/> <many-to-many class="eg.Node" column="to_node_id"/> *************** *** 446,451 **** <para> ! Changes made to the readonly end of the association are <emphasis>not</emphasis> ! persistent. </para> --- 446,451 ---- <para> ! Changes made only to the inverse end of the association are <emphasis>not</emphasis> ! persisted. </para> *************** *** 453,457 **** You may map a bidirectional one-to-many association by mapping a nested, one-to-many set / bag to the same table column(s) as a many-to-one association and ! declaring the many-valued end readonly. </para> --- 453,457 ---- You may map a bidirectional one-to-many association by mapping a nested, one-to-many set / bag to the same table column(s) as a many-to-one association and ! declaring the many-valued end inverse. </para> *************** *** 459,463 **** <id name="id" column="id"/> .... ! <set name="children" readonly="true" lazy="true"> <key column="parent_id"/> <one-to-many class="eg.Child"/> --- 459,463 ---- <id name="id" column="id"/> .... ! <set name="children" inverse="true" lazy="true"> <key column="parent_id"/> <one-to-many class="eg.Child"/> Index: examples.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/examples.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** examples.xml 16 Jan 2003 08:28:45 -0000 1.2 --- examples.xml 16 Jan 2003 08:39:24 -0000 1.3 *************** *** 143,147 **** <property name="title"/> ! <set role="authors" table="author_work"> <key column="work_id" not-null="true"/> <many-to-many class="Author" column="author_id" not-null="true"/> --- 143,147 ---- <property name="title"/> ! <set name="authors" table="author_work"> <key column="work_id" not-null="true"/> <many-to-many class="Author" column="author_id" not-null="true"/> *************** *** 168,172 **** <one-to-one name="person" constrained="true"/> ! <set role="works" table="author_work" readonly="true"> <key column="author_id"/> <many-to-many class="Work" column="work_id"/> --- 168,172 ---- <one-to-one name="person" constrained="true"/> ! <set name="works" table="author_work" readonly="true"> <key column="author_id"/> <many-to-many class="Work" column="work_id"/> *************** *** 257,261 **** </id> <property name="name"/> ! <set role="orders" readonly="true"> <key column="customer_id"/> <one-to-many class="Order"/> --- 257,261 ---- </id> <property name="name"/> ! <set name="orders" readonly="true"> <key column="customer_id"/> <one-to-many class="Order"/> *************** *** 269,273 **** <property name="date"/> <many-to-one name="customer" column="customer_id"/> ! <list role="lineItems" table="line_items"> <key column="order_id"/> <index column="line_number"/> --- 269,273 ---- <property name="date"/> <many-to-one name="customer" column="customer_id"/> ! <list name="lineItems" table="line_items"> <key column="order_id"/> <index column="line_number"/> |
From: <one...@us...> - 2003-01-16 08:28:48
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv17595/reference/src Modified Files: advanced_or_mapping.xml basic_or_mapping.xml examples.xml Log Message: document changes in 2.0 Index: advanced_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/advanced_or_mapping.xml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** advanced_or_mapping.xml 1 Jan 2003 13:46:22 -0000 1.1.1.1 --- advanced_or_mapping.xml 16 Jan 2003 08:28:45 -0000 1.2 *************** *** 59,63 **** <para> Collections (and subcollections) obey the usual rules for value types: no shared ! references, created and deleted along with containing entity. </para> --- 59,65 ---- <para> Collections (and subcollections) obey the usual rules for value types: no shared ! references, created and deleted along with containing entity. Due to the underlying ! relational model, they do not support null value semantics; Hibernate does not ! distinguish between a null collection reference and an empty collection. </para> *************** *** 79,111 **** <sect2 id="adv-or-mapping-s1-2"> ! <title>Toplevel and Nested Collections</title> ! ! <para> ! All collections require an identifier. The identifier is never exposed to the ! application. A <emphasis>nested</emphasis> collection is one whose identifier ! is assigned from its containing object. A <emphasis>toplevel</emphasis> ! collection's identifier is generated by a Hibernate ID generator. Toplevel ! collections require an extra column in the table of the owning class (holding ! the collection's identifier). ! </para> <para> ! Nested collection roles are declared inside a ! <literal>class</literal> or <literal>component</literal> tag. ! The role name is the name of a property of that class or component and collections ! of that role may only be referenced by that property. This is intended to be the ! most common use of collections. However, nested collections may <emphasis>not</emphasis> ! be contained in other collections.....Hibernate won't even let you declare such ! a mapping. Nested collections do not distinguish between a null collection ! reference and an empty collection. </para> - <para> - Toplevel collections are declared directly beneath the root element of a mapping - and may be referenced by a properties of any class or component, or by another - collection. They require their own ID generator (but may not use - <literal>native</literal> ID generation). Toplevel collections - may be contained in other collections. - </para> </sect2> --- 81,91 ---- <sect2 id="adv-or-mapping-s1-2"> ! <title>Collections Keys</title> <para> ! Collection instances are distinguished in the database by a foreign key to ! the owning object. (Hence collections may not contain other collections.) </para> </sect2> *************** *** 126,130 **** <programlisting><![CDATA[<map ! role="roleName" table="table_name" schema="schema_name --- 106,110 ---- <programlisting><![CDATA[<map ! name="propertyName" table="table_name" schema="schema_name *************** *** 142,152 **** <listitem> <para> ! <literal>role</literal> the name of the toplevel collection role ! or nested collection property </para> </listitem> <listitem> <para> ! <literal>table</literal> (optional - defaults to role name) the name of the collection table (not used for one-to-many associations) </para> --- 122,131 ---- <listitem> <para> ! <literal>name</literal> the collection property name </para> </listitem> <listitem> <para> ! <literal>table</literal> (optional - defaults to property name) the name of the collection table (not used for one-to-many associations) </para> *************** *** 187,241 **** </sect2> - - <sect2 id="adv-or-mapping-s1-4"> - <title>Mapping a Property to a Toplevel Collection</title> - - <para> - The <literal><collection></literal> and - <literal><subcollection></literal> elements map a property to a - toplevel collection or a collection to a subcollection. - </para> - - <programlisting><![CDATA[<collection - name="propertyName" - column="column_name" - role="some_role" - cascade="all|none|save-update|delete"/> - - <subcollection - column="column_name" - role="some_role"/>]]></programlisting> - - <itemizedlist> - <listitem> - <para> - <literal>name</literal> the property name - </para> - </listitem> - <listitem> - <para> - <literal>role</literal> the name of the toplevel collection role - </para> - </listitem> - <listitem> - <para> - <literal>column</literal> (optional - defaults to property name) - the column holding the toplevel collection identifier - </para> - </listitem> - <listitem> - <para> - <literal>cascade</literal> (optional) enable cascaded operations - </para> - </listitem> - </itemizedlist> - - <para> - Note that enabling cascades for a collection will force operations to cascade - all the way down a heirarchy of subcollections to the leaf entity objects. - </para> - </sect2> - - <sect2 id="adv-or-mapping-s1-5"> <title>Collections of Values and Many To Many Associations</title> --- 166,169 ---- *************** *** 260,270 **** <para> ! First, a set of strings. This is a nested collection so it doesn't declare its ! own key type or generator (even nested collections declare a ! <literal><key></literal> element - the foreign key of their ! owning class): </para> ! <programlisting><![CDATA[<set role="names" table="NAMES"> <key column="GROUPID"/> <element column="NAME" type="string"/> --- 188,195 ---- <para> ! First, a set of strings: </para> ! <programlisting><![CDATA[<set name="names" table="NAMES"> <key column="GROUPID"/> <element column="NAME" type="string"/> *************** *** 272,280 **** <para> ! A nested bag containing integers (with an iteration order determined by the <literal>order-by</literal> attribute): </para> ! <programlisting><![CDATA[<bag role="sizes" table="SIZES" order-by="SIZE ASC"> <key column="OWNER"/> <element column="SIZE" type="integer"/> --- 197,205 ---- <para> ! A bag containing integers (with an iteration order determined by the <literal>order-by</literal> attribute): </para> ! <programlisting><![CDATA[<bag name="sizes" table="SIZES" order-by="SIZE ASC"> <key column="OWNER"/> <element column="SIZE" type="integer"/> *************** *** 282,290 **** <para> ! A nested array of entities - in this case, a many to many association (note that the entities are lifecycle objects, <literal>cascade="all"</literal>): </para> ! <programlisting><![CDATA[<array role="foos" table="BAR_FOOS" cascade="all"> <key column="BAR_ID"/> <index column="I"/> --- 207,215 ---- <para> ! An array of entities - in this case, a many to many association (note that the entities are lifecycle objects, <literal>cascade="all"</literal>): </para> ! <programlisting><![CDATA[<array name="foos" table="BAR_FOOS" cascade="all"> <key column="BAR_ID"/> <index column="I"/> *************** *** 293,297 **** <para> ! A toplevel map from string indices to dates (this might be a useful mapping style if many different classes all had collections living in the one table, or if the map was a subcollection): --- 218,222 ---- <para> ! A map from string indices to dates (this might be a useful mapping style if many different classes all had collections living in the one table, or if the map was a subcollection): *************** *** 299,306 **** ! <programlisting><![CDATA[<map role="holidays" table="holidays" schema="dbo" order-by="hol_name asc"> ! <generated-key column="id" type="string"> ! <generator class="uuid.hex"/> ! </key> <index column="hol_name" type="string"/> <element column="hol_date" type="date"/> --- 224,229 ---- ! <programlisting><![CDATA[<map name="holidays" table="holidays" schema="dbo" order-by="hol_name asc"> ! <generated-key column="id"/> <index column="hol_name" type="string"/> <element column="hol_date" type="date"/> *************** *** 308,315 **** <para> ! A nested list of components: </para> ! <programlisting><![CDATA[<list role="carComponents" table="car_components"> <key column="car_id"/> <index column="posn"/> --- 231,238 ---- <para> ! A list of components: </para> ! <programlisting><![CDATA[<list name="carComponents" table="car_components"> <key column="car_id"/> <index column="posn"/> *************** *** 330,336 **** A <emphasis>one to many association</emphasis> links the tables of two classes <emphasis>directly</emphasis>, with no intervening collection table. ! (This implements a <emphasis>one-to-many</emphasis> relational ! model.) This model has higher performance but loses some of the semantics of ! Java collections: </para> --- 253,258 ---- A <emphasis>one to many association</emphasis> links the tables of two classes <emphasis>directly</emphasis>, with no intervening collection table. ! (This implements a <emphasis>one-to-many</emphasis> relational model.) This ! relational model loses some of the semantics of Java collections: </para> *************** *** 371,375 **** </para> ! <programlisting><![CDATA[<set role="bars" table="foobars"> <key column="foo_id"/> <one-to-many class="com.illflow.Bar"/> --- 293,297 ---- </para> ! <programlisting><![CDATA[<set name="bars" table="foobars"> <key column="foo_id"/> <one-to-many class="com.illflow.Bar"/> *************** *** 377,382 **** <para> ! The <literal>one-to-many</literal> tag does not need to declare ! any columns. </para> </sect2> --- 299,303 ---- <para> ! The <literal>one-to-many</literal> tag does not need to declare any columns. </para> </sect2> *************** *** 426,430 **** </para> ! <programlisting><![CDATA[<set role="names" table="NAMES" lazy="true"> <key column="group_id"/> <element column="NAME" type="string"/> --- 347,351 ---- </para> ! <programlisting><![CDATA[<set name="names" table="NAMES" lazy="true"> <key column="group_id"/> <element column="NAME" type="string"/> *************** *** 438,452 **** <para> ! Hibernate supports collections implementing ! <literal>java.util.SortedMap</literal> and ! <literal>java.util.SortedSet</literal>. You must specify a ! comparator in the mapping file: </para> ! <programlisting><![CDATA[<set role="names" sort="natural"> ... </set> ! <map role="holidays" sort="my.custom.StringComparator" lazy="true"> ... </map>]]></programlisting> --- 359,371 ---- <para> ! Hibernate supports collections implementing <literal>java.util.SortedMap</literal> and ! <literal>java.util.SortedSet</literal>. You must specify a comparator in the mapping file: </para> ! <programlisting><![CDATA[<set name="names" sort="natural"> ... </set> ! <map name="holidays" sort="my.custom.StringComparator" lazy="true"> ... </map>]]></programlisting> *************** *** 516,524 **** <id name="id" column="id"/> .... ! <bag role="accessibleTo" table="node_access" lazy="true"> <key column="to_node_id"/> <many-to-many class="eg.Node" column="from_node_id"/> </bag> ! <bag role="accessibleFrom" table="node_access" readonly="true" lazy="true"> <!-- readonly end --> <key column="from_node_id"/> <many-to-many class="eg.Node" column="to_node_id"/> --- 435,443 ---- <id name="id" column="id"/> .... ! <bag name="accessibleTo" table="node_access" lazy="true"> <key column="to_node_id"/> <many-to-many class="eg.Node" column="from_node_id"/> </bag> ! <bag name="accessibleFrom" table="node_access" readonly="true" lazy="true"> <!-- readonly end --> <key column="from_node_id"/> <many-to-many class="eg.Node" column="to_node_id"/> *************** *** 540,544 **** <id name="id" column="id"/> .... ! <set role="children" readonly="true" lazy="true"> <key column="parent_id"/> <one-to-many class="eg.Child"/> --- 459,463 ---- <id name="id" column="id"/> .... ! <set name="children" readonly="true" lazy="true"> <key column="parent_id"/> <one-to-many class="eg.Child"/> *************** *** 562,566 **** </para> ! <programlisting><![CDATA[<map role="contracts" lazy="true"> <key column="employer_id"/> <index-many-to-many column="employee_id" class="Employee"/> --- 481,485 ---- </para> ! <programlisting><![CDATA[<map name="contracts" lazy="true"> <key column="employer_id"/> <index-many-to-many column="employee_id" class="Employee"/> *************** *** 568,572 **** </map>]]></programlisting> ! <programlisting><![CDATA[<map role="connections" lazy="true"> <key column="node1_id"/> <index-many-to-many column="node2_id" class="Node"/> --- 487,491 ---- </map>]]></programlisting> ! <programlisting><![CDATA[<map name="connections" lazy="true"> <key column="node1_id"/> <index-many-to-many column="node2_id" class="Node"/> *************** *** 613,617 **** <generator class="sequence"/> </id> ! <set role="children" lazy="true"> <key type="long" column="parent_id"/> <one-to-many class="eg.Child"/> --- 532,536 ---- <generator class="sequence"/> </id> ! <set name="children" lazy="true"> <key type="long" column="parent_id"/> <one-to-many class="eg.Child"/> *************** *** 647,651 **** <generator class="sequence"/> </id> ! <set role="children" lazy="true" table="childset"> <key type="long" column="parent_id"/> <many-to-many class="eg.Child" column="child_id"/> --- 566,570 ---- <generator class="sequence"/> </id> ! <set name="children" lazy="true" table="childset"> <key type="long" column="parent_id"/> <many-to-many class="eg.Child" column="child_id"/> *************** *** 669,710 **** alter table childset add constraint childsetfk1 (child_id) references child]]></programlisting> - <para> - If many different classes contain sets of - <literal>eg.Child</literal> or if, for some reason, we need to - distinguish between a null collection reference and an empty set, a toplevel - collection might be used: - </para> - - - <programlisting><![CDATA[<hibernate-mapping> - - <set role="childset" lazy="true"> - <generated-key type="long" column="id"> - <generator class="sequence"/> - </key> - <many-to-many class="eg.Child" column="child_id"/> - </set> - - <class name="eg.Parent> - <id name="id"> - <generator class="sequence"/> - </id> - <collection name="children" column="childset_id" role="childset"/> - </class> - - <class name="eg.Child"> - .... - </class> - - </hibernate-mapping>]]></programlisting> - - <para> - Table definitions: - </para> - - <programlisting><![CDATA[create table parent ( id bigint not null primary key, childset_id bigint ) - create table child ( id bigint not null primary key, name varchar(255) ) - create table childset ( id bigint, child_id bigint ) - alter table childset add constraint childsetfk0 (child_id) references child]]></programlisting> </sect2> --- 588,591 ---- *************** *** 840,847 **** </para> ! <programlisting><![CDATA[<set role="some_names" lazy="true"> ! <key name="id" type="string"> ! <generator class="uuid.hex"/> ! </key> <composite-element class="eg.Name"> <!-- class attribute required --> <property name="initial"/> --- 721,726 ---- </para> ! <programlisting><![CDATA[<set name="some_names" lazy="true"> ! <key column="id"/> <composite-element class="eg.Name"> <!-- class attribute required --> <property name="initial"/> *************** *** 852,857 **** <para> ! Composite elements may contain components and even toplevel collections, ! but not nested collections. If your composite element itself contains components, use the <literal><nested-composite-element></literal> tag. This is a pretty exotic case - a collection of components which --- 731,736 ---- <para> ! Composite elements may contain components not collections. If your composite ! element itself contains components, use the <literal><nested-composite-element></literal> tag. This is a pretty exotic case - a collection of components which *************** *** 875,879 **** <programlisting><![CDATA[<class name="eg.Order" .... > .... ! <set role="purchasedItems" lazy="true"> <key name="order_id"> <composite-element class="eg.Purchase"> --- 754,758 ---- <programlisting><![CDATA[<class name="eg.Order" .... > .... ! <set name="purchasedItems" lazy="true"> <key name="order_id"> <composite-element class="eg.Purchase"> *************** *** 890,894 **** <programlisting><![CDATA[<class name="eg.Order" .... > .... ! <set role="purchasedItems" lazy="true"> <key name="order_id"> <composite-element class="eg.OrderLine"> --- 769,773 ---- <programlisting><![CDATA[<class name="eg.Order" .... > .... ! <set name="purchasedItems" lazy="true"> <key name="order_id"> <composite-element class="eg.OrderLine"> *************** *** 978,982 **** </para> ! <programlisting><![CDATA[<set role="foos"> <key column="owner_id"/> <many-to-many class="eg.Foo"> --- 857,861 ---- </para> ! <programlisting><![CDATA[<set name="foos"> <key column="owner_id"/> <many-to-many class="eg.Foo"> *************** *** 999,1003 **** .... .... ! <set role="Dates" lazy="true"> <key> <!-- a nested collection inherits the composite key type --> <column name="foo_string"/> --- 878,882 ---- .... .... ! <set name="Dates" lazy="true"> <key> <!-- a nested collection inherits the composite key type --> <column name="foo_string"/> *************** *** 1090,1094 **** <jcs-cache usage="read-write"/> .... ! <set role="kittens" ... > <jcs-cache usage="read-write"/> .... --- 969,973 ---- <jcs-cache usage="read-write"/> .... ! <set name="kittens" ... > <jcs-cache usage="read-write"/> .... Index: basic_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/basic_or_mapping.xml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** basic_or_mapping.xml 1 Jan 2003 13:46:26 -0000 1.1.1.1 --- basic_or_mapping.xml 16 Jan 2003 08:28:45 -0000 1.2 *************** *** 17,21 **** <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" ! "http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd"> <hibernate-mapping> --- 17,21 ---- <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" ! "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping> *************** *** 23,27 **** <class name="eg.Cat" table="CATS" discriminator-value="C"> <id name="id" column="uid" type="long"> ! <generator class="hilo.long"/> </id> <discriminator column="subclass" type="character"/> --- 23,27 ---- <class name="eg.Cat" table="CATS" discriminator-value="C"> <id name="id" column="uid" type="long"> ! <generator class="hilo"/> </id> <discriminator column="subclass" type="character"/> *************** *** 30,36 **** <property name="sex" not-null="true"/> <property name="weight"/> ! <many-to-one name="mate"/> ! <set role="kittens"> ! <key column="mother"/> <one-to-many class="eg.Cat"/> </set> --- 30,36 ---- <property name="sex" not-null="true"/> <property name="weight"/> ! <many-to-one name="mate" column="mate_id"/> ! <set name="kittens"> ! <key column="mother_id"/> <one-to-many class="eg.Cat"/> </set> *************** *** 40,45 **** </class> ! <class name="eg.Baz"> ! <!-- mapping for Baz goes here --> </class> --- 40,45 ---- </class> ! <class name="eg.Dog"> ! <!-- mapping for Dog could go here --> </class> *************** *** 60,66 **** <para> ! All XML mappings should declare this doctype. The actual DTD may be found at the ! URL above, in the directory <literal>hibernate-x.x.x/src/net/sf/hibernate</literal> ! or in <literal>hibernate.jar</literal>. Hibernate will always look for the DTD in its classpath first. </para> --- 60,66 ---- <para> ! All XML mappings should declare the doctype shown. The actual DTD may be found ! at the URL above, in the directory <literal>hibernate-x.x.x/src/net/sf/hibernate ! </literal> or in <literal>hibernate.jar</literal>. Hibernate will always look for the DTD in its classpath first. </para> *************** *** 257,262 **** <programlisting><![CDATA[<id name="id" type="long" column="uid" unsaved-value="null"> <generator class="net.sf.hibernate.id.HiLoGenerator"> ! <param>uid_table</param> ! <param>next_hi_value_column</param> </generator> </id>]]></programlisting> --- 257,262 ---- <programlisting><![CDATA[<id name="id" type="long" column="uid" unsaved-value="null"> <generator class="net.sf.hibernate.id.HiLoGenerator"> ! <param name="table">uid_table</param> ! <param name="column">next_hi_value_column</param> </generator> </id>]]></programlisting> *************** *** 271,368 **** <variablelist> <varlistentry> ! <term><literal>uuid.hex</literal></term> ! <listitem> ! <para> ! uses a 128-bit UUID algorithm to generate identifiers of type string, ! unique within a network (the IP address is used). The UUID is encoded ! as a string of hexadecimal digits of length 32. ! </para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term><literal>uuid.string</literal></term> <listitem> <para> ! uses the same UUID algorithm. The UUID is encoded a string of length 16 ! consisting of (any) ASCII characters. <emphasis>Do not use with PostgreSQL.</emphasis> </para> </listitem> </varlistentry> <varlistentry> ! <term><literal>vm.long</literal></term> <listitem> <para> ! generates identifiers of type <literal>long</literal> that are unique only within a ! single VM. <emphasis>Do not use in a cluster.</emphasis> </para> </listitem> </varlistentry> <varlistentry> ! <term><literal>vm.hex</literal></term> <listitem> <para> ! generates identifiers encoded as strings of hexadecimal digits that ! are unique only within a single VM. <emphasis>Do not use in ! a cluster.</emphasis> </para> </listitem> </varlistentry> <varlistentry> ! <term><literal>assigned</literal></term> <listitem> <para> ! lets the application to assign an identifier to the object before ! <literal>save()</literal> is called. </para> </listitem> </varlistentry> <varlistentry> ! <term><literal>native</literal></term> <listitem> <para> ! supports identity columns in DB2, MySQL, MS SQL Server, Sybase and ! HypersonicSQL. The returned identifier is of type <literal>long</literal> ! (or <literal>integer</literal> in HSQL). </para> </listitem> </varlistentry> <varlistentry> ! <term><literal>sequence</literal></term> <listitem> <para> ! uses a sequence in DB2, PostgreSQL, Oracle, SAP DB, McKoi or a generator ! in Interbase. The returned identifier is of type <literal>long</literal>. </para> </listitem> </varlistentry> <varlistentry> ! <term><literal>hilo.long</literal></term> <listitem> <para> ! uses a hi/lo algorithm to efficiently generate identifiers of ! type <literal>long</literal>, given a table and column ! (by default "hibernate_unique_key" and "next" respectively) as a source ! of hi values. The hi/lo algorithm generates identifiers that are unique ! only for a particular database. <emphasis>Do not use this generator with ! connections enlisted with JTA or with a user-supplied connection.</emphasis> </para> </listitem> </varlistentry> <varlistentry> ! <term><literal>hilo.hex</literal></term> <listitem> <para> ! uses the same hi/lo algorithm to generate strings of hex digits ! (of length 16). <emphasis>Do not use this generator with connections enlisted ! with JTA or with a user-supplied connection.</emphasis> </para> </listitem> </varlistentry> <varlistentry> ! <term><literal>seqhilo.long</literal></term> <listitem> <para> ! uses a hi/lo algorithm to efficiently generate identifiers of ! type <literal>long</literal>, given a named database sequence. </para> </listitem> --- 271,361 ---- <variablelist> <varlistentry> ! <term><literal>vm</literal></term> <listitem> <para> ! generates identifiers of type <literal>long</literal>, <literal>short</literal> or ! <literal>int</literal> that are unique only within a single VM. ! <emphasis>Do not use in a cluster.</emphasis> </para> </listitem> </varlistentry> <varlistentry> ! <term><literal>identity</literal></term> <listitem> <para> ! supports identity columns in DB2, MySQL, MS SQL Server, Sybase and ! HypersonicSQL. The returned identifier is of type <literal>long</literal>, ! <literal>short</literal> or <literal>int</literal>. </para> </listitem> </varlistentry> <varlistentry> ! <term><literal>sequence</literal></term> <listitem> <para> ! uses a sequence in DB2, PostgreSQL, Oracle, SAP DB, McKoi or a generator ! in Interbase. The returned identifier is of type <literal>long</literal>, ! <literal>short</literal> or <literal>int</literal> </para> </listitem> </varlistentry> <varlistentry> ! <term><literal>hilo</literal></term> <listitem> <para> ! uses a hi/lo algorithm to efficiently generate identifiers of ! type <literal>long</literal>, <literal>short</literal> or <literal>int</literal>, ! given a table and column (by default "hibernate_unique_key" and "next" ! respectively) as a source of hi values. The hi/lo algorithm generates identifiers ! that are unique only for a particular database. <emphasis>Do not use this generator ! with connections enlisted with JTA or with a user-supplied connection.</emphasis> </para> </listitem> </varlistentry> <varlistentry> ! <term><literal>seqhilo</literal></term> <listitem> <para> ! uses a hi/lo algorithm to efficiently generate identifiers of ! type <literal>long</literal>, <literal>short</literal> or <literal>int</literal>, ! given a named database sequence. </para> </listitem> </varlistentry> <varlistentry> ! <term><literal>uuid.hex</literal></term> <listitem> <para> ! uses a 128-bit UUID algorithm to generate identifiers of type string, ! unique within a network (the IP address is used). The UUID is encoded ! as a string of hexadecimal digits of length 32. </para> </listitem> </varlistentry> <varlistentry> ! <term><literal>uuid.string</literal></term> <listitem> <para> ! uses the same UUID algorithm. The UUID is encoded a string of length 16 ! consisting of (any) ASCII characters. <emphasis>Do not use with PostgreSQL.</emphasis> </para> </listitem> </varlistentry> <varlistentry> ! <term><literal>native</literal></term> <listitem> <para> ! Picks <literal>identity</literal>, <literal>sequence</literal> or ! <literal>hilo</literal> depending upon the capabilities of the ! underlying database. </para> </listitem> </varlistentry> <varlistentry> ! <term><literal>assigned</literal></term> <listitem> <para> ! lets the application to assign an identifier to the object before ! <literal>save()</literal> is called. </para> </listitem> *************** *** 371,379 **** <para> - The first part of the name refers to the algorithm used. The second part refers - to the type of the resulting identifier. - </para> - - <para> The UUIDs contain: IP address, startup time of the JVM (accurate to a quarter second), system time and a counter value (unique within the JVM). It's not --- 364,367 ---- *************** *** 384,388 **** <para> For databases which support identity columns (DB2, MySQL, Sybase, MS SQL), you ! may use <literal>native</literal> key generation. For databases that support sequences (DB2, Oracle, PostgreSQL, Interbase, McKoi, SAP DB) you may use <literal>sequence</literal> style key generation. Both these strategies require --- 372,376 ---- <para> For databases which support identity columns (DB2, MySQL, Sybase, MS SQL), you ! may use <literal>identity</literal> key generation. For databases that support sequences (DB2, Oracle, PostgreSQL, Interbase, McKoi, SAP DB) you may use <literal>sequence</literal> style key generation. Both these strategies require *************** *** 392,396 **** <programlisting><![CDATA[<id name="id" type="long" column="uid"> <generator class="sequence"> ! <param>uid_sequence</param> </generator> </id>]]></programlisting> --- 380,384 ---- <programlisting><![CDATA[<id name="id" type="long" column="uid"> <generator class="sequence"> ! <param name="sequence">uid_sequence</param> </generator> </id>]]></programlisting> *************** *** 410,415 **** <para> Don't try to use <literal>uuid.string</literal> in PostgreSQL. ! Don't try to use <literal>hilo.long</literal> or <literal>hilo.hex</literal> when ! supplying your own <literal>Connection</literal> to Hibernate, or when Hibernate is using an application server datasource to obtain connections enlisted with JTA. </para> --- 398,403 ---- <para> Don't try to use <literal>uuid.string</literal> in PostgreSQL. ! Don't try to use <literal>hilo</literal> when supplying your own ! <literal>Connection</literal> to Hibernate, or when Hibernate is using an application server datasource to obtain connections enlisted with JTA. </para> *************** *** 643,647 **** <para> The name of a Hibernate basic type (eg. <literal>integer, string, character, ! date, timestamp, float, binary, serializable, object</literal>). </para> </listitem> --- 631,635 ---- <para> The name of a Hibernate basic type (eg. <literal>integer, string, character, ! date, timestamp, float, binary, serializable, object, blob</literal>). </para> </listitem> *************** *** 649,653 **** <para> The name of a Java class with a default basic type (eg. <literal>int, float, ! char, java.lang.String, java.util.Date, java.lang.Integer</literal>). </para> </listitem> --- 637,641 ---- <para> The name of a Java class with a default basic type (eg. <literal>int, float, ! char, java.lang.String, java.util.Date, java.lang.Integer, java.sql.Clob</literal>). </para> </listitem> *************** *** 948,952 **** <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" ! "http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd"> <hibernate-mapping> --- 936,940 ---- <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" ! "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping> *************** *** 961,965 **** <property name="weight"/> <many-to-one name="mate"/> ! <set role="kittens"> <key column="MOTHER"/> <one-to-many class="eg.Cat"/> --- 949,953 ---- <property name="weight"/> <many-to-one name="mate"/> ! <set name="kittens"> <key column="MOTHER"/> <one-to-many class="eg.Cat"/> *************** *** 983,990 **** <para> ! Collections are discussed later. For now we will just mention that a collection ! may be declared either directly beneath the root element of a mapping file or ! as a subelement of a class or component. A collection declared beneath the root ! element may be referenced later by classes, components or other collections. </para> </sect2> --- 971,975 ---- <para> ! Collections are discussed later. </para> </sect2> *************** *** 1139,1147 **** </listitem> </varlistentry> </variablelist> <para> Unique identifiers of entities and collections may be of any basic type except ! <literal>binary</literal>. (Composite identifiers are also allowed, see below.) </para> --- 1124,1144 ---- </listitem> </varlistentry> + <varlistentry> + <term><literal>clob, blob</literal></term> + <listitem> + <para> + Type mappings for the JDBC classes <literal>java.sql.Clob</literal> and + <literal>java.sql.Blob</literal>. These types may be inconvenient for some + applications, since the blob or clob object may not be reused outside of + a transaction. (Furthermore, driver support is patchy and inconsistent.) + </para> + </listitem> + </varlistentry> </variablelist> <para> Unique identifiers of entities and collections may be of any basic type except ! <literal>binary</literal>, <literal>blob</literal> and <literal>clob</literal>. ! (Composite identifiers are also allowed, see below.) </para> Index: examples.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/examples.xml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** examples.xml 1 Jan 2003 13:46:28 -0000 1.1.1.1 --- examples.xml 16 Jan 2003 08:28:45 -0000 1.2 *************** *** 29,33 **** <id name="id"> <generator class="sequence"> ! <param>employer_id_seq</param> </generator> </id> --- 29,33 ---- <id name="id"> <generator class="sequence"> ! <param name="sequence">employer_id_seq</param> </generator> </id> *************** *** 39,43 **** <id name="id"> <generator class="sequence"> ! <param>employment_id_seq</param> </generator> </id> --- 39,43 ---- <id name="id"> <generator class="sequence"> ! <param name="sequence">employment_id_seq</param> </generator> </id> *************** *** 60,64 **** <id name="id"> <generator class="sequence"> ! <param>employee_id_seq</param> </generator> </id> --- 60,64 ---- <id name="id"> <generator class="sequence"> ! <param name="sequence">employee_id_seq</param> </generator> </id> |
From: <one...@us...> - 2003-01-15 12:52:43
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader In directory sc8-pr-cvs1:/tmp/cvs-serv9882/hibernate/loader Modified Files: EntityLoader.java Loader.java OneToManyLoader.java OuterJoinLoader.java Log Message: tidied imports Index: EntityLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/EntityLoader.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** EntityLoader.java 26 Nov 2002 14:47:29 -0000 1.12 --- EntityLoader.java 15 Jan 2003 12:52:40 -0000 1.13 *************** *** 11,16 **** import cirrus.hibernate.engine.SessionImplementor; import cirrus.hibernate.impl.CollectionPersister; - import cirrus.hibernate.persister.*; import cirrus.hibernate.persister.ClassPersister; import cirrus.hibernate.type.Type; --- 11,16 ---- import cirrus.hibernate.engine.SessionImplementor; import cirrus.hibernate.impl.CollectionPersister; import cirrus.hibernate.persister.ClassPersister; + import cirrus.hibernate.persister.Loadable; import cirrus.hibernate.type.Type; Index: Loader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/Loader.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** Loader.java 27 Dec 2002 11:54:48 -0000 1.33 --- Loader.java 15 Jan 2003 12:52:40 -0000 1.34 *************** *** 11,15 **** import java.util.Map; ! import org.apache.commons.logging.*; import cirrus.hibernate.Environment; --- 11,16 ---- import java.util.Map; ! import org.apache.commons.logging.Log; ! import org.apache.commons.logging.LogFactory; import cirrus.hibernate.Environment; *************** *** 24,28 **** import cirrus.hibernate.impl.CollectionPersister; import cirrus.hibernate.impl.QueryImpl; ! import cirrus.hibernate.persister.*; import cirrus.hibernate.type.Type; --- 25,29 ---- import cirrus.hibernate.impl.CollectionPersister; import cirrus.hibernate.impl.QueryImpl; ! import cirrus.hibernate.persister.Loadable; import cirrus.hibernate.type.Type; Index: OneToManyLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/OneToManyLoader.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** OneToManyLoader.java 26 Nov 2002 08:37:25 -0000 1.14 --- OneToManyLoader.java 15 Jan 2003 12:52:40 -0000 1.15 *************** *** 12,16 **** import cirrus.hibernate.engine.SessionImplementor; import cirrus.hibernate.impl.CollectionPersister; ! import cirrus.hibernate.persister.*; import cirrus.hibernate.type.EntityType; import cirrus.hibernate.type.Type; --- 12,16 ---- import cirrus.hibernate.engine.SessionImplementor; import cirrus.hibernate.impl.CollectionPersister; ! import cirrus.hibernate.persister.Loadable; import cirrus.hibernate.type.EntityType; import cirrus.hibernate.type.Type; Index: OuterJoinLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/OuterJoinLoader.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** OuterJoinLoader.java 9 Jan 2003 09:40:19 -0000 1.15 --- OuterJoinLoader.java 15 Jan 2003 12:52:40 -0000 1.16 *************** *** 11,19 **** import cirrus.hibernate.helpers.StringHelper; import cirrus.hibernate.impl.CollectionPersister; - import cirrus.hibernate.persister.*; - import cirrus.hibernate.type.*; import cirrus.hibernate.MappingException; import cirrus.hibernate.sql.Dialect; /** --- 11,24 ---- import cirrus.hibernate.helpers.StringHelper; import cirrus.hibernate.impl.CollectionPersister; import cirrus.hibernate.MappingException; + import cirrus.hibernate.persister.ClassPersister; + import cirrus.hibernate.persister.Loadable; + import cirrus.hibernate.persister.MultiTableEntityPersister; import cirrus.hibernate.sql.Dialect; + import cirrus.hibernate.type.AbstractComponentType; + import cirrus.hibernate.type.EntityType; + import cirrus.hibernate.type.OneToOneType; + import cirrus.hibernate.type.Type; /** |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader In directory sc8-pr-cvs1:/tmp/cvs-serv9590/sf/hibernate/loader Modified Files: CollectionLoader.java EntityLoader.java Loader.java OneToManyLoader.java OuterJoinLoader.java SimpleEntityLoader.java Log Message: added a new exception to stop a flush occuring during cascade Index: CollectionLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/CollectionLoader.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CollectionLoader.java 5 Jan 2003 02:11:21 -0000 1.4 --- CollectionLoader.java 15 Jan 2003 12:49:01 -0000 1.5 *************** *** 12,16 **** import net.sf.hibernate.engine.SessionFactoryImplementor; import net.sf.hibernate.engine.SessionImplementor; ! import net.sf.hibernate.persister.*; import net.sf.hibernate.type.Type; --- 12,16 ---- import net.sf.hibernate.engine.SessionFactoryImplementor; import net.sf.hibernate.engine.SessionImplementor; ! import net.sf.hibernate.persister.Loadable; import net.sf.hibernate.type.Type; Index: EntityLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/EntityLoader.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** EntityLoader.java 5 Jan 2003 02:11:21 -0000 1.4 --- EntityLoader.java 15 Jan 2003 12:49:01 -0000 1.5 *************** *** 11,16 **** import net.sf.hibernate.engine.SessionFactoryImplementor; import net.sf.hibernate.engine.SessionImplementor; - import net.sf.hibernate.persister.*; import net.sf.hibernate.persister.ClassPersister; import net.sf.hibernate.type.Type; --- 11,16 ---- import net.sf.hibernate.engine.SessionFactoryImplementor; import net.sf.hibernate.engine.SessionImplementor; import net.sf.hibernate.persister.ClassPersister; + import net.sf.hibernate.persister.Loadable; import net.sf.hibernate.type.Type; Index: Loader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/Loader.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Loader.java 5 Jan 2003 02:11:21 -0000 1.4 --- Loader.java 15 Jan 2003 12:49:01 -0000 1.5 *************** *** 11,15 **** import java.util.Map; ! import org.apache.commons.logging.*; import net.sf.hibernate.Environment; --- 11,16 ---- import java.util.Map; ! import org.apache.commons.logging.Log; ! import org.apache.commons.logging.LogFactory; import net.sf.hibernate.Environment; *************** *** 24,28 **** import net.sf.hibernate.util.JDBCExceptionReporter; import net.sf.hibernate.util.StringHelper; ! import net.sf.hibernate.persister.*; import net.sf.hibernate.type.Type; --- 25,29 ---- import net.sf.hibernate.util.JDBCExceptionReporter; import net.sf.hibernate.util.StringHelper; ! import net.sf.hibernate.persister.Loadable; import net.sf.hibernate.type.Type; Index: OneToManyLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/OneToManyLoader.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OneToManyLoader.java 5 Jan 2003 02:11:21 -0000 1.4 --- OneToManyLoader.java 15 Jan 2003 12:49:01 -0000 1.5 *************** *** 12,16 **** import net.sf.hibernate.engine.SessionFactoryImplementor; import net.sf.hibernate.engine.SessionImplementor; ! import net.sf.hibernate.persister.*; import net.sf.hibernate.type.EntityType; import net.sf.hibernate.type.Type; --- 12,16 ---- import net.sf.hibernate.engine.SessionFactoryImplementor; import net.sf.hibernate.engine.SessionImplementor; ! import net.sf.hibernate.persister.Loadable; import net.sf.hibernate.type.EntityType; import net.sf.hibernate.type.Type; Index: OuterJoinLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/OuterJoinLoader.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** OuterJoinLoader.java 9 Jan 2003 12:24:51 -0000 1.5 --- OuterJoinLoader.java 15 Jan 2003 12:49:01 -0000 1.6 *************** *** 7,19 **** import java.util.Set; - import net.sf.hibernate.engine.SessionFactoryImplementor; - import net.sf.hibernate.util.ArrayHelper; - import net.sf.hibernate.util.StringHelper; - import net.sf.hibernate.persister.*; - import net.sf.hibernate.type.*; - import net.sf.hibernate.MappingException; import net.sf.hibernate.collection.CollectionPersister; import net.sf.hibernate.dialect.Dialect; /** --- 7,23 ---- import java.util.Set; import net.sf.hibernate.MappingException; import net.sf.hibernate.collection.CollectionPersister; import net.sf.hibernate.dialect.Dialect; + import net.sf.hibernate.engine.SessionFactoryImplementor; + import net.sf.hibernate.persister.ClassPersister; + import net.sf.hibernate.persister.Loadable; + import net.sf.hibernate.persister.MultiTableEntityPersister; + import net.sf.hibernate.type.AbstractComponentType; + import net.sf.hibernate.type.EntityType; + import net.sf.hibernate.type.OneToOneType; + import net.sf.hibernate.type.Type; + import net.sf.hibernate.util.ArrayHelper; + import net.sf.hibernate.util.StringHelper; /** Index: SimpleEntityLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/SimpleEntityLoader.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SimpleEntityLoader.java 5 Jan 2003 02:11:21 -0000 1.4 --- SimpleEntityLoader.java 15 Jan 2003 12:49:01 -0000 1.5 *************** *** 10,14 **** import net.sf.hibernate.collection.CollectionPersister; import net.sf.hibernate.engine.SessionImplementor; ! import net.sf.hibernate.persister.*; import net.sf.hibernate.type.Type; --- 10,14 ---- import net.sf.hibernate.collection.CollectionPersister; import net.sf.hibernate.engine.SessionImplementor; ! import net.sf.hibernate.persister.Loadable; import net.sf.hibernate.type.Type; |
From: <one...@us...> - 2003-01-15 12:49:04
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv9590/sf/hibernate/impl Modified Files: SessionImpl.java Log Message: added a new exception to stop a flush occuring during cascade Index: SessionImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionImpl.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SessionImpl.java 15 Jan 2003 10:33:17 -0000 1.9 --- SessionImpl.java 15 Jan 2003 12:49:01 -0000 1.10 *************** *** 123,126 **** --- 123,127 ---- private transient int dontFlushFromFind = 0; private transient boolean reentrantCallback = false; + private transient int cascading = 0; private transient Batcher batcher; *************** *** 591,595 **** // cascade-save to many-to-one BEFORE the parent is saved ! Cascades.cascade(this, persister, object, Cascades.ACTION_SAVE_UPDATE, Cascades.CASCADE_BEFORE_INSERT_AFTER_DELETE); Object[] values = persister.getPropertyValues(object); --- 592,602 ---- // cascade-save to many-to-one BEFORE the parent is saved ! cascading++; ! try { ! Cascades.cascade(this, persister, object, Cascades.ACTION_SAVE_UPDATE, Cascades.CASCADE_BEFORE_INSERT_AFTER_DELETE); ! } ! finally { ! cascading--; ! } Object[] values = persister.getPropertyValues(object); *************** *** 631,635 **** // cascade-save to collections AFTER the collection owner was saved ! Cascades.cascade(this, persister, object, Cascades.ACTION_SAVE_UPDATE, Cascades.CASCADE_AFTER_INSERT_BEFORE_DELETE); return id; --- 638,648 ---- // cascade-save to collections AFTER the collection owner was saved ! cascading++; ! try { ! Cascades.cascade(this, persister, object, Cascades.ACTION_SAVE_UPDATE, Cascades.CASCADE_AFTER_INSERT_BEFORE_DELETE); ! } ! finally { ! cascading--; ! } return id; *************** *** 840,843 **** --- 853,857 ---- nullifiables = oldNullifiables; + cascading++; try { // cascade-delete to collections "BEFORE" the collection owner is deleted *************** *** 845,848 **** --- 859,863 ---- } finally { + cascading--; newNullifiables.addAll(oldNullifiables); nullifiables = newNullifiables; *************** *** 1057,1061 **** if (proxy!=object) proxiesByKey.put(key, proxy); ! Cascades.cascade(this, persister, object, Cascades.ACTION_SAVE_UPDATE, Cascades.CASCADE_ON_UPDATE); // do cascade } --- 1072,1082 ---- if (proxy!=object) proxiesByKey.put(key, proxy); ! cascading++; ! try { ! Cascades.cascade(this, persister, object, Cascades.ACTION_SAVE_UPDATE, Cascades.CASCADE_ON_UPDATE); // do cascade ! } ! finally { ! cascading--; ! } } *************** *** 1683,1686 **** --- 1704,1710 ---- */ public void flush() throws HibernateException { + if (cascading>0) throw new HibernateException( + "Flush during cascade is dangerous - this might occur if an object was deleted and then re-saved by cascade" + ); flushEverything(); execute(); *************** *** 1917,1921 **** if ( status!=LOADING && status!=GONE && status!=DELETED ) { Object object = me.getKey(); ! Cascades.cascade(this, entry.persister, object, Cascades.ACTION_SAVE_UPDATE, Cascades.CASCADE_ON_UPDATE); } } --- 1941,1951 ---- if ( status!=LOADING && status!=GONE && status!=DELETED ) { Object object = me.getKey(); ! cascading++; ! try { ! Cascades.cascade(this, entry.persister, object, Cascades.ACTION_SAVE_UPDATE, Cascades.CASCADE_ON_UPDATE); ! } ! finally { ! cascading--; ! } } } |
From: <one...@us...> - 2003-01-15 12:49:04
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister In directory sc8-pr-cvs1:/tmp/cvs-serv9590/sf/hibernate/persister Modified Files: ClassPersister.java Log Message: added a new exception to stop a flush occuring during cascade Index: ClassPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister/ClassPersister.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ClassPersister.java 5 Jan 2003 02:11:22 -0000 1.3 --- ClassPersister.java 15 Jan 2003 12:49:01 -0000 1.4 *************** *** 4,8 **** import java.io.Serializable; import java.lang.reflect.Method; ! import java.sql.*; import net.sf.hibernate.HibernateException; --- 4,8 ---- import java.io.Serializable; import java.lang.reflect.Method; ! import java.sql.SQLException; import net.sf.hibernate.HibernateException; |
From: <one...@us...> - 2003-01-15 12:49:04
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/ps In directory sc8-pr-cvs1:/tmp/cvs-serv9590/sf/hibernate/ps Modified Files: PreparedStatementCache.java Log Message: added a new exception to stop a flush occuring during cascade Index: PreparedStatementCache.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/ps/PreparedStatementCache.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PreparedStatementCache.java 5 Jan 2003 02:11:22 -0000 1.4 --- PreparedStatementCache.java 15 Jan 2003 12:49:01 -0000 1.5 *************** *** 2,11 **** package net.sf.hibernate.ps; ! import java.sql.*; ! import org.apache.commons.logging.*; ! import java.util.*; import net.sf.hibernate.util.IdentityMap; import net.sf.hibernate.util.JDBCExceptionReporter; /** --- 2,21 ---- package net.sf.hibernate.ps; ! import java.sql.Connection; ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! import java.util.ArrayList; ! import java.util.HashMap; ! import java.util.Iterator; ! import java.util.LinkedList; ! import java.util.List; ! import java.util.Map; import net.sf.hibernate.util.IdentityMap; import net.sf.hibernate.util.JDBCExceptionReporter; + + import org.apache.commons.logging.Log; + import org.apache.commons.logging.LogFactory; /** |
From: <one...@us...> - 2003-01-15 10:33:20
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type In directory sc8-pr-cvs1:/tmp/cvs-serv30115/sf/hibernate/type Modified Files: TimestampType.java TrueFalseType.java Log Message: fixed bug in TimestampType now possible to delete and re-save an object in same session Index: TimestampType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/TimestampType.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TimestampType.java 5 Jan 2003 02:11:24 -0000 1.4 --- TimestampType.java 15 Jan 2003 10:33:17 -0000 1.5 *************** *** 38,46 **** public Object deepCopyNotNull(Object value) { - Timestamp copy = new Timestamp( ( (java.util.Date) value ).getTime() ); if ( value instanceof Timestamp ) { ! copy.setNanos( ( (Timestamp) value ).getNanos() ); } - return copy; } --- 38,51 ---- public Object deepCopyNotNull(Object value) { if ( value instanceof Timestamp ) { ! Timestamp orig = (Timestamp) value; ! Timestamp ts = new Timestamp( orig.getTime() ); ! ts.setNanos( orig.getNanos() ); ! return ts; ! } ! else { ! java.util.Date orig = (java.util.Date) value; ! return new java.util.Date( orig.getTime() ); } } *************** *** 49,60 **** if (x==y) return true; if (x==null || y==null) return false; - - /*if ( - x instanceof Timestamp && - y instanceof Timestamp && - ( (Timestamp) x ).getNanos() != ( (Timestamp) y ).getNanos() - ) return false; - - return ( (java.util.Date) x ).getTime()==( (java.util.Date) y ).getTime();*/ long xTime = ( (java.util.Date) x ).getTime(); --- 54,57 ---- Index: TrueFalseType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/TrueFalseType.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TrueFalseType.java 5 Jan 2003 02:11:24 -0000 1.3 --- TrueFalseType.java 15 Jan 2003 10:33:17 -0000 1.4 *************** *** 1,4 **** --- 1,5 ---- //$Id$ package net.sf.hibernate.type; + public class TrueFalseType extends CharBooleanType { |
From: <one...@us...> - 2003-01-15 10:33:20
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv30115/sf/hibernate/test Modified Files: FooBarTest.java Log Message: fixed bug in TimestampType now possible to delete and re-save an object in same session Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** FooBarTest.java 12 Jan 2003 15:04:52 -0000 1.9 --- FooBarTest.java 15 Jan 2003 10:33:17 -0000 1.10 *************** *** 2,24 **** package net.sf.hibernate.test; - import net.sf.hibernate.*; - import net.sf.hibernate.Databinder; - import net.sf.hibernate.connection.ConnectionProvider; - import net.sf.hibernate.connection.DriverManagerConnectionProvider; - import net.sf.hibernate.dialect.DB2Dialect; - import net.sf.hibernate.dialect.HSQLDialect; - import net.sf.hibernate.dialect.InterbaseDialect; - import net.sf.hibernate.dialect.MckoiDialect; - import net.sf.hibernate.dialect.MySQLDialect; - import net.sf.hibernate.dialect.OracleDialect; - import net.sf.hibernate.dialect.PointbaseDialect; - import net.sf.hibernate.dialect.PostgreSQLDialect; - import net.sf.hibernate.dialect.SAPDBDialect; - import net.sf.hibernate.dialect.SybaseDialect; - import net.sf.hibernate.type.DateType; - import net.sf.hibernate.type.EntityType; - import net.sf.hibernate.type.StringType; - import net.sf.hibernate.type.Type; - import java.io.Serializable; import java.sql.Connection; --- 2,5 ---- *************** *** 38,45 **** import java.util.TreeSet; - import org.apache.commons.lang.SerializationUtils; - import junit.framework.Test; import junit.framework.TestSuite; public class FooBarTest extends TestCase { --- 19,53 ---- import java.util.TreeSet; import junit.framework.Test; import junit.framework.TestSuite; + import net.sf.hibernate.Databinder; + import net.sf.hibernate.Environment; + import net.sf.hibernate.Hibernate; + import net.sf.hibernate.LazyInitializationException; + import net.sf.hibernate.LockMode; + import net.sf.hibernate.ObjectDeletedException; + import net.sf.hibernate.ObjectNotFoundException; + import net.sf.hibernate.Query; + import net.sf.hibernate.ScrollableResults; + import net.sf.hibernate.Session; + import net.sf.hibernate.Transaction; + import net.sf.hibernate.connection.ConnectionProvider; + import net.sf.hibernate.connection.DriverManagerConnectionProvider; + import net.sf.hibernate.dialect.DB2Dialect; + import net.sf.hibernate.dialect.HSQLDialect; + import net.sf.hibernate.dialect.InterbaseDialect; + import net.sf.hibernate.dialect.MckoiDialect; + import net.sf.hibernate.dialect.MySQLDialect; + import net.sf.hibernate.dialect.OracleDialect; + import net.sf.hibernate.dialect.PointbaseDialect; + import net.sf.hibernate.dialect.PostgreSQLDialect; + import net.sf.hibernate.dialect.SAPDBDialect; + import net.sf.hibernate.dialect.SybaseDialect; + import net.sf.hibernate.type.DateType; + import net.sf.hibernate.type.EntityType; + import net.sf.hibernate.type.StringType; + import net.sf.hibernate.type.Type; + + import org.apache.commons.lang.SerializationUtils; public class FooBarTest extends TestCase { *************** *** 51,54 **** --- 59,75 ---- } + public void testAfterDelete() throws Exception { + Session s = sessions.openSession(); + Foo foo = new Foo(); + s.save(foo); + s.flush(); + s.delete(foo); + s.save(foo); + s.delete(foo); + s.flush(); + s.connection().commit(); + s.close(); + } + public void testAssociationId() throws Exception { Session s = sessions.openSession(); *************** *** 2700,2706 **** err=false; try { ! s.load(Foo.class, id); } ! catch (ObjectDeletedException ode) { err=true; } --- 2721,2727 ---- err=false; try { ! ( (Foo) s.load(Foo.class, id) ).getBool(); } ! catch (LazyInitializationException onfe) { err=true; } *************** *** 2724,2728 **** s.load(Fo.class, id); } ! catch (ObjectDeletedException ode) { err=true; } --- 2745,2749 ---- s.load(Fo.class, id); } ! catch (ObjectNotFoundException onfe) { err=true; } |
From: <one...@us...> - 2003-01-15 10:33:19
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv30115/sf/hibernate/impl Modified Files: SessionImpl.java Log Message: fixed bug in TimestampType now possible to delete and re-save an object in same session Index: SessionImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionImpl.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SessionImpl.java 14 Jan 2003 13:42:13 -0000 1.8 --- SessionImpl.java 15 Jan 2003 10:33:17 -0000 1.9 *************** *** 493,509 **** EntityEntry e = getEntry(object); if ( e!=null ) { ! log.trace( "object already associated with session" ); ! return e.id; ! } ! else { ! Serializable id; ! try { ! id = getPersister(object).getIdentifierGenerator().generate(this, object); } ! catch (SQLException sqle) { ! throw new JDBCException("Could not save object", sqle); } - return doSave(object, id); } } --- 493,514 ---- EntityEntry e = getEntry(object); if ( e!=null ) { ! if ( e.status==DELETED ) { ! flush(); } ! else { ! log.trace( "object already associated with session" ); ! return e.id; } } + + Serializable id; + try { + id = getPersister(object).getIdentifierGenerator().generate(this, object); + } + catch (SQLException sqle) { + throw new JDBCException("Could not save object", sqle); + } + return doSave(object, id); + } *************** *** 518,530 **** EntityEntry e = getEntry(object); if ( e!=null ) { ! if ( !id.equals(e.id) ) throw new PersistentObjectException( ! "object passed to save() was already persistent: " + ! infoString(e.persister, id) ! ); ! log.trace( "object already associated with session" ); ! } ! else { ! doSave(object, id); } } --- 523,539 ---- EntityEntry e = getEntry(object); if ( e!=null ) { ! if ( e.status==DELETED ) { ! flush(); ! } ! else { ! if ( !id.equals(e.id) ) throw new PersistentObjectException( ! "object passed to save() was already persistent: " + ! infoString(e.persister, id) ! ); ! log.trace( "object already associated with session" ); ! } } + + doSave(object, id); } *************** *** 552,559 **** key = new Key(id, persister); ! if ( getEntity(key) != null ) throw new HibernateException( ! "The generated ID is already in use: " + ! infoString(persister, id) ! ); persister.setIdentifier(object, id); --- 561,576 ---- key = new Key(id, persister); ! Object old = getEntity(key); ! if (old!= null) { ! if ( getEntry(old).status==DELETED ) { ! flush(); ! } ! else { ! throw new HibernateException( ! "The generated identifier is already in use: " + ! infoString(persister, id) ! ); ! } ! } persister.setIdentifier(object, id); *************** *** 954,961 **** Object object = HibernateProxyHelper.unproxy(obj, this); ! if ( isEntryFor(object) ) { // do nothing for persistent instances log.trace("object already associated with session"); } else { --- 971,982 ---- Object object = HibernateProxyHelper.unproxy(obj, this); ! EntityEntry e = getEntry(object); ! if (e!=null && e.status!=DELETED) { // do nothing for persistent instances log.trace("object already associated with session"); } + else if (e!=null) { //e.status==DELETED + save(object); + } else { *************** *** 978,983 **** } ! } ! } --- 999,1003 ---- } ! } } *************** *** 1019,1023 **** ); } ! else if ( old!=null ) { throw new HibernateException( "Another object was associated with this id (the object with the given id was already loaded): " + --- 1039,1043 ---- ); } ! else if (old!=null) { throw new HibernateException( "Another object was associated with this id (the object with the given id was already loaded): " + *************** *** 1737,1741 **** public void postDelete(Object obj) { ! getEntry(obj).existsInDatabase = false; } --- 1757,1765 ---- public void postDelete(Object obj) { ! EntityEntry e = removeEntry(obj); ! Key key = new Key(e.id, e.persister); ! removeEntity(key); ! proxiesByKey.remove(key); ! //getEntry(obj).existsInDatabase = false; } *************** *** 1863,1867 **** if (status==DELETED) { ! entry.status = GONE; //for next time } else { --- 1887,1891 ---- if (status==DELETED) { ! entry.status = GONE; } else { |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection In directory sc8-pr-cvs1:/tmp/cvs-serv30115/sf/hibernate/connection Modified Files: C3P0ConnectionProvider.java ConnectionProviderFactory.java DBCPConnectionProvider.java DriverManagerConnectionProvider.java Log Message: fixed bug in TimestampType now possible to delete and re-save an object in same session Index: C3P0ConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection/C3P0ConnectionProvider.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** C3P0ConnectionProvider.java 5 Jan 2003 02:11:20 -0000 1.3 --- C3P0ConnectionProvider.java 15 Jan 2003 10:33:16 -0000 1.4 *************** *** 60,64 **** String jdbcDriverClass = props.getProperty(Environment.DRIVER); String jdbcUrl = props.getProperty(Environment.URL); ! Properties connectionProps = ConnectionProviderFactory.getJdbcConnectionProperties(props); log.info("C3P0 using driver: " + jdbcDriverClass + " at URL: " + jdbcUrl); --- 60,64 ---- String jdbcDriverClass = props.getProperty(Environment.DRIVER); String jdbcUrl = props.getProperty(Environment.URL); ! Properties connectionProps = ConnectionProviderFactory.getConnectionProperties(props); log.info("C3P0 using driver: " + jdbcDriverClass + " at URL: " + jdbcUrl); Index: ConnectionProviderFactory.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection/ConnectionProviderFactory.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ConnectionProviderFactory.java 12 Jan 2003 07:07:48 -0000 1.4 --- ConnectionProviderFactory.java 15 Jan 2003 10:33:16 -0000 1.5 *************** *** 5,8 **** --- 5,9 ---- import java.util.Iterator; import java.util.Properties; + import java.util.Set; import org.apache.commons.logging.Log; *************** *** 83,96 **** * format accepted by <tt>DriverManager</tt> by triming the leading "<tt>hibernate.connection</tt>". */ ! public static Properties getJdbcConnectionProperties(Properties properties) { ! ! HashSet specialProps = new HashSet(); ! specialProps.add(Environment.DATASOURCE); ! specialProps.add(Environment.URL); ! specialProps.add(Environment.CONNECTION_PROVIDER); ! specialProps.add(Environment.POOL_SIZE); ! specialProps.add(Environment.ISOLATION); ! specialProps.add(Environment.DRIVER); ! specialProps.add(Environment.USER); Iterator iter = properties.keySet().iterator(); --- 84,88 ---- * format accepted by <tt>DriverManager</tt> by triming the leading "<tt>hibernate.connection</tt>". */ ! public static Properties getConnectionProperties(Properties properties) { Iterator iter = properties.keySet().iterator(); *************** *** 98,102 **** while ( iter.hasNext() ) { String prop = (String) iter.next(); ! if ( prop.indexOf(Environment.CONNECTION_PREFIX) > -1 && !specialProps.contains(prop) ) { result.setProperty( prop.substring( Environment.CONNECTION_PREFIX.length()+1 ), --- 90,94 ---- while ( iter.hasNext() ) { String prop = (String) iter.next(); ! if ( prop.indexOf(Environment.CONNECTION_PREFIX) > -1 && !specialProperties.contains(prop) ) { result.setProperty( prop.substring( Environment.CONNECTION_PREFIX.length()+1 ), *************** *** 108,111 **** --- 100,116 ---- if (userName!=null) result.setProperty( "user", userName ); return result; + } + + private static final Set specialProperties; + static { + specialProperties = new HashSet(); + specialProperties.add(Environment.DATASOURCE); + specialProperties.add(Environment.URL); + specialProperties.add(Environment.CONNECTION_PROVIDER); + specialProperties.add(Environment.POOL_SIZE); + specialProperties.add(Environment.ISOLATION); + specialProperties.add(Environment.DRIVER); + specialProperties.add(Environment.USER); + } Index: DBCPConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection/DBCPConnectionProvider.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DBCPConnectionProvider.java 5 Jan 2003 02:11:20 -0000 1.3 --- DBCPConnectionProvider.java 15 Jan 2003 10:33:17 -0000 1.4 *************** *** 65,69 **** String jdbcDriverClass = props.getProperty(Environment.DRIVER); String jdbcUrl = props.getProperty(Environment.URL); ! Properties connectionProps = ConnectionProviderFactory.getJdbcConnectionProperties(props); log.info("DBCP using driver: " + jdbcDriverClass + " at URL: " + jdbcUrl); --- 65,69 ---- String jdbcDriverClass = props.getProperty(Environment.DRIVER); String jdbcUrl = props.getProperty(Environment.URL); ! Properties connectionProps = ConnectionProviderFactory.getConnectionProperties(props); log.info("DBCP using driver: " + jdbcDriverClass + " at URL: " + jdbcUrl); Index: DriverManagerConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection/DriverManagerConnectionProvider.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DriverManagerConnectionProvider.java 5 Jan 2003 02:11:20 -0000 1.4 --- DriverManagerConnectionProvider.java 15 Jan 2003 10:33:17 -0000 1.5 *************** *** 65,69 **** } ! connectionProps = ConnectionProviderFactory.getJdbcConnectionProperties(props); log.info( "using driver: " + driverClass + " at URL: " + url ); --- 65,69 ---- } ! connectionProps = ConnectionProviderFactory.getConnectionProperties(props); log.info( "using driver: " + driverClass + " at URL: " + url ); |
From: <one...@us...> - 2003-01-15 10:28:42
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/type In directory sc8-pr-cvs1:/tmp/cvs-serv29686/hibernate/type Modified Files: TimestampType.java Log Message: fixed an NPE when username was not specied fixed a bug in TimestampType Index: TimestampType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/TimestampType.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** TimestampType.java 25 Dec 2002 01:02:16 -0000 1.33 --- TimestampType.java 15 Jan 2003 10:28:39 -0000 1.34 *************** *** 2,6 **** package cirrus.hibernate.type; ! import java.sql.*; import java.text.SimpleDateFormat; --- 2,10 ---- package cirrus.hibernate.type; ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! import java.sql.Timestamp; ! import java.sql.Types; import java.text.SimpleDateFormat; *************** *** 34,42 **** public Object deepCopyNotNull(Object value) { - Timestamp copy = new Timestamp( ( (java.util.Date) value ).getTime() ); if ( value instanceof Timestamp ) { ! copy.setNanos( ( (Timestamp) value ).getNanos() ); } - return copy; } --- 38,51 ---- public Object deepCopyNotNull(Object value) { if ( value instanceof Timestamp ) { ! Timestamp orig = (Timestamp) value; ! Timestamp ts = new Timestamp( orig.getTime() ); ! ts.setNanos( orig.getNanos() ); ! return ts; ! } ! else { ! java.util.Date orig = (java.util.Date) value; ! return new java.util.Date( orig.getTime() ); } } |
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/connection In directory sc8-pr-cvs1:/tmp/cvs-serv29686/hibernate/connection Modified Files: C3P0ConnectionProvider.java ConnectionProviderFactory.java DBCPConnectionProvider.java DriverManagerConnectionProvider.java Log Message: fixed an NPE when username was not specied fixed a bug in TimestampType Index: C3P0ConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/connection/C3P0ConnectionProvider.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** C3P0ConnectionProvider.java 27 Dec 2002 11:54:48 -0000 1.18 --- C3P0ConnectionProvider.java 15 Jan 2003 10:28:39 -0000 1.19 *************** *** 60,64 **** String jdbcDriverClass = props.getProperty(Environment.DRIVER); String jdbcUrl = props.getProperty(Environment.URL); ! Properties connectionProps = ConnectionProviderFactory.getJdbcConnectionProperties(props); log.info("C3P0 using driver: " + jdbcDriverClass + " at URL: " + jdbcUrl); --- 60,64 ---- String jdbcDriverClass = props.getProperty(Environment.DRIVER); String jdbcUrl = props.getProperty(Environment.URL); ! Properties connectionProps = ConnectionProviderFactory.getConnectionProperties(props); log.info("C3P0 using driver: " + jdbcDriverClass + " at URL: " + jdbcUrl); Index: ConnectionProviderFactory.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/connection/ConnectionProviderFactory.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ConnectionProviderFactory.java 1 Jan 2003 03:03:16 -0000 1.11 --- ConnectionProviderFactory.java 15 Jan 2003 10:28:39 -0000 1.12 *************** *** 83,87 **** * format accepted by <tt>DriverManager</tt> by triming the leading "<tt>hibernate.connection</tt>". */ ! public static Properties getJdbcConnectionProperties(Properties properties) { HashSet specialProps = new HashSet(); --- 83,87 ---- * format accepted by <tt>DriverManager</tt> by triming the leading "<tt>hibernate.connection</tt>". */ ! public static Properties getConnectionProperties(Properties properties) { HashSet specialProps = new HashSet(); *************** *** 105,109 **** } } ! result.setProperty( "user", properties.getProperty(Environment.USER) ); return result; } --- 105,110 ---- } } ! String userName = properties.getProperty(Environment.USER); ! if (userName!=null) result.setProperty( "user", userName ); return result; } Index: DBCPConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/connection/DBCPConnectionProvider.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DBCPConnectionProvider.java 27 Dec 2002 11:54:48 -0000 1.6 --- DBCPConnectionProvider.java 15 Jan 2003 10:28:39 -0000 1.7 *************** *** 65,69 **** String jdbcDriverClass = props.getProperty(Environment.DRIVER); String jdbcUrl = props.getProperty(Environment.URL); ! Properties connectionProps = ConnectionProviderFactory.getJdbcConnectionProperties(props); log.info("DBCP using driver: " + jdbcDriverClass + " at URL: " + jdbcUrl); --- 65,69 ---- String jdbcDriverClass = props.getProperty(Environment.DRIVER); String jdbcUrl = props.getProperty(Environment.URL); ! Properties connectionProps = ConnectionProviderFactory.getConnectionProperties(props); log.info("DBCP using driver: " + jdbcDriverClass + " at URL: " + jdbcUrl); Index: DriverManagerConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/connection/DriverManagerConnectionProvider.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** DriverManagerConnectionProvider.java 23 Nov 2002 00:24:17 -0000 1.18 --- DriverManagerConnectionProvider.java 15 Jan 2003 10:28:39 -0000 1.19 *************** *** 61,65 **** } ! connectionProps = ConnectionProviderFactory.getJdbcConnectionProperties(props); log.info( "Using driver: " + driverClass + " at URL: " + url ); --- 61,65 ---- } ! connectionProps = ConnectionProviderFactory.getConnectionProperties(props); log.info( "Using driver: " + driverClass + " at URL: " + url ); |
From: <one...@us...> - 2003-01-14 14:07:39
|
Update of /cvsroot/hibernate/Hibernate2/doc/api In directory sc8-pr-cvs1:/tmp/cvs-serv30892/doc/api Modified Files: package.html Log Message: fixed Javadoc bugs Index: package.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/api/package.html,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** package.html 1 Jan 2003 13:42:58 -0000 1.1.1.1 --- package.html 14 Jan 2003 14:07:01 -0000 1.2 *************** *** 3,26 **** This documentation concentrates upon the <b>Core API</b> interfaces: ! <li><tt>cirrus.hibernate.Hibernate</tt></li> ! <li><tt>cirrus.hibernate.Session</tt></li> ! <li><tt>cirrus.hibernate.SessionFactory</tt></li> ! <li><tt>cirrus.hibernate.Transaction</tt></li> ! <li><tt>cirrus.hibernate.Datastore</tt></li> These interfaces are exposed to the application.<br> <br> ! The <b>Extension API</b> is intended to be used by application programmers ! to extend Hibernate functionality. None of these interfaces are intended to be exposed to the application - they are called internally by Hibernate. ! This API is less stable than the Core API. The safest way to extend ! functionality is to contribute extensions back to the project; that way extensions will be updated when the Extension API changes.<br> <br> Full Hibernate documentation may be found at <a href="http://hibernate.sourceforge.net">hibernate.sourceforge.net</a>. ! @see cirrus.hibernate.Hibernate ! @see cirrus.hibernate.Session ! @see cirrus.hibernate.SessionFactory ! @see cirrus.hibernate.Transaction ! @see cirrus.hibernate.Datastore </body> --- 3,28 ---- This documentation concentrates upon the <b>Core API</b> interfaces: ! <li><tt>net.sf.hibernate.Hibernate</tt></li> ! <li><tt>net.sf.hibernate.Session</tt></li> ! <li><tt>net.sf.hibernate.SessionFactory</tt></li> ! <li><tt>net.sf.hibernate.Transaction</tt></li> ! <li><tt>net.sf.hibernate.Query</tt></li> ! <li><tt>net.sf.hibernate.ScrollableResults</tt></li> These interfaces are exposed to the application.<br> <br> ! The <b>Extension API</b> is intended to be used by application programmers ! to extend Hibernate functionality. None of these interfaces are intended to be exposed to the application - they are called internally by Hibernate. ! This API is less stable than the Core API. The safest way to extend ! functionality is to contribute extensions back to the project; that way extensions will be updated when the Extension API changes.<br> <br> Full Hibernate documentation may be found at <a href="http://hibernate.sourceforge.net">hibernate.sourceforge.net</a>. ! @see net.sf.hibernate.Hibernate ! @see net.sf.hibernate.Session ! @see net.sf.hibernate.SessionFactory ! @see net.sf.hibernate.Transaction ! @see net.sf.hibernate.Query ! @see net.sf.hibernate.ScrollableResults </body> |
From: <one...@us...> - 2003-01-14 14:07:34
|
Update of /cvsroot/hibernate/Hibernate2 In directory sc8-pr-cvs1:/tmp/cvs-serv30892 Modified Files: build.xml Log Message: fixed Javadoc bugs Index: build.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/build.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** build.xml 13 Jan 2003 09:11:52 -0000 1.2 --- build.xml 14 Jan 2003 14:07:00 -0000 1.3 *************** *** 136,140 **** <javadoc sourcepath="${src.dir}" ! packagenames="net.sf.hibernate,net.sf.hibernate.id,net.sf.hibernate.connection,net.sf.hibernate.transaction,net.sf.hibernate.type,net.sf.hibernate.sql,net.sf.hibernate.odmg,net.sf..hibernate.ejb,net.sf.hibernate.cfg,net.sf.hibernate.cache,net.sf.hibernate.jmx,net.sf.hibernate.loader,net.sf.hibernate.persister,net.sf.hibernate.engine,net.sf.hibernate.metadata" classpathref="lib.class.path" destdir="${dist.api.dir}" --- 136,140 ---- <javadoc sourcepath="${src.dir}" ! packagenames="net.sf.hibernate,net.sf.hibernate.id,net.sf.hibernate.connection,net.sf.hibernate.transaction,net.sf.hibernate.type,net.sf.hibernate.dialect,net.sf.hibernate.odmg,net.sf.hibernate.cfg,net.sf.hibernate.cache,net.sf.hibernate.jmx,net.sf.hibernate.loader,net.sf.hibernate.persister,net.sf.hibernate.engine,net.sf.hibernate.metadata" classpathref="lib.class.path" destdir="${dist.api.dir}" *************** *** 149,154 **** <group title="Core API" packages="net.sf.hibernate:net.sf.hibernate.metadata"/> ! <group title="Extension API" packages="net.sf.hibernate.id:net.sf.hibernate.connection:net.sf.hibernate.transaction:net.sf.hibernate.type:net.sf.hibernate.sql:net.sf.hibernate.cache:net.sf.hibernate.loader:net.sf.hibernate.persister:net.sf.hibernate.engine"/> ! <group title="Extras" packages="net.sf.hibernate.odmg:net.sf.hibernate.cfg:net.sf.hibernate.ejb:net.sf.hibernate.jmx"/> </javadoc> --- 149,154 ---- <group title="Core API" packages="net.sf.hibernate:net.sf.hibernate.metadata"/> ! <group title="Extension API" packages="net.sf.hibernate.id:net.sf.hibernate.connection:net.sf.hibernate.transaction:net.sf.hibernate.type:net.sf.hibernate.dialect:net.sf.hibernate.cache:net.sf.hibernate.loader:net.sf.hibernate.persister:net.sf.hibernate.engine"/> ! <group title="Extras" packages="net.sf.hibernate.odmg:net.sf.hibernate.cfg:net.sf.hibernate.jmx"/> </javadoc> |
From: <one...@us...> - 2003-01-14 14:07:19
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv30892/src/net/sf/hibernate Modified Files: Query.java Session.java SessionFactory.java Log Message: fixed Javadoc bugs Index: Query.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/Query.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Query.java 14 Jan 2003 13:42:06 -0000 1.4 --- Query.java 14 Jan 2003 14:07:02 -0000 1.5 *************** *** 71,75 **** * * @return the result iterator - * @throws SQLException * @throws HibernateException */ --- 71,74 ---- *************** *** 85,89 **** * @see ScrollableResults * @return the result iterator - * @throws SQLException * @throws HibernateException */ --- 84,87 ---- *************** *** 95,99 **** * * @return the result list - * @throws SQLException * @throws HibernateException */ --- 93,96 ---- Index: Session.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/Session.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Session.java 14 Jan 2003 13:42:07 -0000 1.5 --- Session.java 14 Jan 2003 14:07:04 -0000 1.6 *************** *** 71,75 **** * persistable state held in memory. * - * @throws SQLException * @throws HibernateException */ --- 71,74 ---- *************** *** 99,103 **** * @return the JDBC connection in use by the <tt>Session</tt> * @throws HibernateException if the <tt>Session</tt> is disconnected - * @throws SQLException */ public Connection connection() throws HibernateException; --- 98,101 ---- *************** *** 112,116 **** * @return the connection provided by the application or <tt>null</tt> * @throws HibernateException if the <tt>Session</tt> is disconnected - * @throws SQLException * @see Session#reconnect() */ --- 110,113 ---- *************** *** 121,125 **** * require long transactions. * - * @throws SQLException * @see Session#disconnect() */ --- 118,121 ---- *************** *** 143,147 **** * @return the connection provided by the application * or <tt>null</tt> - * @throws SQLException * @throws HibernateException */ --- 139,142 ---- *************** *** 181,185 **** * @param lockMode the lock level * @return the persistent instance - * @throws SQLException * @throws HibernateException */ --- 176,179 ---- *************** *** 192,196 **** * @param id a valid identifier of an existing persistent instance of the class * @return the persistent instance - * @throws SQLException * @throws HibernateException */ --- 186,189 ---- *************** *** 202,206 **** * @param object an "empty" instance of the persistent class * @param id a valid identifier of an existing persistent instance of the class - * @throws SQLException * @throws HibernateException */ --- 195,198 ---- *************** *** 214,218 **** * @param object a transient instance of a persistent class * @return the generated identifier - * @throws SQLException * @throws HibernateException */ --- 206,209 ---- *************** *** 224,228 **** * @param object a transient instance of a persistent class * @param id an unused valid identifier - * @throws SQLException * @throws HibernateException */ --- 215,218 ---- *************** *** 238,242 **** * @see Session#update(Object object, Serializable id) * @param object a transient instance containing new or updated state - * @throws SQLException * @throws HibernateException */ --- 228,231 ---- *************** *** 255,259 **** * * @param object a transient instance containing updated state - * @throws SQLException * @throws HibernateException */ --- 244,247 ---- *************** *** 270,274 **** * @param object a transient instance containing updated state * @param id identifier of persistent instance - * @throws SQLException * @throws HibernateException */ --- 258,261 ---- *************** *** 281,285 **** * * @param object the instance to be removed - * @throws SQLException * @throws HibernateException */ --- 268,271 ---- *************** *** 291,295 **** * @param query a query expressed in Hibernate's query language * @return a distinct list of instances (or arrays of instances) - * @throws SQLException * @throws HibernateException */ --- 277,280 ---- *************** *** 304,308 **** * @see Hibernate for access to <tt>Type</tt> instances * @return a distinct list of instances (or arrays of instances) - * @throws SQLException * @throws HibernateException */ --- 289,292 ---- *************** *** 317,321 **** * @see Hibernate for access to <tt>Type</tt> instances * @return a distinct list of instances - * @throws SQLException * @throws HibernateException */ --- 301,304 ---- *************** *** 332,336 **** * @param query the query string * @return an iterator - * @throws SQLException * @throws HibernateException */ --- 315,318 ---- *************** *** 350,354 **** * @param type the hibernate type of value * @return an iterator - * @throws SQLException * @throws HibernateException */ --- 332,335 ---- *************** *** 368,372 **** * @param types a list of Hibernate types of the values * @return an iterator - * @throws SQLException * @throws HibernateException */ --- 349,352 ---- *************** *** 381,385 **** * @param filter a filter query string * @return Collection the resulting collection - * @throws SQLException * @throws HibernateException */ --- 361,364 ---- *************** *** 395,399 **** * @param type the hibernate type of value * @return Collection - * @throws SQLException * @throws HibernateException */ --- 374,377 ---- *************** *** 409,413 **** * @param types a list of Hibernate types of the values * @return Collection - * @throws SQLException * @throws HibernateException */ --- 387,390 ---- *************** *** 419,423 **** * @param query the query string * @return the number of instances deleted - * @throws SQLException * @throws HibernateException */ --- 396,399 ---- *************** *** 431,435 **** * @param type the hibernate type of value. * @return the number of instances deleted - * @throws SQLException * @throws HibernateException */ --- 407,410 ---- *************** *** 443,447 **** * @param types a list of Hibernate types of the values * @return the number of instances deleted - * @throws SQLException * @throws HibernateException */ --- 418,421 ---- *************** *** 453,457 **** * @param object a persistent instance * @param lockMode the lock level - * @throws SQLException * @throws HibernateException */ --- 427,430 ---- *************** *** 471,475 **** * @param object a persistent instance * @throws HibernateException - * @throws SQLException */ public void refresh(Object object) throws HibernateException; --- 444,447 ---- Index: SessionFactory.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/SessionFactory.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SessionFactory.java 14 Jan 2003 13:42:07 -0000 1.4 --- SessionFactory.java 14 Jan 2003 14:07:11 -0000 1.5 *************** *** 133,137 **** * @param interceptor a session-scoped interceptor * @return Session ! * @throws SQLException */ public Session openSession(Interceptor interceptor) throws HibernateException; --- 133,137 ---- * @param interceptor a session-scoped interceptor * @return Session ! * @throws HibernateException */ public Session openSession(Interceptor interceptor) throws HibernateException; *************** *** 150,154 **** * * @return Session ! * @throws SQLException */ public Session openSession() throws HibernateException; --- 150,154 ---- * * @return Session ! * @throws HibernateException */ public Session openSession() throws HibernateException; |
From: <one...@us...> - 2003-01-14 13:44:05
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv20953/net/sf/hibernate Added Files: JDBCException.java Log Message: wrap all SQLExceptions --- NEW FILE: JDBCException.java --- //$Id: JDBCException.java,v 1.1 2003/01/14 13:43:59 oneovthafew Exp $ package net.sf.hibernate; import java.sql.SQLException; import net.sf.hibernate.util.JDBCExceptionReporter; import org.apache.commons.logging.LogFactory; /** * Wraps an <tt>SQLException</tt>. Indicates that an exception * occurred during a JDBC call. * * @see java.sql.SQLException */ public class JDBCException extends HibernateException { private SQLException sqle; /** * Constructor for JDBCException. * @param root */ public JDBCException(SQLException root) { this("SQLException occurred", root); } /** * Constructor for JDBCException. * @param string * @param root */ public JDBCException(String string, SQLException root) { super(string, root); LogFactory.getLog(JDBCExceptionReporter.class).error(string, root); } /** * Get the SQLState of the underlying <tt>SQLException</tt> * @see java.sql.SQLException * @return String */ public String getSQLState() { return sqle.getSQLState(); } /** * Get the <tt>errorCode</tt> of the underlying <tt>SQLException</tt> * @see java.sql.SQLException * @return int the error code */ public int getErrorCode() { return sqle.getErrorCode(); } /** * Get the underlying <tt>SQLException</tt> * @return SQLException */ public SQLException getSQLException() { return sqle; } } |
From: <one...@us...> - 2003-01-14 13:42:53
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/xml In directory sc8-pr-cvs1:/tmp/cvs-serv19888/net/sf/hibernate/xml Modified Files: XMLDatabinder.java Log Message: wrap all SQLExceptions fixed a bug in SchemaExport where generated foreign key constraints did not used qualified tablename for referenced table Index: XMLDatabinder.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/xml/XMLDatabinder.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** XMLDatabinder.java 5 Jan 2003 02:11:25 -0000 1.4 --- XMLDatabinder.java 14 Jan 2003 13:42:19 -0000 1.5 *************** *** 5,9 **** import java.io.StringWriter; import java.lang.reflect.Array; - import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; --- 5,8 ---- *************** *** 153,162 **** } ! try { ! return li.getImplementation(); ! } ! catch (SQLException sqle) { ! throw new HibernateException( "SQL Exception initializing proxy", sqle ); ! } } --- 152,156 ---- } ! return li.getImplementation(); } |
From: <one...@us...> - 2003-01-14 13:42:52
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/transaction In directory sc8-pr-cvs1:/tmp/cvs-serv19888/net/sf/hibernate/transaction Modified Files: JDBCTransaction.java JTATransaction.java Log Message: wrap all SQLExceptions fixed a bug in SchemaExport where generated foreign key constraints did not used qualified tablename for referenced table Index: JDBCTransaction.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/transaction/JDBCTransaction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** JDBCTransaction.java 9 Jan 2003 12:24:52 -0000 1.4 --- JDBCTransaction.java 14 Jan 2003 13:42:18 -0000 1.5 *************** *** 47,51 **** } ! public void commit() throws HibernateException, SQLException { if (!begun) throw new TransactionException("Transaction not successfully started"); --- 47,51 ---- } ! public void commit() throws HibernateException { if (!begun) throw new TransactionException("Transaction not successfully started"); Index: JTATransaction.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/transaction/JTATransaction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** JTATransaction.java 9 Jan 2003 12:24:52 -0000 1.4 --- JTATransaction.java 14 Jan 2003 13:42:18 -0000 1.5 *************** *** 13,18 **** import org.apache.commons.logging.LogFactory; - import java.sql.SQLException; - import net.sf.hibernate.AssertionFailure; import net.sf.hibernate.FlushMode; --- 13,16 ---- *************** *** 44,48 **** static final Log log = LogFactory.getLog(JTATransaction.class); ! public void commit() throws HibernateException, SQLException { if (!begun) throw new TransactionException("Transaction not successfully started"); --- 42,46 ---- static final Log log = LogFactory.getLog(JTATransaction.class); ! public void commit() throws HibernateException { if (!begun) throw new TransactionException("Transaction not successfully started"); |