|
From: <one...@us...> - 2003-01-27 07:12:06
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg
In directory sc8-pr-cvs1:/tmp/cvs-serv24927/hibernate/cfg
Modified Files:
Configuration.java
Added Files:
Binder.java
Log Message:
massive refactoring of XML mapping parsing code
--- NEW FILE: Binder.java ---
//$Id: Binder.java,v 1.1 2003/01/27 07:12:03 oneovthafew Exp $
package net.sf.hibernate.cfg;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Properties;
import net.sf.hibernate.Hibernate;
import net.sf.hibernate.MappingException;
import net.sf.hibernate.engine.Cascades;
import net.sf.hibernate.loader.OuterJoinLoader;
import net.sf.hibernate.mapping.Array;
import net.sf.hibernate.mapping.Association;
import net.sf.hibernate.mapping.Bag;
import net.sf.hibernate.mapping.Collection;
import net.sf.hibernate.mapping.Column;
import net.sf.hibernate.mapping.Component;
import net.sf.hibernate.mapping.ForeignKey;
[...988 lines suppressed...]
public Collection create(Node node, String prefix, PersistentClass owner, Root root) throws MappingException {
PrimitiveArray array = new PrimitiveArray(owner);
Binder.bindArray(node, array, prefix, root);
return array;
}
};
private static final HashMap INSTANCES = new HashMap();
static {
INSTANCES.put(MAP.toString(), MAP);
INSTANCES.put(BAG.toString(), BAG);
INSTANCES.put(SET.toString(), SET);
INSTANCES.put(LIST.toString(), LIST);
INSTANCES.put(ARRAY.toString(), ARRAY);
INSTANCES.put(PRIMITIVE_ARRAY.toString(), PRIMITIVE_ARRAY);
}
public static CollectionType collectionTypeFromString(String xmlTagName) {
return (CollectionType) INSTANCES.get(xmlTagName);
}
}
}
Index: Configuration.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Configuration.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Configuration.java 26 Jan 2003 03:16:32 -0000 1.6
--- Configuration.java 27 Jan 2003 07:12:03 -0000 1.7
***************
*** 6,10 ****
import java.util.ArrayList;
import java.util.HashMap;
- import java.util.Map;
import java.util.Properties;
import java.util.jar.JarFile;
--- 6,9 ----
***************
*** 35,43 ****
import net.sf.hibernate.id.PersistentIdentifierGenerator;
import net.sf.hibernate.impl.SessionFactoryImpl;
! import net.sf.hibernate.mapping.Collection;
import net.sf.hibernate.mapping.ForeignKey;
import net.sf.hibernate.mapping.Index;
import net.sf.hibernate.mapping.PersistentClass;
import net.sf.hibernate.mapping.Root;
import net.sf.hibernate.mapping.Table;
import net.sf.hibernate.dialect.Dialect;
--- 34,47 ----
import net.sf.hibernate.id.PersistentIdentifierGenerator;
import net.sf.hibernate.impl.SessionFactoryImpl;
! import net.sf.hibernate.mapping.Array;
! import net.sf.hibernate.mapping.Bag;
import net.sf.hibernate.mapping.ForeignKey;
import net.sf.hibernate.mapping.Index;
+ import net.sf.hibernate.mapping.List;
+ import net.sf.hibernate.mapping.Map;
import net.sf.hibernate.mapping.PersistentClass;
+ import net.sf.hibernate.mapping.PrimitiveArray;
import net.sf.hibernate.mapping.Root;
+ import net.sf.hibernate.mapping.Set;
import net.sf.hibernate.mapping.Table;
import net.sf.hibernate.dialect.Dialect;
***************
*** 156,160 ****
private void add(Document doc) throws Exception {
try {
! new Root(doc, classes, collections, tables, namedQueries);
}
catch (MappingException me) {
--- 160,164 ----
private void add(Document doc) throws Exception {
try {
! Binder.bindRoot( doc, createRoot() );
}
catch (MappingException me) {
***************
*** 164,167 ****
--- 168,175 ----
}
+ public Root createRoot() {
+ return new Root(classes, collections, tables, namedQueries);
+ }
+
/**
* Read mappings from an <tt>InputStream</tt>
***************
*** 407,411 ****
Iterator iter = collections.values().iterator();
while ( iter.hasNext() ) {
! ( (Collection) iter.next() ).secondPassCompile(classes);
}
--- 415,425 ----
Iterator iter = collections.values().iterator();
while ( iter.hasNext() ) {
! Object coll = iter.next();
! if (coll instanceof Set) Binder.bindSetSecondPass( (Set) coll, classes );
! if (coll instanceof Map) Binder.bindMapSecondPass( (Map) coll, classes );
! if (coll instanceof List) Binder.bindListSecondPass( (List) coll, classes );
! if (coll instanceof Bag) Binder.bindCollectionSecondPass( (Bag) coll, classes );
! if (coll instanceof Array) Binder.bindListSecondPass( (Array) coll, classes );
! if (coll instanceof PrimitiveArray) Binder.bindListSecondPass( (PrimitiveArray) coll, classes );
}
***************
*** 434,438 ****
* Get the named queries
*/
! public Map getNamedQueries() {
return namedQueries;
}
--- 448,452 ----
* Get the named queries
*/
! public java.util.Map getNamedQueries() {
return namedQueries;
}
|