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-02-16 01:55:10
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util In directory sc8-pr-cvs1:/tmp/cvs-serv7760/hibernate/util Modified Files: IdentityMap.java Log Message: enable use of JDK IdentityHashMap in 1.4+ Index: IdentityMap.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/IdentityMap.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IdentityMap.java 5 Jan 2003 02:11:25 -0000 1.3 --- IdentityMap.java 16 Feb 2003 01:55:07 -0000 1.4 *************** *** 2,16 **** package net.sf.hibernate.util; - import java.util.HashMap; import java.io.Serializable; ! import java.util.*; /** ! * A hashtable where keys are compared by object identity, ! * rather than equals(). */ public final class IdentityMap implements Map, Serializable { private final Map map = new HashMap(); --- 2,69 ---- package net.sf.hibernate.util; import java.io.Serializable; ! 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; ! ! import net.sf.hibernate.AssertionFailure; /** ! * A <tt>Map</tt> where keys are compared by object identity, ! * rather than <tt>equals()</tt>. */ public final class IdentityMap implements Map, Serializable { + private static final Class identityMapClass; + static { + Class imc; + try { + imc = Class.forName("java.util.IdentityHashMap"); + //throw new ClassNotFoundException(); + } + catch (ClassNotFoundException cnfe) { + imc = IdentityMap.class; + } + identityMapClass=imc; + } + + /** + * Return a new instance of this class, or an instance of JDK <tt>IdentityHashMap</tt>, + * if available. (The JDK implementation is significantly faster.) + * + * @return Map + */ + public static Map instantiate() { + try { + return (Map) identityMapClass.newInstance(); + } + catch (Exception ie) { + throw new AssertionFailure("could not instantiate identity map", ie); + } + } + + /** + * Return the map entries (as instances of <tt>Map.Entry</tt> in a collection that + * is safe from concurrent modification). ie. we may safely add new instances to + * the underlying <tt>Map</tt> during iteration of the <tt>entries()</tt>. + * + * @param map + * @return Collection + */ + public static Collection entries(Map map) { + if (identityMapClass==IdentityMap.class) { + return ( (IdentityMap) map ).entryList(); + } + else { + return new ArrayList( map.entrySet() ); + } + } + private final Map map = new HashMap(); *************** *** 50,73 **** } } ! ! private static IdentityKey popKey(Object key) { ! ! /*synchronized(keyCache) { ! if ( keyCache.isEmpty() ) { ! return new Key(key); ! } ! else { ! Key k = (Key) keyCache.pop(); ! k.key = key; ! return k; ! } ! }*/ ! return new IdentityKey(key); ! } ! ! private static void pushKey(IdentityKey k) { ! //keyCache.push(k); ! } ! public int size() { return map.size(); --- 103,107 ---- } } ! public int size() { return map.size(); *************** *** 79,86 **** public boolean containsKey(Object key) { ! IdentityKey k = popKey(key); ! boolean result = map.containsKey(k); ! pushKey(k); ! return result; } --- 113,118 ---- public boolean containsKey(Object key) { ! IdentityKey k = new IdentityKey(key); ! return map.containsKey(k); } *************** *** 90,108 **** public Object get(Object key) { ! IdentityKey k = popKey(key); ! Object result = map.get(k); ! pushKey(k); ! return result; } public Object put(Object key, Object value) { ! return map.put( popKey(key), value ); } public Object remove(Object key) { ! IdentityKey k = popKey(key); ! Object result = map.remove(k); ! pushKey(k); ! return result; } --- 122,136 ---- public Object get(Object key) { ! IdentityKey k = new IdentityKey(key); ! return map.get(k); } public Object put(Object key, Object value) { ! return map.put( new IdentityKey(key), value ); } public Object remove(Object key) { ! IdentityKey k = new IdentityKey(key); ! return map.remove(k); } *************** *** 116,123 **** public void clear() { - Iterator iter = map.keySet().iterator(); - while ( iter.hasNext() ) { - pushKey ( (IdentityKey) iter.next() ); - } map.clear(); } --- 144,147 ---- *************** *** 133,137 **** public Set entrySet() { ! Set set = new HashSet(); Iterator iter = map.entrySet().iterator(); while ( iter.hasNext() ) { --- 157,161 ---- public Set entrySet() { ! Set set = new HashSet( map.size() ); Iterator iter = map.entrySet().iterator(); while ( iter.hasNext() ) { *************** *** 140,143 **** --- 164,222 ---- } return set; + } + + private List entryList() { + ArrayList list = new ArrayList( map.size() ); + Iterator iter = map.entrySet().iterator(); + while ( iter.hasNext() ) { + Map.Entry me = (Map.Entry) iter.next(); + list.add( new IdentityMapEntry( ( (IdentityKey) me.getKey() ).key, me.getValue() ) ); + } + return list; + } + + /** + * Workaround for a JDK 1.4.1 bug where <tt>IdentityHashMap</tt>s are not + * correctly deserialized. + * + * @param map + * @return Object + */ + public static Object serialize(Map map) { + if (identityMapClass==IdentityMap.class) { + return map; + } + else { + Object[] array = new Object[ map.size() * 2 ]; + Iterator iter = map.entrySet().iterator(); + int i=0; + while ( iter.hasNext() ) { + Map.Entry e = (Map.Entry) iter.next(); + array[i++] = e.getKey(); + array[i++] = e.getValue(); + } + return array; + } + } + + /** + * Workaround for a JDK 1.4.1 bug where <tt>IdentityHashMap</tt>s are not + * correctly deserialized. + * + * @param map + * @return Object + */ + public static Map deserialize(Object o) { + if (identityMapClass==IdentityMap.class) { + return (Map) o; + } + else { + Map map = instantiate(); + Object[] array = (Object[]) o; + for ( int i=0; i<array.length; i+=2 ) { + map.put( array[i], array[i+1] ); + } + return map; + } } } |
From: <one...@us...> - 2003-02-16 01:55:10
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/ps In directory sc8-pr-cvs1:/tmp/cvs-serv7760/hibernate/ps Modified Files: PreparedStatementCache.java Log Message: enable use of JDK IdentityHashMap in 1.4+ Index: PreparedStatementCache.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/ps/PreparedStatementCache.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PreparedStatementCache.java 15 Jan 2003 12:49:01 -0000 1.5 --- PreparedStatementCache.java 16 Feb 2003 01:55:07 -0000 1.6 *************** *** 51,55 **** } private final Map cache = new HashMap(); ! private final IdentityMap entryMap = new IdentityMap(); private final LinkedList entries = new LinkedList(); private short reapCounter = 0; --- 51,55 ---- } private final Map cache = new HashMap(); ! private final Map entryMap = IdentityMap.instantiate(); private final LinkedList entries = new LinkedList(); private short reapCounter = 0; |
From: <one...@us...> - 2003-02-16 01:55:09
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv7760/hibernate/impl Modified Files: SessionFactoryImpl.java SessionImpl.java Log Message: enable use of JDK IdentityHashMap in 1.4+ Index: SessionFactoryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionFactoryImpl.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SessionFactoryImpl.java 15 Feb 2003 08:57:57 -0000 1.10 --- SessionFactoryImpl.java 16 Feb 2003 01:55:05 -0000 1.11 *************** *** 287,296 **** } ! // Emulates constant time LRU/MRU algorythms for cache // It is better to hold strong refernces on some (LRU/MRU) queries private transient final int MAX_STRONG_REF_COUNT = 128; //TODO: configurable? private transient final Object strongRefs[] = new Object[MAX_STRONG_REF_COUNT]; //strong reference to MRU queries private transient int strongRefIndex = 0; ! private transient final Map softQueryCache = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.SOFT) ; private static QueryCacheKeyFactory keyFactory = (QueryCacheKeyFactory) KeyFactory.create( --- 287,297 ---- } ! // Emulates constant time LRU/MRU algorithms for cache // It is better to hold strong refernces on some (LRU/MRU) queries private transient final int MAX_STRONG_REF_COUNT = 128; //TODO: configurable? private transient final Object strongRefs[] = new Object[MAX_STRONG_REF_COUNT]; //strong reference to MRU queries private transient int strongRefIndex = 0; ! private transient final Map softQueryCache = new ReferenceMap(ReferenceMap.SOFT, ReferenceMap.SOFT) ; ! // both keys and values may be soft since value keeps a hard ref to the key (and there is a hard ref to MRU values) private static QueryCacheKeyFactory keyFactory = (QueryCacheKeyFactory) KeyFactory.create( *************** *** 298,302 **** ); ! //retuns generated class instance interface QueryCacheKeyFactory { //Will not recalculate hashKey for constant queries --- 299,303 ---- ); ! //returns generated class instance interface QueryCacheKeyFactory { //Will not recalculate hashKey for constant queries *************** *** 333,338 **** // have to be careful to ensure that if the JVM does out-of-order execution // then another thread can't get an uncompiled QueryTranslator from the cache ! // its a bit of a performance killer since it means no other thread can perform ! // a query while another query is being compiled QueryTranslator q = (QueryTranslator) get(cacheKey); --- 334,339 ---- // have to be careful to ensure that if the JVM does out-of-order execution // then another thread can't get an uncompiled QueryTranslator from the cache ! // we also have to be very careful to ensure that other threads can perform ! // compiled queries while another query is being compiled QueryTranslator q = (QueryTranslator) get(cacheKey); Index: SessionImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionImpl.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** SessionImpl.java 15 Feb 2003 01:00:52 -0000 1.20 --- SessionImpl.java 16 Feb 2003 01:55:05 -0000 1.21 *************** *** 83,89 **** private final Map entitiesByKey; //key=Key, value=Object private final Map proxiesByKey; //key=Key, value=HibernateProxy ! private final IdentityMap entries; //key=Object, value=Entry ! private final IdentityMap arrayHolders; //key=array, value=ArrayHolder ! private final IdentityMap collections; //key=PersistentCollection, value=CollectionEntry private Set nullifiables = new HashSet(); //set of Keys of deleted objects --- 83,89 ---- private final Map entitiesByKey; //key=Key, value=Object private final Map proxiesByKey; //key=Key, value=HibernateProxy ! private transient Map entries; //key=Object, value=Entry ! private transient Map arrayHolders; //key=array, value=ArrayHolder ! private transient Map collections; //key=PersistentCollection, value=CollectionEntry private Set nullifiables = new HashSet(); //set of Keys of deleted objects *************** *** 308,311 **** --- 308,314 ---- ois.defaultReadObject(); + entries = IdentityMap.deserialize( ois.readObject() ); + collections = IdentityMap.deserialize( ois.readObject() ); + arrayHolders = IdentityMap.deserialize( ois.readObject() ); initTransientCollections(); *************** *** 359,362 **** --- 362,368 ---- oos.defaultWriteObject(); + oos.writeObject( IdentityMap.serialize(entries) ); + oos.writeObject( IdentityMap.serialize(collections) ); + oos.writeObject( IdentityMap.serialize(arrayHolders) ); } *************** *** 375,382 **** entitiesByKey = new HashMap(50); proxiesByKey = new HashMap(10); ! entries = new IdentityMap(); ! //tableAccesses = new THashSet(10); ! collections = new IdentityMap(); ! arrayHolders = new IdentityMap(); initTransientCollections(); --- 381,387 ---- entitiesByKey = new HashMap(50); proxiesByKey = new HashMap(10); ! entries = IdentityMap.instantiate(); ! collections = IdentityMap.instantiate(); ! arrayHolders = IdentityMap.instantiate(); initTransientCollections(); *************** *** 1918,1922 **** // It is safe because of how IdentityMap implements entrySet() ! Iterator iter = entries.entrySet().iterator(); while ( iter.hasNext() ) { --- 1923,1927 ---- // It is safe because of how IdentityMap implements entrySet() ! Iterator iter = IdentityMap.entries(entries).iterator(); while ( iter.hasNext() ) { *************** *** 2048,2052 **** private void preFlushEntities() throws HibernateException { ! Iterator iter = entries.entrySet().iterator(); //safe from concurrent modification because of how entrySet() is implemented on IdentityMap while ( iter.hasNext() ) { --- 2053,2057 ---- private void preFlushEntities() throws HibernateException { ! Iterator iter = IdentityMap.entries(entries).iterator(); //safe from concurrent modification because of how entrySet() is implemented on IdentityMap while ( iter.hasNext() ) { *************** *** 2121,2125 **** Map.Entry e = (Map.Entry) iter.next(); if ( ! ( (CollectionEntry) e.getValue() ).reached ) ! updateUnreachableCollection( (PersistentCollection) e.getKey() ); } --- 2126,2130 ---- Map.Entry e = (Map.Entry) iter.next(); if ( ! ( (CollectionEntry) e.getValue() ).reached ) ! updateUnreachableCollection( (PersistentCollection) e.getKey() ); } |
From: <one...@us...> - 2003-02-15 08:58:00
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv10780/hibernate/impl Modified Files: SessionFactoryImpl.java Log Message: query cache now keeps strong references to MRU queries Index: SessionFactoryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionFactoryImpl.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SessionFactoryImpl.java 9 Feb 2003 06:28:15 -0000 1.9 --- SessionFactoryImpl.java 15 Feb 2003 08:57:57 -0000 1.10 *************** *** 22,25 **** --- 22,26 ---- import java.util.Map; import java.util.Properties; + import java.util.Collections; import javax.naming.NamingException; *************** *** 31,34 **** --- 32,37 ---- import javax.xml.transform.stream.StreamSource; + import net.sf.cglib.KeyFactory; + import net.sf.hibernate.AssertionFailure; import net.sf.hibernate.Databinder; *************** *** 283,288 **** } ! private transient final ReferenceMap queryCache = new ReferenceMap(ReferenceMap.SOFT, ReferenceMap.SOFT); public QueryTranslator getQuery(String query) throws QueryException, MappingException { --- 286,320 ---- } + + // Emulates constant time LRU/MRU algorythms for cache + // It is better to hold strong refernces on some (LRU/MRU) queries + private transient final int MAX_STRONG_REF_COUNT = 128; //TODO: configurable? + private transient final Object strongRefs[] = new Object[MAX_STRONG_REF_COUNT]; //strong reference to MRU queries + private transient int strongRefIndex = 0; + private transient final Map softQueryCache = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.SOFT) ; ! private static QueryCacheKeyFactory keyFactory = (QueryCacheKeyFactory) KeyFactory.create( ! QueryCacheKeyFactory.class, QueryCacheKeyFactory.class.getClassLoader() ! ); ! ! //retuns generated class instance ! interface QueryCacheKeyFactory { ! //Will not recalculate hashKey for constant queries ! Object newInstance(String query, boolean scalar); ! } ! ! //TODO: this stuff can be implemented in separate class to reuse soft MRU/LRU caching ! private synchronized Object get(Object key) { ! Object result = softQueryCache.get(key); ! if( result != null ) { ! strongRefs[ ++strongRefIndex % MAX_STRONG_REF_COUNT ] = result; ! } ! return result; ! } ! ! private synchronized void put(Object key, Object value) { ! softQueryCache.put(key, value); ! strongRefs[ ++strongRefIndex % MAX_STRONG_REF_COUNT ] = value; ! } public QueryTranslator getQuery(String query) throws QueryException, MappingException { *************** *** 297,301 **** private QueryTranslator getQuery(String query, boolean shallow) throws QueryException, MappingException { ! String cacheKey = (shallow?'$':'%') + query; //a but expedient, i know.... // have to be careful to ensure that if the JVM does out-of-order execution --- 329,333 ---- private QueryTranslator getQuery(String query, boolean shallow) throws QueryException, MappingException { ! Object cacheKey = keyFactory.newInstance(query, shallow); // have to be careful to ensure that if the JVM does out-of-order execution *************** *** 304,311 **** // a query while another query is being compiled ! QueryTranslator q = (QueryTranslator) queryCache.get(cacheKey); if ( q==null ) { q = new QueryTranslator(); ! queryCache.put(cacheKey, q); } q.compile(this, query, querySubstitutions, shallow); --- 336,343 ---- // a query while another query is being compiled ! QueryTranslator q = (QueryTranslator) get(cacheKey); if ( q==null ) { q = new QueryTranslator(); ! put(cacheKey, q); } q.compile(this, query, querySubstitutions, shallow); *************** *** 316,326 **** public FilterTranslator getFilter(String query, String collectionRole, boolean scalar) throws QueryException, MappingException { ! String cacheKey = (scalar?'#':'*') + query; //a but expedient, i know.... ! ! FilterTranslator q = (FilterTranslator) queryCache.get(cacheKey); if ( q==null ) { q = new FilterTranslator(); ! queryCache.put(cacheKey, q); } q.compile(collectionRole, this, query, querySubstitutions, scalar); --- 348,358 ---- public FilterTranslator getFilter(String query, String collectionRole, boolean scalar) throws QueryException, MappingException { + + Object cacheKey = keyFactory.newInstance(query, scalar); ! FilterTranslator q = (FilterTranslator) get(cacheKey); if ( q==null ) { q = new FilterTranslator(); ! put(cacheKey, q); } q.compile(collectionRole, this, query, querySubstitutions, scalar); |
From: <one...@us...> - 2003-02-15 08:16:48
|
Update of /cvsroot/hibernate/Hibernate2/lib In directory sc8-pr-cvs1:/tmp/cvs-serv29723 Modified Files: cglib.jar Added Files: ant.jar optional.jar Log Message: added ant jars and upgraded to latest cglib --- NEW FILE: ant.jar --- (This appears to be a binary file; contents omitted.) --- NEW FILE: optional.jar --- (This appears to be a binary file; contents omitted.) Index: cglib.jar =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/lib/cglib.jar,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 Binary files /tmp/cvsKsiCKR and /tmp/cvsg7iUAD differ |
From: <one...@us...> - 2003-02-15 08:03:42
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2ddl In directory sc8-pr-cvs1:/tmp/cvs-serv29419/sf/hibernate/tool/hbm2ddl Added Files: SchemaExportTask.java Log Message: ant task by Rong C Ou --- NEW FILE: SchemaExportTask.java --- package net.sf.hibernate.tool.hbm2ddl; import net.sf.hibernate.HibernateException; import net.sf.hibernate.cfg.Configuration; import net.sf.hibernate.tool.hbm2ddl.SchemaExport; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.MatchingTask; import org.apache.tools.ant.types.FileSet; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Properties; /** * An Ant task for <tt>SchemaExport</tt> * * <pre> * <taskdef name="schemaexport" * classname="blah.blah.package.SchemaExportTask" * classpathref="class.path"/> * * <schemaexport * properties="${build.classes.dir}/hibernate.properties" * quiet="no" * text="no" * drop="no" * output="${build.dir}/schema-export.sql"> * <fileset dir="${build.classes.dir}"> * <include name="*.hbm.xml"/> * </fileset> * </schemaexport> * </pre> */ public class SchemaExportTask extends MatchingTask { private List fileSets = new LinkedList(); private File propertiesFile = null; private String configurationFile = null; private String outputFile = null; private boolean quiet = false; private boolean text = false; private boolean drop = false; public void addFileset(FileSet set) { fileSets.add(set); } public void setProperties(File propertiesFile) { if (!propertiesFile.exists()) { throw new BuildException("Properties file: " + propertiesFile + " does not exist."); } log("Using properties file " + propertiesFile, Project.MSG_DEBUG); this.propertiesFile = propertiesFile; } public void setConfig(String configurationFile) { this.configurationFile = configurationFile; } public void setQuiet(boolean quiet) { this.quiet = quiet; } public void setText(boolean text) { this.text = text; } public void setDrop(boolean drop) { this.drop = drop; } public void setOutput(String outputFile) { this.outputFile = outputFile; } public void execute() throws BuildException { try { Configuration cfg = getConfiguration(); SchemaExport schemaExport = getSchemaExport(cfg); if (drop) { schemaExport.drop(!quiet, !text); } else { schemaExport.create(!quiet, !text); } } catch (HibernateException e) { throw new BuildException("Schema text failed: " + e.getMessage(), e); } catch (FileNotFoundException e) { throw new BuildException("File not found: " + e.getMessage(), e); } catch (IOException e) { throw new BuildException("IOException : " + e.getMessage(), e); } } private String[] getFiles() { List files = new LinkedList(); for ( Iterator i = fileSets.iterator(); i.hasNext(); ) { FileSet fs = (FileSet) i.next(); DirectoryScanner ds = fs.getDirectoryScanner(project); String[] dsFiles = ds.getIncludedFiles(); for (int j = 0; j < dsFiles.length; j++) { File f = new File(dsFiles[j]); if ( !f.isFile() ) { f = new File( ds.getBasedir(), dsFiles[j] ); } files.add( f.getAbsolutePath() ); } } return (String[]) files.toArray( new String[0] ); } private Configuration getConfiguration() throws HibernateException { Configuration cfg = new Configuration(); if (configurationFile != null) { cfg.configure(configurationFile); } String[] files = getFiles(); for (int i = 0; i < files.length; i++) { String filename = files[i]; if ( filename.endsWith(".jar") ) { cfg.addJar(filename); } else { cfg.addFile(filename); } } return cfg; } private SchemaExport getSchemaExport(Configuration cfg) throws HibernateException, IOException { SchemaExport schemaExport = null; if (propertiesFile == null) { schemaExport = new SchemaExport(cfg); } else { Properties properties = new Properties(); properties.load( new FileInputStream(propertiesFile) ); schemaExport = new SchemaExport(cfg, properties); } schemaExport.setOutputFile(outputFile); return schemaExport; } } |
From: <one...@us...> - 2003-02-15 08:01:32
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv27994/sf/hibernate/test Modified Files: Fo.java FooBarTest.java FumTest.java Log Message: integrated latest cglib + reflection optimizer Index: Fo.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Fo.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Fo.java 5 Jan 2003 02:11:23 -0000 1.3 --- Fo.java 15 Feb 2003 08:00:52 -0000 1.4 *************** *** 5,8 **** --- 5,15 ---- public class Fo { + + public static Fo newFo() { + return new Fo(); + } + + private Fo() {} + private byte[] buf; private Serializable serial; Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** FooBarTest.java 15 Feb 2003 01:00:57 -0000 1.21 --- FooBarTest.java 15 Feb 2003 08:00:52 -0000 1.22 *************** *** 2035,2044 **** Foo foo = new Foo(); s.save(foo); ! List list = s.find("select foo from foo in class net.sf.hibernate.test.Foo, fee in class net.sf.hibernate.test.Fee where foo.dependent = fee order by foo.string desc, foo.component.count asc, fee.id"); assertTrue( list.size()==1, "order by" ); Foo foo2 = new Foo(); s.save(foo2); foo.setFoo(foo2); ! list = s.find("select foo.foo, foo.dependent from foo in class net.sf.hibernate.test.Foo order by foo.foo.string desc, foo.component.count asc, foo.dependent.id"); assertTrue( list.size()==1, "order by" ); list = s.find("select foo from foo in class net.sf.hibernate.test.Foo order by foo.dependent.id, foo.dependent.fi"); --- 2035,2044 ---- Foo foo = new Foo(); s.save(foo); ! List list = s.find("select foo from foo in class Foo, fee in class Fee where foo.dependent = fee order by foo.string desc, foo.component.count asc, fee.id"); assertTrue( list.size()==1, "order by" ); Foo foo2 = new Foo(); s.save(foo2); foo.setFoo(foo2); ! list = s.find("select foo.foo, foo.dependent from foo in class Foo order by foo.foo.string desc, foo.component.count asc, foo.dependent.id"); assertTrue( list.size()==1, "order by" ); list = s.find("select foo from foo in class net.sf.hibernate.test.Foo order by foo.dependent.id, foo.dependent.fi"); *************** *** 2519,2523 **** } assertTrue(err); ! Fo fo = new Fo(); id = FumTest.fumKey("abc"); //yuck!! s.save(fo, id); --- 2519,2523 ---- } assertTrue(err); ! Fo fo = Fo.newFo(); id = FumTest.fumKey("abc"); //yuck!! s.save(fo, id); Index: FumTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FumTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FumTest.java 15 Feb 2003 01:07:32 -0000 1.1 --- FumTest.java 15 Feb 2003 08:00:55 -0000 1.2 *************** *** 317,321 **** public void testCompositeIDs() throws Exception { Session s = sessions.openSession(); ! Fo fo = new Fo(); Properties props = new Properties(); props.setProperty("foo", "bar"); --- 317,321 ---- public void testCompositeIDs() throws Exception { Session s = sessions.openSession(); ! Fo fo = Fo.newFo(); Properties props = new Properties(); props.setProperty("foo", "bar"); *************** *** 350,354 **** s.flush(); try { ! s.save( new Fo() ); assertTrue(false); } --- 350,354 ---- s.flush(); try { ! s.save( Fo.newFo() ); assertTrue(false); } |
From: <one...@us...> - 2003-02-15 08:01:31
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type In directory sc8-pr-cvs1:/tmp/cvs-serv27994/sf/hibernate/type Modified Files: ComponentType.java Log Message: integrated latest cglib + reflection optimizer Index: ComponentType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/ComponentType.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ComponentType.java 3 Feb 2003 10:28:48 -0000 1.7 --- ComponentType.java 15 Feb 2003 08:00:55 -0000 1.8 *************** *** 8,14 **** --- 8,20 ---- import java.sql.SQLException; + import org.apache.commons.logging.Log; + import org.apache.commons.logging.LogFactory; + + import net.sf.cglib.MetaClass; + import net.sf.hibernate.HibernateException; import net.sf.hibernate.InstantiationException; import net.sf.hibernate.MappingException; + import net.sf.hibernate.PropertyAccessException; import net.sf.hibernate.engine.Cascades; import net.sf.hibernate.engine.Mapping; *************** *** 19,23 **** public class ComponentType extends AbstractType implements AbstractComponentType { ! private final Class componentClass; private final Constructor constructor; --- 25,31 ---- public class ComponentType extends AbstractType implements AbstractComponentType { ! ! private static final Log log = LogFactory.getLog(ComponentType.class); ! private final Class componentClass; private final Constructor constructor; *************** *** 31,34 **** --- 39,43 ---- private final String parentProperty; private final ReflectHelper.Setter parentSetter; + private MetaClass optimizer; public int[] sqlTypes(Mapping mapping) throws MappingException { *************** *** 68,74 **** --- 77,89 ---- getters = new ReflectHelper.Getter[propertySpan]; setters = new ReflectHelper.Setter[propertySpan]; + String getterNames[] = new String[propertySpan]; + String setterNames[] = new String[propertySpan]; + Class propTypes [] = new Class[propertySpan]; for ( int i=0; i<propertySpan; i++ ) { getters[i] = ReflectHelper.getGetter( componentClass, properties[i] ); setters[i] = ReflectHelper.getSetter( componentClass, properties[i] ); + getterNames[i] = getters[i].getMethod().getName(); + setterNames[i] = setters[i].getMethod().getName(); + propTypes[i] = getters[i].getMethod().getReturnType(); } this.parentSetter = (parentProperty==null) ? null : ReflectHelper.getSetter(componentClass, parentProperty); *************** *** 78,81 **** --- 93,107 ---- this.joinedFetch = joinedFetch; constructor = ReflectHelper.getDefaultConstructor(componentClass); + + MetaClass opt; + try { + opt = MetaClass.getInstance(componentClass.getClassLoader(), componentClass, getterNames, setterNames, propTypes); + opt.setPropertyValues( opt.newInstance(), opt.getPropertyValues( opt.newInstance() ) ); + } + catch (Throwable t) { + opt=null; + log.info( "reflection optimizer disabled for: " + componentClass.getName() ); + } + optimizer=opt; } *************** *** 170,193 **** public Object[] getPropertyValues(Object component) throws HibernateException { ! Object[] values = new Object[propertySpan]; ! for ( int i=0; i<propertySpan; i++ ) { ! values[i] = getPropertyValue(component, i); } - return values; } public void setPropertyValues(Object component, Object[] values) throws HibernateException { ! for ( int i=0; i<propertySpan; i++ ) { ! setters[i].set( component, values[i] ); } } public Type[] getSubtypes() { return types; } ! public String getName() { return componentClass.getName(); } public String toXML(Object value, SessionFactoryImplementor factory) { return (value==null) ? null : value.toString(); } public String[] getPropertyNames() { return propertyNames; --- 196,247 ---- public Object[] getPropertyValues(Object component) throws HibernateException { ! ! if(optimizer!=null) { ! try { ! return optimizer.getPropertyValues(component); ! } ! catch (Throwable t){ ! throw new PropertyAccessException(t, "exception getting property value with CGLIB", false, componentClass, "?"); ! } ! } ! else { ! Object[] values = new Object[propertySpan]; ! for ( int i=0; i<propertySpan; i++ ) { ! values[i] = getPropertyValue(component, i); ! } ! return values; } } public void setPropertyValues(Object component, Object[] values) throws HibernateException { ! ! if (optimizer!=null) { ! try { ! optimizer.setPropertyValues(component,values); ! return; ! } ! catch (Throwable t) { ! throw new PropertyAccessException(t, "exception setting property value with CGLIB", true, componentClass, "?"); ! } ! } ! else { ! for ( int i=0; i<propertySpan; i++ ) { ! setters[i].set( component, values[i] ); ! } } } + public Type[] getSubtypes() { return types; } ! public String getName() { ! return componentClass.getName(); ! } ! public String toXML(Object value, SessionFactoryImplementor factory) { return (value==null) ? null : value.toString(); } + public String[] getPropertyNames() { return propertyNames; *************** *** 201,204 **** --- 255,259 ---- values[i] = types[i].deepCopy( values[i] ); } + Object result = instantiate(); //TODO: note that this doesn't copy reference to parent. Is that okay?? setPropertyValues(result, values); *************** *** 207,216 **** public Object instantiate() throws HibernateException { ! try { ! return constructor.newInstance(null); ! } ! catch (Exception e) { ! throw new InstantiationException("Could not instantiate component: ", componentClass, e); } } --- 262,281 ---- public Object instantiate() throws HibernateException { ! if(optimizer!=null) { ! try { ! return optimizer.newInstance(); ! } ! catch(Throwable t) { ! throw new InstantiationException("Could not instantiate component with CGLIB: ", componentClass, t); ! } } + else { + try { + return constructor.newInstance(null); + } + catch (Exception e) { + throw new InstantiationException("Could not instantiate component: ", componentClass, e); + } + } } |
From: <one...@us...> - 2003-02-15 08:01:29
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/proxy In directory sc8-pr-cvs1:/tmp/cvs-serv27994/sf/hibernate/proxy Modified Files: CGLIBLazyInitializer.java HibernateProxyHelper.java Log Message: integrated latest cglib + reflection optimizer Index: CGLIBLazyInitializer.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/proxy/CGLIBLazyInitializer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CGLIBLazyInitializer.java 5 Jan 2003 02:11:22 -0000 1.3 --- CGLIBLazyInitializer.java 15 Feb 2003 08:00:51 -0000 1.4 *************** *** 10,19 **** import net.sf.hibernate.engine.SessionImplementor; ! import net.sf.cglib.proxy.Enhancer; ! import net.sf.cglib.proxy.MethodInterceptor; /** ! * */ public final class CGLIBLazyInitializer extends LazyInitializer implements MethodInterceptor { --- 10,20 ---- import net.sf.hibernate.engine.SessionImplementor; ! import net.sf.cglib.Enhancer; ! import net.sf.cglib.MethodInterceptor; ! import net.sf.cglib.MethodProxy; /** ! * A <tt>LazyInitializer</tt> implemented using the CGLIB bytecode generation library */ public final class CGLIBLazyInitializer extends LazyInitializer implements MethodInterceptor { *************** *** 41,50 **** } ! public boolean invokeSuper(Object obj, Method method, Object args[]) throws Throwable { ! return false; ! } ! ! ! public Object afterReturn(Object obj, Method method, Object args[], boolean invokedSuper, Object retValFromSuper, Throwable e) throws Throwable{ return invoke(method, args); } --- 42,46 ---- } ! public Object intercept(Object obj, Method method, Object args[], MethodProxy proxy) throws Throwable{ return invoke(method, args); } Index: HibernateProxyHelper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/proxy/HibernateProxyHelper.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** HibernateProxyHelper.java 14 Jan 2003 13:42:17 -0000 1.4 --- HibernateProxyHelper.java 15 Feb 2003 08:00:52 -0000 1.5 *************** *** 2,6 **** package net.sf.hibernate.proxy; ! import net.sf.cglib.proxy.Enhancer; import net.sf.hibernate.HibernateException; --- 2,6 ---- package net.sf.hibernate.proxy; ! import net.sf.cglib.Enhancer; import net.sf.hibernate.HibernateException; |
From: <one...@us...> - 2003-02-15 08:01:25
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister In directory sc8-pr-cvs1:/tmp/cvs-serv27994/sf/hibernate/persister Modified Files: AbstractEntityPersister.java EntityPersister.java Log Message: integrated latest cglib + reflection optimizer Index: AbstractEntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister/AbstractEntityPersister.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** AbstractEntityPersister.java 2 Feb 2003 04:19:51 -0000 1.12 --- AbstractEntityPersister.java 15 Feb 2003 08:00:50 -0000 1.13 *************** *** 12,19 **** --- 12,22 ---- import org.apache.commons.logging.LogFactory; + import net.sf.cglib.MetaClass; + import net.sf.hibernate.HibernateException; import net.sf.hibernate.InstantiationException; import net.sf.hibernate.Lifecycle; import net.sf.hibernate.MappingException; + import net.sf.hibernate.PropertyAccessException; import net.sf.hibernate.QueryException; import net.sf.hibernate.StaleObjectStateException; *************** *** 118,121 **** --- 121,126 ---- private transient final Cascades.CascadeStyle[] cascadeStyles; private transient final CacheConcurrencyStrategy cache; + + private transient final MetaClass optimizer; public final Class getMappedClass() { *************** *** 213,216 **** --- 218,231 ---- */ public void setPropertyValues(Object object, Object[] values) throws HibernateException { + try{ + if (optimizer!=null) { + optimizer.setPropertyValues(object, values); + return; + } + } + catch (Throwable t) { + throw new PropertyAccessException(t, "exception setting property value with CGLIB", true, mappedClass, "?"); + } + for (int j=0; j<hydrateSpan; j++) getSetters()[j].set(object, values[j]); } *************** *** 220,223 **** --- 235,247 ---- */ public Object[] getPropertyValues(Object object) throws HibernateException { + try{ + if (optimizer!=null) { + return optimizer.getPropertyValues(object); + } + } + catch (Throwable t) { + throw new PropertyAccessException(t, "exception getting property value with CGLIB", false, mappedClass, "?"); + } + Object[] result = new Object[hydrateSpan]; for (int j=0; j<hydrateSpan; j++) result[j] = getGetters()[j].get(object); *************** *** 295,302 **** if (abstractClass) throw new HibernateException("Cannot instantiate abstract class or interface: " + className); try { return constructor.newInstance(null); } catch (Exception e) { ! throw new InstantiationException( "Could not instantiate entity ", mappedClass, e ); } } --- 319,334 ---- if (abstractClass) throw new HibernateException("Cannot instantiate abstract class or interface: " + className); try { + if (optimizer != null) { + try { + return optimizer.newInstance(); + } + catch (Throwable t) { + throw new InstantiationException("Could not instantiate entity with CGLIB: ", mappedClass, t); + } + } return constructor.newInstance(null); } catch (Exception e) { ! throw new InstantiationException("Could not instantiate entity: ", mappedClass, e); } } *************** *** 607,610 **** --- 639,645 ---- setters = new ReflectHelper.Setter[hydrateSpan]; cascadeStyles = new Cascades.CascadeStyle[hydrateSpan]; + String setterNames[] = new String[hydrateSpan]; + String getterNames[] = new String[hydrateSpan]; + Class types[] = new Class[hydrateSpan]; iter = model.getPropertyClosureIterator(); *************** *** 619,622 **** --- 654,660 ---- getters[i] = ReflectHelper.getGetter( mappedClass, propertyNames[i] ); setters[i] = ReflectHelper.getSetter( mappedClass, propertyNames[i] ); + getterNames[i]= getters[i].getMethod().getName(); + setterNames[i]= setters[i].getMethod().getName(); + types[i] = getters[i].getMethod().getReturnType(); propertyTypes[i] = prop.getType(); propertyUpdateability[i] = prop.isUpdateable(); *************** *** 629,632 **** --- 667,681 ---- } + MetaClass opt; + try { + opt = MetaClass.getInstance( mappedClass.getClassLoader(), mappedClass, getterNames, setterNames, types ); + opt.setPropertyValues( opt.newInstance(), opt.getPropertyValues( opt.newInstance() ) ); + } + catch(Throwable t) { + opt=null; + log.info("reflection optimizer disabled for: " + mappedClass); + } + optimizer=opt; + hasCascades = foundCascade; versionProperty = tempVersionProperty; *************** *** 707,711 **** return propertyInsertability; } ! } --- 756,760 ---- return propertyInsertability; } ! } Index: EntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister/EntityPersister.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** EntityPersister.java 9 Feb 2003 06:28:15 -0000 1.16 --- EntityPersister.java 15 Feb 2003 08:00:50 -0000 1.17 *************** *** 114,121 **** AbstractComponentType actype = (AbstractComponentType) idType; String[] props = actype.getPropertyNames(); ! if (props.length!=columns.length) throw new MappingException("broken mapping for: " + getClassName() + StringHelper.DOT + path); for ( int i=0; i<props.length; i++ ) { String subidpath = idpath + StringHelper.DOT + props[i]; ! columnNamesByPropertyPath.put( subidpath, new String[] { columns[i] } ); mods.put( subidpath, actype.getSubtypes()[i] ); } --- 114,128 ---- AbstractComponentType actype = (AbstractComponentType) idType; String[] props = actype.getPropertyNames(); ! Type[] subtypes = actype.getSubtypes(); ! if ( actype.getColumnSpan(factory)!=columns.length ) ! throw new MappingException("broken mapping for: " + getClassName() + StringHelper.DOT + path); ! int j=0; for ( int i=0; i<props.length; i++ ) { String subidpath = idpath + StringHelper.DOT + props[i]; ! String[] componentColumns = new String[ subtypes[i].getColumnSpan(factory) ]; ! for (int k = 0; k < componentColumns.length; k++) { ! componentColumns[k] = columns[j++]; ! } ! columnNamesByPropertyPath.put(subidpath, componentColumns); mods.put( subidpath, actype.getSubtypes()[i] ); } |
From: <one...@us...> - 2003-02-15 08:01:23
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv27994/sf/hibernate Modified Files: PropertyAccessException.java Log Message: integrated latest cglib + reflection optimizer Index: PropertyAccessException.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/PropertyAccessException.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PropertyAccessException.java 20 Jan 2003 12:48:08 -0000 1.4 --- PropertyAccessException.java 15 Feb 2003 08:00:49 -0000 1.5 *************** *** 15,19 **** private final boolean wasSetter; ! public PropertyAccessException(Exception root, String s, boolean wasSetter, Class persistentClass, String propertyName) { super(s, root); this.persistentClass = persistentClass; --- 15,19 ---- private final boolean wasSetter; ! public PropertyAccessException(Throwable root, String s, boolean wasSetter, Class persistentClass, String propertyName) { super(s, root); this.persistentClass = persistentClass; |
From: <one...@us...> - 2003-02-15 08:01:08
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util In directory sc8-pr-cvs1:/tmp/cvs-serv27994/sf/hibernate/util Modified Files: ReflectHelper.java Log Message: integrated latest cglib + reflection optimizer Index: ReflectHelper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/util/ReflectHelper.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ReflectHelper.java 27 Jan 2003 07:27:44 -0000 1.6 --- ReflectHelper.java 15 Feb 2003 08:00:56 -0000 1.7 *************** *** 41,45 **** catch (NullPointerException npe) { if ( value==null && method.getParameterTypes()[0].isPrimitive() ) { ! throw new PropertyAccessException(npe, "Null values was assigned to a property of primitive type", true, clazz, propertyName); } else { --- 41,45 ---- catch (NullPointerException npe) { if ( value==null && method.getParameterTypes()[0].isPrimitive() ) { ! throw new PropertyAccessException(npe, "Null value was assigned to a property of primitive type", true, clazz, propertyName); } else { *************** *** 57,60 **** --- 57,64 ---- throw new PropertyAccessException(iae, "IllegalArgumentException occurred while calling", true, clazz, propertyName); } + } + + public Method getMethod() { + return method; } |
From: <one...@us...> - 2003-02-15 04:31:09
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister In directory sc8-pr-cvs1:/tmp/cvs-serv6001/hibernate/persister Modified Files: EntityPersister.java Log Message: support for composite id class as target of key-many-to-one Index: EntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister/EntityPersister.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** EntityPersister.java 17 Jan 2003 10:27:10 -0000 1.49 --- EntityPersister.java 15 Feb 2003 04:31:06 -0000 1.50 *************** *** 107,114 **** AbstractComponentType actype = (AbstractComponentType) idType; String[] props = actype.getPropertyNames(); ! if (props.length!=columns.length) throw new MappingException("broken mapping for: " + getClassName() + '.' + path); for ( int i=0; i<props.length; i++ ) { String subidpath = idpath + '.' + props[i]; ! columnNamesByPropertyPath.put( subidpath, new String[] { columns[i] } ); mods.put( subidpath, actype.getSubtypes()[i] ); } --- 107,121 ---- AbstractComponentType actype = (AbstractComponentType) idType; String[] props = actype.getPropertyNames(); ! Type[] subtypes = actype.getSubtypes(); ! if ( actype.getColumnSpan(factory)!=columns.length ) ! throw new MappingException("broken mapping for: " + getClassName() + '.' + path); ! int j=0; for ( int i=0; i<props.length; i++ ) { String subidpath = idpath + '.' + props[i]; ! String[] componentColumns = new String[ subtypes[i].getColumnSpan(factory) ]; ! for (int k = 0; k < componentColumns.length; k++) { ! componentColumns[k] = columns[j++]; ! } ! columnNamesByPropertyPath.put(subidpath, componentColumns); mods.put( subidpath, actype.getSubtypes()[i] ); } |
From: <one...@us...> - 2003-02-15 01:14:40
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv5415/hibernate/test Modified Files: FooBarTest.java Log Message: fix problem wrapping sorted collections don't update if mutable='false' Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/FooBarTest.java,v retrieving revision 1.239 retrieving revision 1.240 diff -C2 -d -r1.239 -r1.240 *** FooBarTest.java 22 Jan 2003 13:32:19 -0000 1.239 --- FooBarTest.java 15 Feb 2003 01:14:37 -0000 1.240 *************** *** 765,768 **** --- 765,770 ---- assertTrue( list.size()==2, "component query" ); s.find("from foo in class Foo where not exists (from bar in class Bar where bar.id = foo.id)"); + + s.iterate("select foo.string, foo.date, foo.foo.string from foo in class Foo, baz in class Baz where foo in baz.fooArray.elements and foo.string like 'foo'"); } list = s.find("from foo in class cirrus.hibernate.test.Foo where foo.component.count is null order by foo.component.count"); |
From: <one...@us...> - 2003-02-15 01:14:40
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv5415/hibernate/impl Modified Files: SessionImpl.java Log Message: fix problem wrapping sorted collections don't update if mutable='false' Index: SessionImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl/SessionImpl.java,v retrieving revision 1.162 retrieving revision 1.163 diff -C2 -d -r1.162 -r1.163 *** SessionImpl.java 22 Jan 2003 13:32:19 -0000 1.162 --- SessionImpl.java 15 Feb 2003 01:14:37 -0000 1.163 *************** *** 266,269 **** --- 266,270 ---- } } + } *************** *** 1762,1771 **** // compare to cached state (ignoring nested collections) if ( ! noCleanState || ! (dirtyProperties!=null) || ( ! status==LOADED && ! persister.isVersioned() && ! persister.hasCollections() && ! searchForDirtyCollections(values, types) ) ) { // its dirty! --- 1763,1774 ---- // compare to cached state (ignoring nested collections) if ( ! persister.isMutable() && ( ! noCleanState || ! (dirtyProperties!=null) || ( ! status==LOADED && ! persister.isVersioned() && ! persister.hasCollections() && ! searchForDirtyCollections(values, types) ! ) ) ) { // its dirty! |
From: <one...@us...> - 2003-02-15 01:14:40
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/collections In directory sc8-pr-cvs1:/tmp/cvs-serv5415/hibernate/collections Modified Files: SortedMap.java SortedSet.java Log Message: fix problem wrapping sorted collections don't update if mutable='false' Index: SortedMap.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/collections/SortedMap.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** SortedMap.java 26 Nov 2002 03:35:41 -0000 1.22 --- SortedMap.java 15 Feb 2003 01:14:37 -0000 1.23 *************** *** 57,69 **** this.comparator = comparator; } ! ! //need to distinguish between the different 2-argument constructors ! /*public SortedMap(SessionImplementor session, Comparator comp) { ! super(session); ! this.map = new TreeMap(comp); ! }*/ ! public SortedMap(SessionImplementor session, java.util.SortedMap map) { super(session, map); } --- 57,64 ---- this.comparator = comparator; } ! public SortedMap(SessionImplementor session, java.util.SortedMap map) { super(session, map); + comparator = map.comparator(); } Index: SortedSet.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/collections/SortedSet.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** SortedSet.java 1 Oct 2002 01:25:29 -0000 1.22 --- SortedSet.java 15 Feb 2003 01:14:37 -0000 1.23 *************** *** 58,61 **** --- 58,62 ---- public SortedSet(SessionImplementor session, java.util.SortedSet set) { super(session, set); + comparator = set.comparator(); } |
From: <one...@us...> - 2003-02-15 01:14:40
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/ps In directory sc8-pr-cvs1:/tmp/cvs-serv5415/hibernate/ps Modified Files: PreparedStatementCache.java Log Message: fix problem wrapping sorted collections don't update if mutable='false' Index: PreparedStatementCache.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/ps/PreparedStatementCache.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PreparedStatementCache.java 21 Oct 2002 03:45:03 -0000 1.11 --- PreparedStatementCache.java 15 Feb 2003 01:14:37 -0000 1.12 *************** *** 2,8 **** package cirrus.hibernate.ps; ! import java.sql.*; ! import org.apache.commons.logging.*; ! import java.util.*; import cirrus.hibernate.helpers.IdentityMap; --- 2,18 ---- package cirrus.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 org.apache.commons.logging.Log; ! import org.apache.commons.logging.LogFactory; import cirrus.hibernate.helpers.IdentityMap; |
From: <one...@us...> - 2003-02-15 01:07:38
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv2743/sf/hibernate/test Added Files: FumTest.java Log Message: seperated out the composite-id tests --- NEW FILE: FumTest.java --- //$Id: FumTest.java,v 1.1 2003/02/15 01:07:32 oneovthafew Exp $ package net.sf.hibernate.test; import java.io.Serializable; import java.util.ArrayList; import java.util.Date; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Properties; import java.util.Set; import junit.framework.Test; import junit.framework.TestSuite; import net.sf.hibernate.Hibernate; import net.sf.hibernate.LockMode; import net.sf.hibernate.Query; import net.sf.hibernate.Session; import net.sf.hibernate.dialect.MckoiDialect; import net.sf.hibernate.type.DateType; import net.sf.hibernate.type.EntityType; import net.sf.hibernate.type.StringType; import net.sf.hibernate.type.Type; public class FumTest extends TestCase { protected static short fumKeyShort = 1; public FumTest(String arg) { super(arg); } public void testListIdentifiers() throws Exception { Session s = sessions.openSession(); Fum fum = new Fum( fumKey("fum") ); fum.setFum("fo fee fi"); s.save(fum); fum = new Fum( fumKey("fi") ); fum.setFum("fee fi fo"); s.save(fum); List list = s.find("select fum.id from fum in class net.sf.hibernate.test.Fum where not fum.fum='FRIEND'"); assertTrue( list.size()==2, "list identifiers"); Iterator iter = s.iterate("select fum.id from fum in class net.sf.hibernate.test.Fum where not fum.fum='FRIEND'"); int i=0; while ( iter.hasNext() ) { assertTrue( iter.next() instanceof FumCompositeID, "iterate identifiers"); i++; } assertTrue(i==2); s.delete( s.load(Fum.class, (Serializable) list.get(0) ) ); s.delete( s.load(Fum.class, (Serializable) list.get(1) ) ); s.flush(); s.connection().commit(); s.close(); } static FumCompositeID fumKey(String str) { return fumKey(str,false); } static FumCompositeID fumKey(String str, boolean aCompositeQueryTest) { FumCompositeID id = new FumCompositeID(); if( dialect instanceof MckoiDialect ) { java.util.GregorianCalendar now = new java.util.GregorianCalendar(); java.util.GregorianCalendar cal = new java.util.GregorianCalendar( now.get(java.util.Calendar.YEAR), now.get(java.util.Calendar.MONTH), now.get(java.util.Calendar.DATE) ); id.setDate( cal.getTime() ); } else id.setDate( new Date() ); id.setString( new String(str) ); if (aCompositeQueryTest) id.setShort( fumKeyShort++ ); else id.setShort((short)12); return id; } public void testCompositeID() throws Exception { Session s = sessions.openSession(); Fum fum = new Fum( fumKey("fum") ); fum.setFum("fee fi fo"); s.save(fum); assertTrue( fum==s.load( Fum.class, fumKey("fum") ), "load by composite key" ); s.flush(); s.connection().commit(); s.close(); s = sessions.openSession(); fum = (Fum) s.load( Fum.class, fumKey("fum"), LockMode.UPGRADE ); assertTrue( fum!=null, "load by composite key" ); Fum fum2 = new Fum( fumKey("fi") ); fum2.setFum("fee fo fi"); fum.setFo(fum2); s.save(fum2); assertTrue( s.find("from fum in class net.sf.hibernate.test.Fum where not fum.fum='FRIEND'").size()==2, "find composite keyed objects" ); assertTrue( s.find("select fum from fum in class net.sf.hibernate.test.Fum where fum.fum='fee fi fo'").get(0)==fum, "find composite keyed object" ); fum.setFo(null); s.flush(); s.connection().commit(); s.close(); s = sessions.openSession(); Iterator iter = s.iterate("from fum in class net.sf.hibernate.test.Fum where not fum.fum='FRIEND'"); int i = 0; while ( iter.hasNext() ) { fum = (Fum) iter.next(); //iter.remove(); s.delete(fum); i++; } assertTrue( i==2, "iterate on composite key" ); s.flush(); s.connection().commit(); s.close(); } public void testCompositeIDOneToOne() throws Exception { Session s = sessions.openSession(); Fum fum = new Fum( fumKey("fum") ); fum.setFum("fee fi fo"); //s.save(fum); Fumm fumm = new Fumm(); fumm.setFum(fum); s.save(fumm); s.flush(); s.connection().commit(); s.close(); s = sessions.openSession(); fumm = (Fumm) s.load( Fumm.class, fumKey("fum") ); //s.delete( fumm.getFum() ); s.delete(fumm); s.flush(); s.connection().commit(); s.close(); } public void testCompositeIDQuery() throws Exception { Session s = sessions.openSession(); Fum fee = new Fum( fumKey("fee",true) ); fee.setFum("fee"); s.save(fee); Fum fi = new Fum( fumKey("fi",true) ); fi.setFum("fi"); short fiShort = fi.getId().getShort(); s.save(fi); Fum fo = new Fum( fumKey("fo",true) ); fo.setFum("fo"); s.save(fo); Fum fum = new Fum( fumKey("fum",true) ); fum.setFum("fum"); s.save(fum); s.flush(); s.connection().commit(); s.close(); s = sessions.openSession(); // Try to find the Fum object "fo" that we inserted searching by the string in the id List vList = s.find("from fum in class net.sf.hibernate.test.Fum where fum.id.string='fo'" ); assertTrue( vList.size() == 1, "find by composite key query (find fo object)" ); fum = (Fum)vList.get(0); assertTrue( fum.getId().getString().equals("fo"), "find by composite key query (check fo object)" ); // Try to find the Fum object "fi" that we inserted searching by the date in the id vList = s.find("from fum in class net.sf.hibernate.test.Fum where fum.id.short = ?",new Short(fiShort),Hibernate.SHORT); assertTrue( vList.size() == 1, "find by composite key query (find fi object)" ); fi = (Fum)vList.get(0); assertTrue( fi.getId().getString().equals("fi"), "find by composite key query (check fi object)" ); // Make sure we can return all of the objects by searching by the date id assertTrue( s.find("from fum in class net.sf.hibernate.test.Fum where fum.id.date <= ? and not fum.fum='FRIEND'",new Date(),Hibernate.DATE).size()==4, "find by composite key query with arguments" ); s.flush(); s.connection().commit(); s.close(); s = sessions.openSession(); assertTrue( s.iterate("select fum.id.short, fum.id.date, fum.id.string from fum in class net.sf.hibernate.test.Fum").hasNext() ); assertTrue( s.iterate("select fum.id from fum in class net.sf.hibernate.test.Fum").hasNext() ); Query qu = s.createQuery("select fum.fum, fum , fum.fum, fum.id.date from fum in class net.sf.hibernate.test.Fum"); Type[] types = qu.getReturnTypes(); assertTrue(types.length==4); for ( int k=0; k<types.length; k++) { assertTrue( types[k]!=null ); } assertTrue(types[0] instanceof StringType); assertTrue(types[1] instanceof EntityType); assertTrue(types[2] instanceof StringType); assertTrue(types[3] instanceof DateType); Iterator iter = qu.iterate(); int j = 0; while ( iter.hasNext() ) { j++; assertTrue( ( (Object[]) iter.next() )[1] instanceof Fum ); } assertTrue( j==8, "iterate on composite key" ); iter = s.iterate("from fum in class net.sf.hibernate.test.Fum where not fum.fum='FRIEND'"); int i = 0; while ( iter.hasNext() ) { fum = (Fum) iter.next(); //iter.remove(); s.delete(fum); i++; } assertTrue( i==4, "iterate on composite key" ); s.flush(); s.iterate("from fu in class Fum, fo in class Fum where fu.fo.id.string = fo.id.string and fo.fum is not null"); s.connection().commit(); s.close(); } public void testCompositeIDCollections() throws Exception { Session s = sessions.openSession(); Fum fum1 = new Fum( fumKey("fum1") ); Fum fum2 = new Fum( fumKey("fum2") ); fum1.setFum("fee fo fi"); fum2.setFum("fee fo fi"); s.save(fum1); s.save(fum2); Qux q = new Qux(); s.save(q); Set set = new HashSet(); List list = new ArrayList(); set.add(fum1); set.add(fum2); list.add(fum1); q.setFums(set); q.setMoreFums(list); fum1.setQuxArray( new Qux[] {q} ); s.flush(); s.connection().commit(); s.close(); s = sessions.openSession(); q = (Qux) s.load( Qux.class, q.getKey() ); assertTrue( q.getFums().size()==2, "collection of fums" ); assertTrue( q.getMoreFums().size()==1, "collection of fums" ); assertTrue( ( (Fum) q.getMoreFums().get(0) ).getQuxArray()[0]==q, "unkeyed composite id collection" ); Iterator iter = q.getFums().iterator(); iter.hasNext(); s.delete( (Fum) iter.next() ); iter.hasNext(); s.delete( (Fum) iter.next() ); s.delete(q); s.flush(); s.connection().commit(); s.close(); } public void testDeleteOwner() throws Exception { Session s = sessions.openSession(); Qux q = new Qux(); s.save(q); Fum f1 = new Fum( fumKey("f1") ); Fum f2 = new Fum( fumKey("f2") ); Set set = new HashSet(); set.add(f1); set.add(f2); List list = new LinkedList(); list.add(f1); list.add(f2); f1.setFum("f1"); f2.setFum("f2"); q.setFums(set); q.setMoreFums(list); s.save(f1); s.save(f2); s.flush(); s.connection().commit(); s.close(); s = sessions.openSession(); q = (Qux) s.load( Qux.class, q.getKey(), LockMode.UPGRADE ); s.lock( q, LockMode.UPGRADE ); s.delete(q); s.flush(); s.connection().commit(); s.close(); s = sessions.openSession(); list = s.find("from fum in class net.sf.hibernate.test.Fum where not fum.fum='FRIEND'"); assertTrue( list.size()==2, "deleted owner" ); s.lock( list.get(0), LockMode.UPGRADE ); s.lock( list.get(1), LockMode.UPGRADE ); Iterator iter = list.iterator(); while ( iter.hasNext() ) { s.delete( iter.next() ); } s.flush(); s.connection().commit(); s.close(); } public void testCompositeIDs() throws Exception { Session s = sessions.openSession(); Fo fo = new Fo(); Properties props = new Properties(); props.setProperty("foo", "bar"); props.setProperty("bar", "foo"); fo.setSerial(props); fo.setBuf( "abcdefghij1`23%$*^*$*\n\t".getBytes() ); s.save( fo, fumKey("an instance of fo") ); s.flush(); props.setProperty("x", "y"); s.flush(); s.connection().commit(); s.close(); s = sessions.openSession(); fo = (Fo) s.load( Fo.class, fumKey("an instance of fo") ); props = (Properties) fo.getSerial(); assertTrue( props.getProperty("foo").equals("bar") ); assertTrue( props.getProperty("x").equals("y") ); assertTrue( fo.getBuf()[0]=='a' ); fo.getBuf()[1]=(byte)126; s.flush(); s.connection().commit(); s.close(); s = sessions.openSession(); fo = (Fo) s.load( Fo.class, fumKey("an instance of fo") ); assertTrue( fo.getBuf()[1]==126 ); assertTrue( s.iterate("from fo in class net.sf.hibernate.test.Fo where fo.id.string like 'an instance of fo'").next()==fo ); s.delete(fo); s.flush(); try { s.save( new Fo() ); assertTrue(false); } catch (Exception e) { //System.out.println( e.getMessage() ); } s.connection().commit(); s.close(); } public static Test suite() throws Exception { try { TestCase.exportSchema( new String[] { "FooBar.hbm.xml", "Baz.hbm.xml", "Qux.hbm.xml", "Glarch.hbm.xml", "Fum.hbm.xml", "Fumm.hbm.xml", "Fo.hbm.xml", "One.hbm.xml", "Many.hbm.xml", "Immutable.hbm.xml", "Fee.hbm.xml", "Vetoer.hbm.xml", "Holder.hbm.xml", "Location.hbm.xml", "Stuff.hbm.xml", "Container.hbm.xml", "Simple.hbm.xml" } ); return new TestSuite(FumTest.class); } catch (Exception e) { e.printStackTrace(); throw e; } } } |
From: <one...@us...> - 2003-02-15 01:01:34
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping In directory sc8-pr-cvs1:/tmp/cvs-serv32602/sf/hibernate/mapping Modified Files: Collection.java Log Message: fixed a bug wrapping sorted collections don't ever update mutable=false objects added where attribute to collection mappings Index: Collection.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Collection.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Collection.java 27 Jan 2003 12:51:50 -0000 1.12 --- Collection.java 15 Feb 2003 01:00:55 -0000 1.13 *************** *** 24,27 **** --- 24,28 ---- private CacheConcurrencyStrategy cache; private String orderBy; + private String where; private PersistentClass owner; private boolean sorted; *************** *** 36,43 **** } - public String getOrderByString() { - return orderBy; - } - public Value getKey() { return key; --- 37,40 ---- *************** *** 214,217 **** --- 211,230 ---- public void setOwner(PersistentClass owner) { this.owner = owner; + } + + /** + * Returns the where. + * @return String + */ + public String getWhere() { + return where; + } + + /** + * Sets the where. + * @param where The where to set + */ + public void setWhere(String where) { + this.where = where; } |
From: <one...@us...> - 2003-02-15 01:01:33
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader In directory sc8-pr-cvs1:/tmp/cvs-serv32602/sf/hibernate/loader Modified Files: CollectionLoader.java Loader.java OneToManyLoader.java Log Message: fixed a bug wrapping sorted collections don't ever update mutable=false objects added where attribute to collection mappings Index: CollectionLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/CollectionLoader.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CollectionLoader.java 1 Feb 2003 12:22:35 -0000 1.8 --- CollectionLoader.java 15 Feb 2003 01:00:53 -0000 1.9 *************** *** 38,41 **** --- 38,44 ---- String alias = alias( persister.getQualifiedTableName(), 0 ); + String whereString=""; + if ( persister.hasWhere() ) whereString = " and " + persister.getSQLWhereString(alias); + List associations = walkTree(persister, alias, session); *************** *** 54,58 **** new ConditionFragment().setTableAlias(alias) .setCondition( persister.getKeyColumnNames(), "?" ) ! .toFragmentString() ) .setOuterJoins( --- 57,62 ---- new ConditionFragment().setTableAlias(alias) .setCondition( persister.getKeyColumnNames(), "?" ) ! .toFragmentString() + ! whereString ) .setOuterJoins( Index: Loader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/Loader.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Loader.java 3 Feb 2003 10:28:47 -0000 1.10 --- Loader.java 15 Feb 2003 01:00:54 -0000 1.11 *************** *** 105,117 **** final Key optionalObjectKey; - //boolean success; if (optionalObject!=null) { optionalObjectKey = new Key( optionalID, session.getPersister(optionalObject) ); - //success = false; } else { optionalObjectKey = null; - //success = true; } --- 105,114 ---- *************** *** 257,262 **** //its the given optional object object=optionalObject; - //success=true; - } else { --- 254,257 ---- Index: OneToManyLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/OneToManyLoader.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** OneToManyLoader.java 1 Feb 2003 12:22:35 -0000 1.9 --- OneToManyLoader.java 15 Feb 2003 01:00:54 -0000 1.10 *************** *** 46,49 **** --- 46,52 ---- String collAlias = persister.getConcreteClassAlias(alias); + String whereString=""; + if ( collPersister.hasWhere() ) whereString = " and " + collPersister.getSQLWhereString(collAlias); + List associations = walkTree(persister, alias, session); *************** *** 68,71 **** --- 71,75 ---- .setCondition( collPersister.getKeyColumnNames(), "?" ) .toFragmentString() + + whereString ) .setOuterJoins( |
From: <one...@us...> - 2003-02-15 01:01:27
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv32602/sf/hibernate/impl Modified Files: SessionImpl.java Log Message: fixed a bug wrapping sorted collections don't ever update mutable=false objects added where attribute to collection mappings Index: SessionImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionImpl.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** SessionImpl.java 9 Feb 2003 07:41:15 -0000 1.19 --- SessionImpl.java 15 Feb 2003 01:00:52 -0000 1.20 *************** *** 1140,1144 **** if (old==object) { throw new AssertionFailure( ! "Hibernate has a bug in update() ... or you are using an illegal id type" + infoString(persister, id) ); --- 1140,1144 ---- if (old==object) { throw new AssertionFailure( ! "Hibernate has a bug in update() ... or you are using an illegal id type: " + infoString(persister, id) ); *************** *** 1943,1947 **** entry.id + " to " + oid - ); } --- 1943,1946 ---- *************** *** 1977,1981 **** cannotDirtyCheck = entry.loadedState==null; // object loaded by update() if (!cannotDirtyCheck) { ! dirtyProperties = dirtyProperties = persister.findDirty(values, entry.loadedState, object, this); } } --- 1976,1980 ---- cannotDirtyCheck = entry.loadedState==null; // object loaded by update() if (!cannotDirtyCheck) { ! dirtyProperties = persister.findDirty(values, entry.loadedState, object, this); } } *************** *** 1986,1996 **** // compare to cached state (ignoring nested collections) ! if ( ! cannotDirtyCheck || ! (dirtyProperties!=null && dirtyProperties.length!=0 ) || ( ! status==LOADED && ! persister.isVersioned() && ! persister.hasCollections() && ! searchForDirtyCollections(values, types) ) ) { // its dirty! --- 1985,1997 ---- // compare to cached state (ignoring nested collections) ! if ( ! persister.isMutable() && ( ! cannotDirtyCheck || ! ( dirtyProperties!=null && dirtyProperties.length!=0 ) || ( ! status==LOADED && ! persister.isVersioned() && ! persister.hasCollections() && ! searchForDirtyCollections(values, types) ! ) ) ) { // its dirty! |
From: <one...@us...> - 2003-02-15 01:01:27
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection In directory sc8-pr-cvs1:/tmp/cvs-serv32602/sf/hibernate/collection Modified Files: CollectionPersister.java SortedMap.java SortedSet.java Log Message: fixed a bug wrapping sorted collections don't ever update mutable=false objects added where attribute to collection mappings Index: CollectionPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/CollectionPersister.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CollectionPersister.java 9 Feb 2003 07:41:15 -0000 1.10 --- CollectionPersister.java 15 Feb 2003 01:00:51 -0000 1.11 *************** *** 6,9 **** --- 6,10 ---- import java.sql.ResultSet; import java.sql.SQLException; + import java.util.HashSet; import java.util.Iterator; import java.util.StringTokenizer; *************** *** 56,60 **** --- 57,63 ---- private final String sqlDeleteRowString; private final String sqlOrderByString; + private final String sqlWhereString; private final boolean hasOrder; + private final boolean hasWhere; private final boolean isSet; private final Type keyType; *************** *** 95,100 **** ownerClass = collection.getOwnerClass(); ! hasOrder = collection.getOrderByString()!=null; ! sqlOrderByString = collection.getOrderByString(); cache=collection.getCache(); --- 98,105 ---- ownerClass = collection.getOwnerClass(); ! sqlOrderByString = collection.getOrderBy(); ! hasOrder = sqlOrderByString!=null; ! sqlWhereString = collection.getWhere(); ! hasWhere = sqlWhereString!=null; cache=collection.getCache(); *************** *** 236,241 **** } ! public String getSQLOrderByString() { ! return sqlOrderByString; } --- 241,268 ---- } ! public String getSQLWhereString(String alias) { ! StringTokenizer tokens = new StringTokenizer(sqlWhereString, " =><!", true); ! StringBuffer result = new StringBuffer(); ! while ( tokens.hasMoreTokens() ) { ! String token = tokens.nextToken(); ! if ( Character.isLetter( token.charAt(0) ) && !keywords.contains(token) ) { ! //TODO: handle and, or, not ! result.append(alias).append(StringHelper.DOT).append(token); ! } ! else { ! result.append(token); ! } ! } ! return result.toString(); ! } ! ! private static final java.util.Set keywords = new HashSet(); ! static { ! keywords.add("and"); ! keywords.add("or"); ! keywords.add("not"); ! keywords.add("like"); ! keywords.add("is"); ! keywords.add("null"); } *************** *** 256,259 **** --- 283,290 ---- public boolean hasOrdering() { return hasOrder; + } + + public boolean hasWhere() { + return hasWhere; } Index: SortedMap.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/SortedMap.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SortedMap.java 9 Feb 2003 07:41:15 -0000 1.6 --- SortedMap.java 15 Feb 2003 01:00:51 -0000 1.7 *************** *** 67,70 **** --- 67,71 ---- public SortedMap(SessionImplementor session, java.util.SortedMap map) { super(session, map); + comparator = map.comparator(); } Index: SortedSet.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/SortedSet.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SortedSet.java 9 Feb 2003 07:41:15 -0000 1.6 --- SortedSet.java 15 Feb 2003 01:00:51 -0000 1.7 *************** *** 46,49 **** --- 46,50 ---- public SortedSet(SessionImplementor session, java.util.SortedSet set) { super(session, set); + comparator = set.comparator(); } |
From: <one...@us...> - 2003-02-15 01:01:24
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg In directory sc8-pr-cvs1:/tmp/cvs-serv32602/sf/hibernate/cfg Modified Files: Binder.java Log Message: fixed a bug wrapping sorted collections don't ever update mutable=false objects added where attribute to collection mappings Index: Binder.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Binder.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Binder.java 9 Feb 2003 06:28:14 -0000 1.6 --- Binder.java 15 Feb 2003 01:00:50 -0000 1.7 *************** *** 363,366 **** --- 363,370 ---- log.warn("Attribute \"order-by\" ignored in JDK1.3 or less"); } + } + Attribute whereNode = node.attribute("where"); + if (whereNode!=null) { + model.setWhere( whereNode.getValue() ); } |
From: <one...@us...> - 2003-02-15 01:01:22
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv32602/sf/hibernate Modified Files: hibernate-mapping-2.0.dtd Log Message: fixed a bug wrapping sorted collections don't ever update mutable=false objects added where attribute to collection mappings Index: hibernate-mapping-2.0.dtd =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hibernate-mapping-2.0.dtd,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** hibernate-mapping-2.0.dtd 9 Feb 2003 06:28:14 -0000 1.14 --- hibernate-mapping-2.0.dtd 15 Feb 2003 01:00:49 -0000 1.15 *************** *** 209,212 **** --- 209,213 ---- <!ATTLIST map cascade (none|all|save-update|delete) #IMPLIED> <!-- default: none --> <!ATTLIST map order-by CDATA #IMPLIED> <!-- default: none --> + <!ATTLIST map where CDATA #IMPLIED> <!-- default: none --> <!ELEMENT set ( *************** *** 224,227 **** --- 225,229 ---- <!ATTLIST set cascade (none|all|save-update|delete) #IMPLIED> <!-- default: none --> <!ATTLIST set order-by CDATA #IMPLIED> <!-- default: none --> + <!ATTLIST set where CDATA #IMPLIED> <!-- default: none --> <!ELEMENT bag ( *************** *** 238,241 **** --- 240,244 ---- <!ATTLIST bag cascade (none|all|save-update|delete) #IMPLIED> <!-- default: none --> <!ATTLIST bag order-by CDATA #IMPLIED> <!-- default: none --> + <!ATTLIST bag where CDATA #IMPLIED> <!-- default: none --> <!ELEMENT list ( *************** *** 252,255 **** --- 255,259 ---- <!ATTLIST list inverse (true|false) "false"> <!ATTLIST list cascade (none|all|save-update|delete) #IMPLIED> <!-- default: none --> + <!ATTLIST list where CDATA #IMPLIED> <!-- default: none --> <!ELEMENT array ( *************** *** 265,268 **** --- 269,273 ---- <!ATTLIST array element-class CDATA #IMPLIED> <!ATTLIST array cascade (none|all|save-update|delete) #IMPLIED> <!-- default: none --> + <!ATTLIST array where CDATA #IMPLIED> <!-- default: none --> <!ELEMENT primitive-array (meta*, jcs-cache?, key, index, element)> *************** *** 270,273 **** --- 275,279 ---- <!ATTLIST primitive-array table CDATA #IMPLIED> <!-- default: name --> <!ATTLIST primitive-array schema CDATA #IMPLIED> <!-- default: none --> + <!ATTLIST primitive-array where CDATA #IMPLIED> <!-- default: none --> <!-- Declares the element type of a collection of basic type --> |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv32602/sf/hibernate/test Modified Files: Baz.hbm.xml Baz.java FooBarTest.java MultiTableTest.java SQLFunctionsTest.java Added Files: Blobber.hbm.xml Blobber.java Log Message: fixed a bug wrapping sorted collections don't ever update mutable=false objects added where attribute to collection mappings --- NEW FILE: Blobber.hbm.xml --- <?xml version="1.0"?> <!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" > <hibernate-mapping> <class name="net.sf.hibernate.test.Blobber" dynamic-update="true"> <id name="id"> <generator class="hilo"/> </id> <property name="blob" column="blob_"/> <property name="clob" column="clob_"/> </class> </hibernate-mapping> --- NEW FILE: Blobber.java --- package net.sf.hibernate.test; import java.sql.Blob; import java.sql.Clob; /** * @author Administrator * * To change this generated comment edit the template variable "typecomment": * Window>Preferences>Java>Templates. * To enable and disable the creation of type comments go to * Window>Preferences>Java>Code Generation. */ public class Blobber { private int id; private Blob blob; private Clob clob; /** * Returns the blob. * @return Blob */ public Blob getBlob() { return blob; } /** * Returns the clob. * @return Clob */ public Clob getClob() { return clob; } /** * Returns the id. * @return int */ public int getId() { return id; } /** * Sets the blob. * @param blob The blob to set */ public void setBlob(Blob blob) { this.blob = blob; } /** * Sets the clob. * @param clob The clob to set */ public void setClob(Clob clob) { this.clob = clob; } /** * Sets the id. * @param id The id to set */ public void setId(int id) { this.id = id; } } Index: Baz.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Baz.hbm.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Baz.hbm.xml 9 Feb 2003 06:28:16 -0000 1.10 --- Baz.hbm.xml 15 Feb 2003 01:00:55 -0000 1.11 *************** *** 177,180 **** --- 177,186 ---- </composite-element> </map> + + <map name="stringGlarchMap" where="baz_map_index > 'a' and tha_key is not null" cascade="all"> + <key column="baz_map_id"/> + <index column="baz_map_index" type="string"/> + <one-to-many class="net.sf.hibernate.test.Glarch"/> + </map> </class> Index: Baz.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Baz.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Baz.java 9 Feb 2003 06:28:16 -0000 1.6 --- Baz.java 15 Feb 2003 01:00:56 -0000 1.7 *************** *** 31,34 **** --- 31,35 ---- private Set cached; private Map cachedMap; + private Map stringGlarchMap; Baz() {} *************** *** 296,299 **** --- 297,316 ---- public int compareTo(Object o) { return ( (Baz) o ).code.compareTo(code); + } + + /** + * Returns the stringGlarchMap. + * @return Map + */ + public Map getStringGlarchMap() { + return stringGlarchMap; + } + + /** + * Sets the stringGlarchMap. + * @param stringGlarchMap The stringGlarchMap to set + */ + public void setStringGlarchMap(Map stringGlarchMap) { + this.stringGlarchMap = stringGlarchMap; } Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** FooBarTest.java 9 Feb 2003 06:28:16 -0000 1.20 --- FooBarTest.java 15 Feb 2003 01:00:57 -0000 1.21 *************** *** 10,17 **** import java.util.HashSet; import java.util.Iterator; - import java.util.LinkedList; import java.util.List; import java.util.Locale; - import java.util.Properties; import java.util.Set; import java.util.TimeZone; --- 10,15 ---- *************** *** 46,52 **** import net.sf.hibernate.dialect.SybaseDialect; import net.sf.hibernate.proxy.HibernateProxy; - import net.sf.hibernate.type.DateType; - import net.sf.hibernate.type.EntityType; - import net.sf.hibernate.type.StringType; import net.sf.hibernate.type.Type; --- 44,47 ---- *************** *** 371,374 **** --- 366,373 ---- bars.add( new Bar() ); baz.setCascadingBars(bars); + HashMap sgm = new HashMap(); + sgm.put( "a", new Glarch() ); + sgm.put( "b", new Glarch() ); + baz.setStringGlarchMap(sgm); //System.out.println( s.print(baz) ); s.flush(); *************** *** 393,396 **** --- 392,397 ---- //System.out.println(time); + assertTrue( baz.getStringGlarchMap().size()==1 ); + //The following test is disabled databases with no subselects if ( !(dialect instanceof MySQLDialect) && !(dialect instanceof HSQLDialect) && !(dialect instanceof PointbaseDialect) ) { *************** *** 499,502 **** --- 500,505 ---- s.load( Qux.class, new Long(666) ); //nonexistent + assertTrue( s.delete("from g in class Glarch")==1 ); + s.flush(); s.connection().commit(); *************** *** 849,853 **** s.save(foo2); foo.setFoo(foo2); ! if ( dialect instanceof DB2Dialect) { s.find("from foo in class Foo where lower( foo.foo.string ) = 'foo'"); --- 852,856 ---- s.save(foo2); foo.setFoo(foo2); ! if ( dialect instanceof DB2Dialect) { s.find("from foo in class Foo where lower( foo.foo.string ) = 'foo'"); *************** *** 890,893 **** --- 893,898 ---- assertTrue( list.size()==2, "component query" ); s.find("from foo in class Foo where not exists (from bar in class Bar where bar.id = foo.id)"); + + s.iterate("select foo.string, foo.date, foo.foo.string, foo.id from foo in class Foo, baz in class Baz where foo in baz.fooArray.elements and foo.string like 'foo'"); } list = s.find("from foo in class net.sf.hibernate.test.Foo where foo.component.count is null order by foo.component.count"); *************** *** 1097,1101 **** - //TODO: reenable public void testReachability() throws Exception { //first for unkeyed collections --- 1102,1105 ---- *************** *** 1539,1719 **** s.close(); } - - - private FumCompositeID fumKey(String str) { - - return fumKey(str,false); - } - - private FumCompositeID fumKey(String str, boolean aCompositeQueryTest) { - FumCompositeID id = new FumCompositeID(); - if( dialect instanceof MckoiDialect ) { - java.util.GregorianCalendar now = new java.util.GregorianCalendar(); - java.util.GregorianCalendar cal - = new java.util.GregorianCalendar( now.get(java.util.Calendar.YEAR), - now.get(java.util.Calendar.MONTH), - now.get(java.util.Calendar.DATE) ); - id.setDate( cal.getTime() ); - } - else - id.setDate( new Date() ); - id.setString( new String(str) ); - - if (aCompositeQueryTest) - id.setShort( fumKeyShort++ ); - else - id.setShort((short)12); - - return id; - } - - public void testCompositeID() throws Exception { - Session s = sessions.openSession(); - Fum fum = new Fum( fumKey("fum") ); - fum.setFum("fee fi fo"); - s.save(fum); - assertTrue( fum==s.load( Fum.class, fumKey("fum") ), "load by composite key" ); - s.flush(); - s.connection().commit(); - s.close(); - - s = sessions.openSession(); - fum = (Fum) s.load( Fum.class, fumKey("fum"), LockMode.UPGRADE ); - assertTrue( fum!=null, "load by composite key" ); - - Fum fum2 = new Fum( fumKey("fi") ); - fum2.setFum("fee fo fi"); - fum.setFo(fum2); - s.save(fum2); - assertTrue( - s.find("from fum in class net.sf.hibernate.test.Fum where not fum.fum='FRIEND'").size()==2, - "find composite keyed objects" - ); - assertTrue( - s.find("select fum from fum in class net.sf.hibernate.test.Fum where fum.fum='fee fi fo'").get(0)==fum, - "find composite keyed object" - ); - fum.setFo(null); - s.flush(); - s.connection().commit(); - s.close(); - - s = sessions.openSession(); - Iterator iter = s.iterate("from fum in class net.sf.hibernate.test.Fum where not fum.fum='FRIEND'"); - int i = 0; - while ( iter.hasNext() ) { - fum = (Fum) iter.next(); - //iter.remove(); - s.delete(fum); - i++; - } - assertTrue( i==2, "iterate on composite key" ); - s.flush(); - s.connection().commit(); - s.close(); - } - - public void testCompositeIDOneToOne() throws Exception { - Session s = sessions.openSession(); - Fum fum = new Fum( fumKey("fum") ); - fum.setFum("fee fi fo"); - //s.save(fum); - Fumm fumm = new Fumm(); - fumm.setFum(fum); - s.save(fumm); - s.flush(); - s.connection().commit(); - s.close(); - s = sessions.openSession(); - fumm = (Fumm) s.load( Fumm.class, fumKey("fum") ); - //s.delete( fumm.getFum() ); - s.delete(fumm); - s.flush(); - s.connection().commit(); - s.close(); - } - - public void testCompositeIDQuery() throws Exception { - Session s = sessions.openSession(); - Fum fee = new Fum( fumKey("fee",true) ); - fee.setFum("fee"); - s.save(fee); - Fum fi = new Fum( fumKey("fi",true) ); - fi.setFum("fi"); - short fiShort = fi.getId().getShort(); - s.save(fi); - Fum fo = new Fum( fumKey("fo",true) ); - fo.setFum("fo"); - s.save(fo); - Fum fum = new Fum( fumKey("fum",true) ); - fum.setFum("fum"); - s.save(fum); - s.flush(); - s.connection().commit(); - s.close(); - - s = sessions.openSession(); - // Try to find the Fum object "fo" that we inserted searching by the string in the id - List vList = s.find("from fum in class net.sf.hibernate.test.Fum where fum.id.string='fo'" ); - assertTrue( vList.size() == 1, "find by composite key query (find fo object)" ); - fum = (Fum)vList.get(0); - assertTrue( fum.getId().getString().equals("fo"), "find by composite key query (check fo object)" ); - - // Try to find the Fum object "fi" that we inserted searching by the date in the id - vList = s.find("from fum in class net.sf.hibernate.test.Fum where fum.id.short = ?",new Short(fiShort),Hibernate.SHORT); - assertTrue( vList.size() == 1, "find by composite key query (find fi object)" ); - fi = (Fum)vList.get(0); - assertTrue( fi.getId().getString().equals("fi"), "find by composite key query (check fi object)" ); - - // Make sure we can return all of the objects by searching by the date id - assertTrue( - s.find("from fum in class net.sf.hibernate.test.Fum where fum.id.date <= ? and not fum.fum='FRIEND'",new Date(),Hibernate.DATE).size()==4, - "find by composite key query with arguments" - ); - s.flush(); - s.connection().commit(); - s.close(); - - s = sessions.openSession(); - assertTrue( - s.iterate("select fum.id.short, fum.id.date, fum.id.string from fum in class net.sf.hibernate.test.Fum").hasNext() - ); - assertTrue( - s.iterate("select fum.id from fum in class net.sf.hibernate.test.Fum").hasNext() - ); - Query qu = s.createQuery("select fum.fum, fum , fum.fum, fum.id.date from fum in class net.sf.hibernate.test.Fum"); - Type[] types = qu.getReturnTypes(); - assertTrue(types.length==4); - for ( int k=0; k<types.length; k++) { - assertTrue( types[k]!=null ); - } - assertTrue(types[0] instanceof StringType); - assertTrue(types[1] instanceof EntityType); - assertTrue(types[2] instanceof StringType); - assertTrue(types[3] instanceof DateType); - Iterator iter = qu.iterate(); - int j = 0; - while ( iter.hasNext() ) { - j++; - assertTrue( ( (Object[]) iter.next() )[1] instanceof Fum ); - } - assertTrue( j==8, "iterate on composite key" ); - iter = s.iterate("from fum in class net.sf.hibernate.test.Fum where not fum.fum='FRIEND'"); - int i = 0; - while ( iter.hasNext() ) { - fum = (Fum) iter.next(); - //iter.remove(); - s.delete(fum); - i++; - } - assertTrue( i==4, "iterate on composite key" ); - s.flush(); - - s.iterate("from fu in class Fum, fo in class Fum where fu.fo.id.string = fo.id.string and fo.fum is not null"); - s.connection().commit(); - s.close(); - } - public void testScrollableIterator() throws Exception { if ( dialect instanceof DB2Dialect || dialect instanceof OracleDialect || dialect instanceof SybaseDialect ) { --- 1543,1547 ---- *************** *** 1753,1793 **** } } ! ! public void testCompositeIDCollections() throws Exception { ! Session s = sessions.openSession(); ! Fum fum1 = new Fum( fumKey("fum1") ); ! Fum fum2 = new Fum( fumKey("fum2") ); ! fum1.setFum("fee fo fi"); ! fum2.setFum("fee fo fi"); ! s.save(fum1); ! s.save(fum2); ! Qux q = new Qux(); ! s.save(q); ! Set set = new HashSet(); ! List list = new ArrayList(); ! set.add(fum1); set.add(fum2); ! list.add(fum1); ! q.setFums(set); ! q.setMoreFums(list); ! fum1.setQuxArray( new Qux[] {q} ); ! s.flush(); ! s.connection().commit(); ! s.close(); ! s = sessions.openSession(); ! q = (Qux) s.load( Qux.class, q.getKey() ); ! assertTrue( q.getFums().size()==2, "collection of fums" ); ! assertTrue( q.getMoreFums().size()==1, "collection of fums" ); ! assertTrue( ( (Fum) q.getMoreFums().get(0) ).getQuxArray()[0]==q, "unkeyed composite id collection" ); ! Iterator iter = q.getFums().iterator(); ! iter.hasNext(); ! s.delete( (Fum) iter.next() ); ! iter.hasNext(); ! s.delete( (Fum) iter.next() ); ! s.delete(q); ! s.flush(); ! s.connection().commit(); ! s.close(); ! } ! public void testMultiColumnQueries() throws Exception { Session s = sessions.openSession(); --- 1581,1585 ---- } } ! public void testMultiColumnQueries() throws Exception { Session s = sessions.openSession(); *************** *** 2166,2213 **** } - public void testDeleteOwner() throws Exception { - Session s = sessions.openSession(); - Qux q = new Qux(); - s.save(q); - Fum f1 = new Fum( fumKey("f1") ); - Fum f2 = new Fum( fumKey("f2") ); - Set set = new HashSet(); - set.add(f1); - set.add(f2); - List list = new LinkedList(); - list.add(f1); - list.add(f2); - f1.setFum("f1"); - f2.setFum("f2"); - q.setFums(set); - q.setMoreFums(list); - s.save(f1); - s.save(f2); - s.flush(); - s.connection().commit(); - s.close(); - - s = sessions.openSession(); - q = (Qux) s.load( Qux.class, q.getKey(), LockMode.UPGRADE ); - s.lock( q, LockMode.UPGRADE ); - s.delete(q); - s.flush(); - s.connection().commit(); - s.close(); - - s = sessions.openSession(); - list = s.find("from fum in class net.sf.hibernate.test.Fum where not fum.fum='FRIEND'"); - assertTrue( list.size()==2, "deleted owner" ); - s.lock( list.get(0), LockMode.UPGRADE ); - s.lock( list.get(1), LockMode.UPGRADE ); - Iterator iter = list.iterator(); - while ( iter.hasNext() ) { - s.delete( iter.next() ); - } - s.flush(); - s.connection().commit(); - s.close(); - } - public void testNewSessionLifecycle() throws Exception { Session s = sessions.openSession(); --- 1958,1961 ---- *************** *** 2589,2616 **** } - public void testListIdentifiers() throws Exception { - Session s = sessions.openSession(); - Fum fum = new Fum( fumKey("fum") ); - fum.setFum("fo fee fi"); - s.save(fum); - fum = new Fum( fumKey("fi") ); - fum.setFum("fee fi fo"); - s.save(fum); - List list = s.find("select fum.id from fum in class net.sf.hibernate.test.Fum where not fum.fum='FRIEND'"); - assertTrue( list.size()==2, "list identifiers"); - Iterator iter = s.iterate("select fum.id from fum in class net.sf.hibernate.test.Fum where not fum.fum='FRIEND'"); - int i=0; - while ( iter.hasNext() ) { - assertTrue( iter.next() instanceof FumCompositeID, "iterate identifiers"); - i++; - } - assertTrue(i==2); - s.delete( s.load(Fum.class, (Serializable) list.get(0) ) ); - s.delete( s.load(Fum.class, (Serializable) list.get(1) ) ); - s.flush(); - s.connection().commit(); - s.close(); - } - public void testVeto() throws Exception { Session s = sessions.openSession(); --- 2337,2340 ---- *************** *** 2711,2760 **** } - - public void testCompositeIDs() throws Exception { - Session s = sessions.openSession(); - Fo fo = new Fo(); - Properties props = new Properties(); - props.setProperty("foo", "bar"); - props.setProperty("bar", "foo"); - fo.setSerial(props); - fo.setBuf( "abcdefghij1`23%$*^*$*\n\t".getBytes() ); - s.save( fo, fumKey("an instance of fo") ); - s.flush(); - props.setProperty("x", "y"); - s.flush(); - s.connection().commit(); - s.close(); - - s = sessions.openSession(); - fo = (Fo) s.load( Fo.class, fumKey("an instance of fo") ); - props = (Properties) fo.getSerial(); - assertTrue( props.getProperty("foo").equals("bar") ); - assertTrue( props.getProperty("x").equals("y") ); - assertTrue( fo.getBuf()[0]=='a' ); - fo.getBuf()[1]=(byte)126; - s.flush(); - s.connection().commit(); - s.close(); - s = sessions.openSession(); - fo = (Fo) s.load( Fo.class, fumKey("an instance of fo") ); - assertTrue( fo.getBuf()[1]==126 ); - assertTrue( - s.iterate("from fo in class net.sf.hibernate.test.Fo where fo.id.string like 'an instance of fo'").next()==fo - ); - s.delete(fo); - s.flush(); - try { - s.save( new Fo() ); - assertTrue(false); - } - catch (Exception e) { - //System.out.println( e.getMessage() ); - } - s.connection().commit(); - s.close(); - } - public void testUserProvidedConnection() throws Exception { ConnectionProvider dcp = new DriverManagerConnectionProvider(); --- 2435,2439 ---- *************** *** 2841,2845 **** assertTrue(err); Fo fo = new Fo(); ! id = fumKey("abc"); s.save(fo, id); s.flush(); --- 2520,2524 ---- assertTrue(err); Fo fo = new Fo(); ! id = FumTest.fumKey("abc"); //yuck!! s.save(fo, id); s.flush(); *************** *** 2960,2963 **** --- 2639,2643 ---- s.flush(); s.connection().commit(); + s.close(); s = sessions.openSession(); *************** *** 2975,2981 **** assertTrue( !(baz.getFooBag().iterator().next() instanceof HibernateProxy) ); //many-to-many outer-join="true" assertTrue( !(baz.getFooSet().iterator().next() instanceof HibernateProxy) ); //one-to-many ! s.delete("from o in class java.lang.Object"); s.flush(); s.connection().commit(); } --- 2655,2663 ---- assertTrue( !(baz.getFooBag().iterator().next() instanceof HibernateProxy) ); //many-to-many outer-join="true" assertTrue( !(baz.getFooSet().iterator().next() instanceof HibernateProxy) ); //one-to-many ! s.delete("from o in class Baz"); ! s.delete("from o in class Foo"); s.flush(); s.connection().commit(); + s.close(); } Index: MultiTableTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/MultiTableTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MultiTableTest.java 24 Jan 2003 13:07:17 -0000 1.5 --- MultiTableTest.java 15 Feb 2003 01:00:58 -0000 1.6 *************** *** 23,28 **** public void testQueries() throws Exception { Session s = sessions.openSession(); ! s.save( new TrivialClass(), new Long(1) ); s.flush(); s.connection().commit(); --- 23,36 ---- public void testQueries() throws Exception { + Session s = sessions.openSession(); ! ! if (dialect instanceof SybaseDialect) { ! s.save( new TrivialClass() ); ! } ! else{ ! s.save( new TrivialClass(), new Long(1) ); ! } ! s.flush(); s.connection().commit(); *************** *** 46,57 **** public void testConstraints() throws Exception { ! ! if ( dialect instanceof SybaseDialect ) return; ! Session s = sessions.openSession(); Transaction t = s.beginTransaction(); SubMulti sm = new SubMulti(); sm.setAmount(66.5f); ! s.save( sm, new Long(2) ); t.commit(); s.close(); --- 54,68 ---- public void testConstraints() throws Exception { ! Session s = sessions.openSession(); Transaction t = s.beginTransaction(); SubMulti sm = new SubMulti(); sm.setAmount(66.5f); ! if ( dialect instanceof SybaseDialect ) { ! s.save(sm); ! } ! else { ! s.save( sm, new Long(2) ); ! } t.commit(); s.close(); Index: SQLFunctionsTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/SQLFunctionsTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SQLFunctionsTest.java 5 Jan 2003 02:11:23 -0000 1.3 --- SQLFunctionsTest.java 15 Feb 2003 01:00:58 -0000 1.4 *************** *** 5,9 **** import java.util.Iterator; ! import net.sf.hibernate.*; import net.sf.hibernate.dialect.DB2Dialect; import net.sf.hibernate.dialect.InterbaseDialect; --- 5,13 ---- import java.util.Iterator; ! import junit.framework.Test; ! import junit.framework.TestSuite; ! import net.sf.hibernate.Query; ! import net.sf.hibernate.Session; ! import net.sf.hibernate.Transaction; import net.sf.hibernate.dialect.DB2Dialect; import net.sf.hibernate.dialect.InterbaseDialect; *************** *** 11,17 **** import net.sf.hibernate.dialect.SybaseDialect; - import junit.framework.Test; - import junit.framework.TestSuite; - public class SQLFunctionsTest extends TestCase { --- 15,18 ---- *************** *** 159,166 **** } public static Test suite() throws Exception { TestCase.exportSchema( ! new String[] { "Simple.hbm.xml" } ); return new TestSuite(SQLFunctionsTest.class); --- 160,198 ---- } + /*public void testBlobClob() throws Exception { + Session s = sessions.openSession(); + Blobber b = new Blobber(); + b.setBlob( Hibernate.createBlob( "foo/bar/baz".getBytes() ) ); + b.setClob( Hibernate.createClob("foo/bar/baz") ); + s.save(b); + //s.refresh(b); + //assertTrue( b.getClob() instanceof ClobImpl ); + s.flush(); + s.refresh(b); + //b.getBlob().setBytes( 2, "abc".getBytes() ); + b.getClob().getSubString(2, 3); + b.getClob().setString(2, "abc"); + s.flush(); + s.connection().commit(); + s.close(); + + s = sessions.openSession(); + b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) ); + Blobber b2 = new Blobber(); + s.save(b2); + b2.setBlob( b.getBlob() ); + b.setBlob(null); + assertTrue( b.getClob().getSubString(1, 3).equals("fab") ); + b.getClob().getSubString(1, 6); + b.getClob().setString(1, "qwerty"); + s.flush(); + s.connection().commit(); + s.close(); + }*/ + public static Test suite() throws Exception { TestCase.exportSchema( ! new String[] { "Simple.hbm.xml", "Blobber.hbm.xml" } ); return new TestSuite(SQLFunctionsTest.class); |