From: <one...@us...> - 2003-03-29 04:09:19
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg In directory sc8-pr-cvs1:/tmp/cvs-serv947/hibernate/cfg Modified Files: Binder.java Configuration.java Environment.java Mappings.java Log Message: * fixed a bug in SQLExpression * fixed a bug in Expression.ge() * improved proxy handling * fixed problems with select new * reworked import mechanism * added <any> mappings Index: Binder.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Binder.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Binder.java 16 Mar 2003 01:45:52 -0000 1.9 --- Binder.java 29 Mar 2003 04:08:46 -0000 1.10 *************** *** 11,14 **** --- 11,15 ---- import net.sf.hibernate.engine.Cascades; import net.sf.hibernate.loader.OuterJoinLoader; + import net.sf.hibernate.mapping.Any; import net.sf.hibernate.mapping.Array; import net.sf.hibernate.mapping.Association; *************** *** 58,62 **** private static final Log log = LogFactory.getLog(Collection.class); ! public static void bindClass(Element node, PersistentClass model) throws MappingException { String className = node.attributeValue("name"); --- 59,63 ---- private static final Log log = LogFactory.getLog(Collection.class); ! public static void bindClass(Element node, PersistentClass model, Mappings mapping) throws MappingException { String className = node.attributeValue("name"); *************** *** 89,98 **** false : "true".equals( dynamicNode.getValue() ) ! ); } public static void bindSubclass(Element node, Subclass model, Mappings mappings) throws MappingException { ! bindClass(node, model); if ( model.getPersister()==null ) { --- 90,104 ---- false : "true".equals( dynamicNode.getValue() ) ! ); ! //IMPORT ! Attribute importNode = node.attribute("import"); ! if (importNode!=null) { ! mapping.addImport( className, importNode.getValue() ); ! } } public static void bindSubclass(Element node, Subclass model, Mappings mappings) throws MappingException { ! bindClass(node, model, mappings); if ( model.getPersister()==null ) { *************** *** 110,114 **** public static void bindJoinedSubclass(Element node, Subclass model, Mappings mappings) throws MappingException { ! bindClass(node, model); // joined subclasses --- 116,120 ---- public static void bindJoinedSubclass(Element node, Subclass model, Mappings mappings) throws MappingException { ! bindClass(node, model, mappings); // joined subclasses *************** *** 145,149 **** public static void bindRootClass(Element node, RootClass model, Mappings mappings) throws MappingException { ! bindClass(node, model); //TABLENAME --- 151,155 ---- public static void bindRootClass(Element node, RootClass model, Mappings mappings) throws MappingException { ! bindClass(node, model, mappings); //TABLENAME *************** *** 458,461 **** --- 464,472 ---- } } + + public static void bindAny(Element node, Any model, boolean isNullable) throws MappingException { + model.setIdentifierType( getTypeFromXML(node) ); + bindColumns(node, model, isNullable, false, null); + } public static void bindOneToOne(Element node, OneToOne model, boolean isNullable) throws MappingException { *************** *** 612,615 **** --- 623,630 ---- bindOneToOne(subnode, (OneToOne) value, isNullable); } + else if ( "any".equals(name) ) { + value = new Any( model.getTable() ); + bindAny(subnode, (Any) value, isNullable); + } else if ( "property".equals(name) || "key-property".equals(name) ) { value = new Value( model.getTable() ); *************** *** 668,672 **** private static Type getTypeFromXML(Element node) throws MappingException { Type type; ! Attribute typeNode = node.attribute("type"); if (typeNode==null) { return null; //we will have to use reflection --- 683,688 ---- private static Type getTypeFromXML(Element node) throws MappingException { Type type; ! Attribute typeNode = node.attribute("type"); ! if (typeNode==null) typeNode = node.attribute("id-type"); //for an any if (typeNode==null) { return null; //we will have to use reflection *************** *** 748,751 **** --- 764,771 ---- value = new ManyToOne(table); bindManyToOne(subnode, (ManyToOne) value, propertyName, true); + } + else if ( "any".equals(name) ) { + value = new Any(table); + bindAny(subnode, (Any) value, true); } else if ( "one-to-one".equals(name) ) { *************** *** 929,937 **** while ( nodes.hasNext() ) { Element n = (Element) nodes.next(); ! String qname = n.attribute("name").getValue(); String query = n.getText(); log.debug("Named query: " + qname + " -> " + query); model.addQuery(qname, query); } } --- 949,967 ---- while ( nodes.hasNext() ) { Element n = (Element) nodes.next(); ! String qname = n.attributeValue("name"); String query = n.getText(); log.debug("Named query: " + qname + " -> " + query); model.addQuery(qname, query); } + + nodes = hmNode.elementIterator("import"); + while ( nodes.hasNext() ) { + Element n = (Element) nodes.next(); + String className = n.attributeValue("class"); + Attribute renameNode = n.attribute("rename"); + String rename = (renameNode==null) ? StringHelper.unqualify(className) : renameNode.getValue(); + log.debug("Import: " + rename + " -> " + className); + model.addImport(className, rename); + } } Index: Configuration.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Configuration.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Configuration.java 17 Mar 2003 07:24:20 -0000 1.17 --- Configuration.java 29 Mar 2003 04:08:46 -0000 1.18 *************** *** 6,9 **** --- 6,10 ---- import java.util.ArrayList; import java.util.HashMap; + import java.util.Map; import java.util.Properties; import java.util.jar.JarFile; *************** *** 69,72 **** --- 70,74 ---- private HashMap classes = new HashMap(); + private HashMap imports = new HashMap(); private HashMap collections = new HashMap(); private HashMap tables = new HashMap(); *************** *** 199,203 **** */ public Mappings createMappings() { ! return new Mappings(classes, collections, tables, namedQueries, secondPasses); } --- 201,205 ---- */ public Mappings createMappings() { ! return new Mappings(classes, collections, tables, namedQueries, imports, secondPasses); } *************** *** 474,478 **** * Get the named queries */ ! public java.util.Map getNamedQueries() { return namedQueries; } --- 476,480 ---- * Get the named queries */ ! public Map getNamedQueries() { return namedQueries; } *************** *** 781,784 **** --- 783,795 ---- throw new MappingException("jcs-cache usage attribute should be read-write or read-only"); } + } + + /** + * Get the query language imports + * + * @return Map + */ + public Map getImports() { + return imports; } Index: Environment.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Environment.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Environment.java 26 Mar 2003 10:47:55 -0000 1.6 --- Environment.java 29 Mar 2003 04:08:46 -0000 1.7 *************** *** 38,42 **** public final class Environment { ! private static final String VERSION = "2.0 beta 4"; /** --- 38,42 ---- public final class Environment { ! private static final String VERSION = "2.0 beta 5"; /** *************** *** 227,230 **** --- 227,231 ---- /** * A comma-seperated list of packages that need not be specified in a query + * @deprecated */ public static final String QUERY_IMPORTS = "hibernate.query.imports"; Index: Mappings.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Mappings.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Mappings.java 3 Feb 2003 12:11:36 -0000 1.4 --- Mappings.java 29 Mar 2003 04:08:46 -0000 1.5 *************** *** 27,38 **** private final Map queries; private final List secondPasses; private String schemaName; private String defaultCascade; ! Mappings(Map classes, Map collections, Map tables, Map queries, List secondPasses) { this.classes = classes; this.collections = collections; this.queries = queries; this.tables = tables; this.secondPasses = secondPasses; } --- 27,40 ---- private final Map queries; private final List secondPasses; + private final Map imports; private String schemaName; private String defaultCascade; ! Mappings(Map classes, Map collections, Map tables, Map queries, Map imports, List secondPasses) { this.classes = classes; this.collections = collections; this.queries = queries; this.tables = tables; + this.imports = imports; this.secondPasses = secondPasses; } *************** *** 51,54 **** --- 53,60 ---- public Collection getCollection(String role) { return (Collection) collections.get(role); + } + + public void addImport(String className, String rename) throws MappingException { + if ( imports.put(rename, className)!=null ) throw new MappingException("duplicate import: " + rename); } |