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-23 01:32:28
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/odmg In directory sc8-pr-cvs1:/tmp/cvs-serv11798/sf/hibernate/odmg Modified Files: Name.hbm.xml Log Message: refactored hql package (incomplete) Index: Name.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/odmg/Name.hbm.xml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Name.hbm.xml 1 Jan 2003 13:56:29 -0000 1.1.1.1 --- Name.hbm.xml 23 Feb 2003 01:32:20 -0000 1.2 *************** *** 1,3 **** ! <?xml version="1.0"?> <!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping.dtd" > <hibernate-mapping> <!-- A default mapping for the ODMG Name class. Applications may specify their own mappings instead. --> <class name="net.sf.hibernate.odmg.Name"> <id name="name" type="string"> <generator class="assigned"/> </id> <property name="persistentClass" type="class" not-null="true"/> <property name="id" type="serializable" not-null="true"/> </class> <query name="byName">from n in class net.sf.hibernate.odmg.Name where n.name = ?</query> --- 1,3 ---- ! <?xml version="1.0"?> <!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" > <hibernate-mapping> <!-- A default mapping for the ODMG Name class. Applications may specify their own mappings instead. --> <class name="net.sf.hibernate.odmg.Name"> <id name="name" type="string"> <generator class="assigned"/> </id> <property name="persistentClass" type="class" not-null="true"/> <property name="id" type="serializable" not-null="true"/> </class> <query name="byName">from n in class net.sf.hibernate.odmg.Name where n.name = ?</query> |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv11798/sf/hibernate/test Modified Files: FooBarTest.java MasterDetailTest.java MultiTableTest.java ParentChildTest.java SQLFunctionsTest.java Log Message: refactored hql package (incomplete) Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** FooBarTest.java 22 Feb 2003 06:42:07 -0000 1.24 --- FooBarTest.java 23 Feb 2003 01:32:21 -0000 1.25 *************** *** 182,185 **** --- 182,188 ---- ).size()==1 ); s.find("from s in class Stuff where s.foo.string is not null"); + assertTrue( + s.find("from s in class Stuff where s.foo > 'a' order by s.foo").size()==1 + ); t.commit(); s.close(); *************** *** 856,859 **** --- 859,869 ---- s.save(foo2); foo.setFoo(foo2); + + s.find("select foo.foo.foo.string from foo in class Foo where foo.foo = 'bar'"); + s.find("select foo.foo.foo.foo.string from foo in class Foo where foo.foo.foo = 'bar'"); + s.find("select foo.foo.foo.string from foo in class Foo where foo.foo.foo.foo.string = 'bar'"); + s.find("select foo.string from foo in class Foo where foo.foo.foo.foo = foo.foo.foo"); + s.find("select foo.string from foo in class Foo where foo.foo.foo = 'bar' and foo.foo.foo.foo = 'baz'"); + s.find("select foo.string from foo in class Foo where foo.foo.foo.foo.string = 'a' and foo.foo.string = 'b'"); if ( dialect instanceof DB2Dialect) { *************** *** 2697,2700 **** --- 2707,2738 ---- hs.start(); hs.stop(); + } + + public void testPSCache() throws Exception { + Session s = sessions.openSession(); + for ( int i=0; i<10; i++ ) s.save( new Foo() ); + Query q = s.createQuery("from f in class Foo"); + q.setMaxResults(2); + q.setFirstResult(5); + assertTrue( q.list().size()==2 ); + q = s.createQuery("from f in class Foo"); + assertTrue( q.list().size()==10 ); + assertTrue( q.list().size()==10 ); + q.setMaxResults(3); + q.setFirstResult(3); + assertTrue( q.list().size()==3 ); + q = s.createQuery("from f in class Foo"); + assertTrue( q.list().size()==10 ); + s.connection().commit(); + s.close(); + s = sessions.openSession(); + q = s.createQuery("from f in class Foo"); + assertTrue( q.list().size()==10 ); + q.setMaxResults(5); + assertTrue( q.list().size()==5 ); + s.delete("from f in class Foo"); + s.connection().commit(); + s.close(); + } Index: MasterDetailTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/MasterDetailTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MasterDetailTest.java 5 Jan 2003 02:11:23 -0000 1.3 --- MasterDetailTest.java 23 Feb 2003 01:32:21 -0000 1.4 *************** *** 2,11 **** package net.sf.hibernate.test; - import net.sf.hibernate.*; - import net.sf.hibernate.dialect.HSQLDialect; - import net.sf.hibernate.dialect.MySQLDialect; - import net.sf.hibernate.dialect.SAPDBDialect; - import net.sf.hibernate.dialect.SybaseDialect; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; --- 2,5 ---- *************** *** 19,22 **** --- 13,24 ---- import junit.framework.Test; import junit.framework.TestSuite; + import net.sf.hibernate.ObjectNotFoundException; + import net.sf.hibernate.Query; + import net.sf.hibernate.Session; + import net.sf.hibernate.Transaction; + import net.sf.hibernate.dialect.HSQLDialect; + import net.sf.hibernate.dialect.MySQLDialect; + import net.sf.hibernate.dialect.SAPDBDialect; + import net.sf.hibernate.dialect.SybaseDialect; public class MasterDetailTest extends TestCase { Index: MultiTableTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/MultiTableTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MultiTableTest.java 15 Feb 2003 01:00:58 -0000 1.6 --- MultiTableTest.java 23 Feb 2003 01:32:21 -0000 1.7 *************** *** 45,48 **** --- 45,49 ---- s.find("from s in class Simple where s.count=1"); s.find("select s.count from s in class Simple, ls in class LessSimple where ls.another=s"); + s.find("select ls.bag.elements, ls.set.elements from ls in class LessSimple"); s.iterate("from s in class LessSimple"); s.iterate("from s in class Simple"); *************** *** 171,174 **** --- 172,176 ---- s.find("from ls in class LessSimple, s in ls.bag.elements where s.id is not null"); + s.find("from ls in class LessSimple, s in ls.set.elements where s.id is not null"); s.find("from sm in class SubMulti where exists sm.children.elements"); Index: ParentChildTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/ParentChildTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ParentChildTest.java 19 Feb 2003 02:02:16 -0000 1.6 --- ParentChildTest.java 23 Feb 2003 01:32:21 -0000 1.7 *************** *** 8,16 **** import java.util.List; - import net.sf.hibernate.*; - import net.sf.hibernate.dialect.MySQLDialect; - import junit.framework.Test; import junit.framework.TestSuite; public class ParentChildTest extends TestCase { --- 8,18 ---- import java.util.List; import junit.framework.Test; import junit.framework.TestSuite; + import net.sf.hibernate.Hibernate; + import net.sf.hibernate.LockMode; + import net.sf.hibernate.Session; + import net.sf.hibernate.Transaction; + import net.sf.hibernate.dialect.MySQLDialect; public class ParentChildTest extends TestCase { Index: SQLFunctionsTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/SQLFunctionsTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SQLFunctionsTest.java 15 Feb 2003 01:00:58 -0000 1.4 --- SQLFunctionsTest.java 23 Feb 2003 01:32:21 -0000 1.5 *************** *** 7,10 **** --- 7,11 ---- import junit.framework.Test; import junit.framework.TestSuite; + import net.sf.hibernate.Hibernate; import net.sf.hibernate.Query; import net.sf.hibernate.Session; *************** *** 160,164 **** } ! /*public void testBlobClob() throws Exception { Session s = sessions.openSession(); Blobber b = new Blobber(); --- 161,165 ---- } ! public void testBlobClob() throws Exception { Session s = sessions.openSession(); Blobber b = new Blobber(); *************** *** 183,187 **** 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"); --- 184,188 ---- 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"); *************** *** 189,193 **** s.connection().commit(); s.close(); ! }*/ --- 190,238 ---- s.connection().commit(); s.close(); ! ! s = sessions.openSession(); ! b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) ); ! b.setClob( Hibernate.createClob("xcvfxvc xcvbx cvbx cvbx cvbxcvbxcvbxcvb") ); ! s.flush(); ! s.connection().commit(); ! s.close(); ! ! s = sessions.openSession(); ! b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) ); ! assertTrue( b.getClob().getSubString(1, 7).equals("xcvfxvc") ); ! b.getClob().setString(5, "1234567890"); ! s.flush(); ! s.connection().commit(); ! s.close(); ! ! ! /*InputStream is = getClass().getClassLoader().getResourceAsStream("jdbc20.pdf"); ! s = sessions.openSession(); ! b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) ); ! System.out.println( is.available() ); ! int size = is.available(); ! b.setBlob( Hibernate.createBlob( is, is.available() ) ); ! s.flush(); ! s.connection().commit(); ! ResultSet rs = s.connection().createStatement().executeQuery("select datalength(blob_) from blobber where id=" + b.getId() ); ! rs.next(); ! assertTrue( size==rs.getInt(1) ); ! rs.close(); ! s.close(); ! ! s = sessions.openSession(); ! b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) ); ! File f = new File("C:/foo.pdf"); ! f.createNewFile(); ! FileOutputStream fos = new FileOutputStream(f); ! Blob blob = b.getBlob(); ! byte[] bytes = blob.getBytes( 1, (int) blob.length() ); ! System.out.println( bytes.length ); ! fos.write(bytes); ! fos.flush(); ! fos.close(); ! s.close();*/ ! ! } |
From: <one...@us...> - 2003-02-23 01:32:28
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister In directory sc8-pr-cvs1:/tmp/cvs-serv11798/sf/hibernate/persister Modified Files: EntityPersister.java NormalizedEntityPersister.java Log Message: refactored hql package (incomplete) Index: EntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister/EntityPersister.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** EntityPersister.java 15 Feb 2003 08:00:50 -0000 1.17 --- EntityPersister.java 23 Feb 2003 01:32:20 -0000 1.18 *************** *** 834,838 **** } else { ! return null; } --- 834,838 ---- } else { ! return ""; } Index: NormalizedEntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister/NormalizedEntityPersister.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** NormalizedEntityPersister.java 9 Feb 2003 06:28:15 -0000 1.9 --- NormalizedEntityPersister.java 23 Feb 2003 01:32:21 -0000 1.10 *************** *** 940,944 **** StringHelper.prefix( getIdentifierColumnNames(), name + StringHelper.DOT ), subclassTableKeyColumns[i], ! innerJoin && isClassOrSuperclassTable[i] ); } --- 940,944 ---- StringHelper.prefix( getIdentifierColumnNames(), name + StringHelper.DOT ), subclassTableKeyColumns[i], ! innerJoin && isClassOrSuperclassTable[i] ? OuterJoinFragment.INNER_JOIN : OuterJoinFragment.LEFT_OUTER_JOIN ); } |
From: <one...@us...> - 2003-02-22 06:42:17
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv17247/sf/hibernate/test Modified Files: FooBarTest.java Log Message: fixed a problem with HibernateService added convenience createBlob() improved some logging added SessionFactory.close() Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** FooBarTest.java 19 Feb 2003 02:02:13 -0000 1.23 --- FooBarTest.java 22 Feb 2003 06:42:07 -0000 1.24 *************** *** 43,46 **** --- 43,47 ---- import net.sf.hibernate.dialect.SAPDBDialect; import net.sf.hibernate.dialect.SybaseDialect; + import net.sf.hibernate.jmx.HibernateService; import net.sf.hibernate.proxy.HibernateProxy; import net.sf.hibernate.type.Type; *************** *** 2683,2686 **** --- 2684,2700 ---- s.connection().commit(); s.close(); + } + + public void testService() throws Exception { + HibernateService hs = new HibernateService(); + hs.setJndiName("SessionFactory"); + hs.setMapResources("net/sf/hibernate/test/Simple.hbm.xml, net/sf/hibernate/test/Blobber.hbm.xml"); + hs.setShowSql(true); + hs.setUseOuterJoin(false); + hs.start(); + hs.stop(); + hs.setProperty("foo", "bar"); + hs.start(); + hs.stop(); } |
From: <one...@us...> - 2003-02-22 06:42:14
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2ddl In directory sc8-pr-cvs1:/tmp/cvs-serv17247/sf/hibernate/tool/hbm2ddl Modified Files: SchemaExport.java Log Message: fixed a problem with HibernateService added convenience createBlob() improved some logging added SessionFactory.close() Index: SchemaExport.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2ddl/SchemaExport.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SchemaExport.java 31 Jan 2003 08:49:50 -0000 1.7 --- SchemaExport.java 22 Feb 2003 06:42:07 -0000 1.8 *************** *** 83,88 **** Connection connection = null; FileWriter fileOutput = null; ! ConnectionProvider cp = null; ! Statement stmt = null; Properties givenProps = (connectionProperties==null) ? Environment.getProperties() : connectionProperties; --- 83,88 ---- Connection connection = null; FileWriter fileOutput = null; ! ConnectionProvider connectionProvider = null; ! Statement statement = null; Properties givenProps = (connectionProperties==null) ? Environment.getProperties() : connectionProperties; *************** *** 98,106 **** if (export) { ! cp = ConnectionProviderFactory.newConnectionProvider(props); ! connection = cp.getConnection(); connection.commit(); connection.setAutoCommit(true); ! stmt = connection.createStatement(); } --- 98,106 ---- if (export) { ! connectionProvider = ConnectionProviderFactory.newConnectionProvider(props); ! connection = connectionProvider.getConnection(); connection.commit(); connection.setAutoCommit(true); ! statement = connection.createStatement(); } *************** *** 113,120 **** if (export) { if (jdbc2) { ! stmt.addBatch( dropSQL[i] ); } else { ! stmt.executeUpdate( dropSQL[i] ); } } --- 113,120 ---- if (export) { if (jdbc2) { ! statement.addBatch( dropSQL[i] ); } else { ! statement.executeUpdate( dropSQL[i] ); } } *************** *** 136,143 **** if (export) { if (jdbc2) { ! stmt.addBatch( createSQL[j] ); } else { ! stmt.executeUpdate( createSQL[j] ); } } --- 136,143 ---- if (export) { if (jdbc2) { ! statement.addBatch( createSQL[j] ); } else { ! statement.executeUpdate( createSQL[j] ); } } *************** *** 150,154 **** } ! if (jdbc2) stmt.executeBatch(); } --- 150,154 ---- } ! if (jdbc2) statement.executeBatch(); } *************** *** 161,169 **** finally { try { ! if (stmt!=null) stmt.close(); if (connection!=null) { JDBCExceptionReporter.logWarnings( connection.getWarnings() ); connection.clearWarnings(); ! cp.closeConnection(connection); } } --- 161,170 ---- finally { try { ! if (statement!=null) statement.close(); if (connection!=null) { JDBCExceptionReporter.logWarnings( connection.getWarnings() ); connection.clearWarnings(); ! connectionProvider.closeConnection(connection); ! connectionProvider.close(); } } |
From: <one...@us...> - 2003-02-22 06:42:14
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/ps In directory sc8-pr-cvs1:/tmp/cvs-serv17247/sf/hibernate/ps Modified Files: PreparedStatementCache.java Log Message: fixed a problem with HibernateService added convenience createBlob() improved some logging added SessionFactory.close() Index: PreparedStatementCache.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/ps/PreparedStatementCache.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PreparedStatementCache.java 16 Feb 2003 01:55:07 -0000 1.6 --- PreparedStatementCache.java 22 Feb 2003 06:42:07 -0000 1.7 *************** *** 50,56 **** } ! private final Map cache = new HashMap(); ! private final Map entryMap = IdentityMap.instantiate(); ! private final LinkedList entries = new LinkedList(); private short reapCounter = 0; --- 50,56 ---- } ! private final Map cache = new HashMap(); //Entry -> PreparedStatement ! private final Map entryMap = IdentityMap.instantiate(); //PreparedStatement->Entry ! private final LinkedList entries = new LinkedList(); //Entry private short reapCounter = 0; *************** *** 194,199 **** protected void finalize() { ! log.info("Finalizing dereferenced prepared statement cache"); Iterator iter = cache.values().iterator(); --- 194,203 ---- protected void finalize() { + close(); + } ! public void close() { ! ! log.info("cleaning up prepared statement cache"); Iterator iter = cache.values().iterator(); *************** *** 206,209 **** --- 210,216 ---- } } + cache.clear(); + entryMap.clear(); + entries.clear(); } |
From: <one...@us...> - 2003-02-22 06:42:14
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/jmx In directory sc8-pr-cvs1:/tmp/cvs-serv17247/sf/hibernate/jmx Modified Files: HibernateService.java SessionFactoryStub.java Log Message: fixed a problem with HibernateService added convenience createBlob() improved some logging added SessionFactory.close() Index: HibernateService.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/jmx/HibernateService.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** HibernateService.java 26 Jan 2003 01:33:35 -0000 1.5 --- HibernateService.java 22 Feb 2003 06:42:08 -0000 1.6 *************** *** 2,7 **** package net.sf.hibernate.jmx; import javax.naming.InitialContext; - import javax.naming.NamingException; import org.apache.commons.logging.Log; --- 2,8 ---- package net.sf.hibernate.jmx; + import java.util.Properties; + import javax.naming.InitialContext; import org.apache.commons.logging.Log; *************** *** 9,16 **** import net.sf.hibernate.HibernateException; import net.sf.hibernate.cfg.Configuration; import net.sf.hibernate.cfg.Environment; import net.sf.hibernate.util.PropertiesHelper; - import net.sf.hibernate.util.StringHelper; --- 10,18 ---- import net.sf.hibernate.HibernateException; + import net.sf.hibernate.SessionFactory; import net.sf.hibernate.cfg.Configuration; import net.sf.hibernate.cfg.Environment; + import net.sf.hibernate.util.NamingHelper; import net.sf.hibernate.util.PropertiesHelper; *************** *** 23,27 **** * @see net.sf.hibernate.SessionFactory */ ! public class HibernateService extends Configuration implements HibernateServiceMBean { private static final Log log = LogFactory.getLog(HibernateServiceMBean.class); --- 25,29 ---- * @see net.sf.hibernate.SessionFactory */ ! public class HibernateService implements HibernateServiceMBean { private static final Log log = LogFactory.getLog(HibernateServiceMBean.class); *************** *** 29,32 **** --- 31,35 ---- private String mapResources; private String boundName; + private Properties properties = new Properties(); /** *************** *** 119,123 **** private String[] parseResourceList(String resourceList) { ! return PropertiesHelper.toStringArray(resourceList, StringHelper.COMMA_SPACE); } --- 122,126 ---- private String[] parseResourceList(String resourceList) { ! return PropertiesHelper.toStringArray(resourceList, " ,\n\t\r\f"); } *************** *** 125,134 **** boundName = getJndiName(); try { ! bindSessionFactory(); } catch (HibernateException he) { ! log.info("Could not build SessionFactory using the MBean classpath - will try again using client classpath"); ! String[] mappingFiles = parseResourceList( getMapResources() ); ! new SessionFactoryStub(mappingFiles, this); } } --- 128,137 ---- boundName = getJndiName(); try { ! buildSessionFactory(); } catch (HibernateException he) { ! log.info( "Could not build SessionFactory using the MBean classpath - will try again using client classpath: " + he.getMessage() ); ! log.debug("Error was", he); ! new SessionFactoryStub(this); } } *************** *** 137,157 **** log.info("stopping service"); try { ! new InitialContext().unbind(boundName); } ! catch (NamingException e) { ! log.warn("exception while unbinding factory from JNDI", e); } } ! private void bindSessionFactory() throws HibernateException { log.info( "starting service at JNDI name: " + boundName ); ! log.info( "properties: " + getProperties() ); String[] mappingFiles = parseResourceList( getMapResources() ); for ( int i=0; i<mappingFiles.length; i++ ) { ! log.info( "compiling mapping: " + mappingFiles[i] ); ! addResource( mappingFiles[i], Thread.currentThread().getContextClassLoader() ); } ! buildSessionFactory(); } --- 140,163 ---- log.info("stopping service"); try { ! InitialContext context = NamingHelper.getInitialContext( getProperties() ); ! ( (SessionFactory) context.lookup(boundName) ).close(); ! context.unbind(boundName); } ! catch (Exception e) { ! log.warn("exception while stopping service", e); } } ! SessionFactory buildSessionFactory() throws HibernateException { log.info( "starting service at JNDI name: " + boundName ); ! log.info( "service properties: " + properties ); ! ! Configuration cfg = new Configuration().addProperties( getProperties() ); String[] mappingFiles = parseResourceList( getMapResources() ); for ( int i=0; i<mappingFiles.length; i++ ) { ! cfg.addResource( mappingFiles[i], Thread.currentThread().getContextClassLoader() ); } ! return cfg.buildSessionFactory(); } *************** *** 183,186 **** --- 189,204 ---- } + public String getProperty(String property) { + return properties.getProperty(property); + } + + public void setProperty(String property, String value) { + properties.setProperty(property, value); + } + + protected Properties getProperties() { + return properties; + } + } Index: SessionFactoryStub.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/jmx/SessionFactoryStub.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SessionFactoryStub.java 9 Feb 2003 06:28:15 -0000 1.6 --- SessionFactoryStub.java 22 Feb 2003 06:42:08 -0000 1.7 *************** *** 21,26 **** import net.sf.hibernate.Session; import net.sf.hibernate.SessionFactory; - import net.sf.hibernate.cfg.Configuration; - import net.sf.hibernate.cfg.Environment; import net.sf.hibernate.id.IdentifierGenerator; import net.sf.hibernate.id.UUIDHexGenerator; --- 21,24 ---- *************** *** 42,54 **** private transient SessionFactory impl; ! private transient String[] resources; ! private transient Configuration mapper; private String uuid; private String name; ! SessionFactoryStub(String[] resources, Configuration mapper) { ! this.resources = resources; ! this.mapper = mapper; ! this.name = mapper.getProperty(Environment.SESSION_FACTORY_NAME); try { uuid = (String) uuidgen.generate(null, null); --- 40,50 ---- private transient SessionFactory impl; ! private transient HibernateService service; private String uuid; private String name; ! SessionFactoryStub(HibernateService service) { ! this.service = service; ! this.name = service.getJndiName(); try { uuid = (String) uuidgen.generate(null, null); *************** *** 58,62 **** } ! SessionFactoryObjectFactory.addInstance( uuid, name, this, mapper.getProperties() ); } --- 54,58 ---- } ! SessionFactoryObjectFactory.addInstance( uuid, name, this, service.getProperties() ); } *************** *** 74,82 **** if (impl==null) { try { ! for ( int i=0; i<resources.length; i++ ) { ! mapper.addResource( resources[i], Thread.currentThread().getContextClassLoader() ); ! } ! impl = mapper.buildSessionFactory(); ! // now impl will be bound to the name this was bound to } catch (Exception e) { --- 70,74 ---- if (impl==null) { try { ! impl = service.buildSessionFactory(); } catch (Exception e) { *************** *** 145,148 **** --- 137,143 ---- } + public void close() throws HibernateException { + } + } |
From: <one...@us...> - 2003-02-22 06:42:14
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection In directory sc8-pr-cvs1:/tmp/cvs-serv17247/sf/hibernate/connection Modified Files: C3P0ConnectionProvider.java ConnectionProvider.java DBCPConnectionProvider.java DatasourceConnectionProvider.java DriverManagerConnectionProvider.java UserSuppliedConnectionProvider.java Log Message: fixed a problem with HibernateService added convenience createBlob() improved some logging added SessionFactory.close() Index: C3P0ConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection/C3P0ConnectionProvider.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** C3P0ConnectionProvider.java 26 Jan 2003 01:33:35 -0000 1.5 --- C3P0ConnectionProvider.java 22 Feb 2003 06:42:07 -0000 1.6 *************** *** 118,121 **** --- 118,125 ---- } + public void close() { + // no API for closing a c3p0 pool + } + } Index: ConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection/ConnectionProvider.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ConnectionProvider.java 5 Jan 2003 02:11:20 -0000 1.3 --- ConnectionProvider.java 22 Feb 2003 06:42:07 -0000 1.4 *************** *** 42,45 **** --- 42,51 ---- */ public boolean isStatementCache(); + + /** + * Release all resources held by this provider. + * @throws SQLException + */ + public void close() throws HibernateException; } Index: DBCPConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection/DBCPConnectionProvider.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DBCPConnectionProvider.java 26 Jan 2003 01:33:35 -0000 1.5 --- DBCPConnectionProvider.java 22 Feb 2003 06:42:07 -0000 1.6 *************** *** 30,35 **** public class DBCPConnectionProvider implements ConnectionProvider { - private DataSource ds; private Integer isolation; private static final Log log = LogFactory.getLog(DBCPConnectionProvider.class); --- 30,37 ---- public class DBCPConnectionProvider implements ConnectionProvider { private Integer isolation; + private DataSource ds; + private KeyedObjectPoolFactory statementPool; + private ObjectPool connectionPool; private static final Log log = LogFactory.getLog(DBCPConnectionProvider.class); *************** *** 88,92 **** // We'll need a ObjectPool that serves as the // actual pool of connections. ! ObjectPool connectionPool = new GenericObjectPool( null, Integer.parseInt( props.getProperty(Environment.DBCP_MAXACTIVE) ), --- 90,94 ---- // We'll need a ObjectPool that serves as the // actual pool of connections. ! connectionPool = new GenericObjectPool( null, Integer.parseInt( props.getProperty(Environment.DBCP_MAXACTIVE) ), *************** *** 98,102 **** // We'll need a KeyedObjectPoolFactory that serves as the // actual pool of prepared statements. ! KeyedObjectPoolFactory statementPool = new GenericKeyedObjectPoolFactory( null, Integer.parseInt( props.getProperty(Environment.DBCP_PS_MAXACTIVE) ), --- 100,104 ---- // We'll need a KeyedObjectPoolFactory that serves as the // actual pool of prepared statements. ! statementPool = new GenericKeyedObjectPoolFactory( null, Integer.parseInt( props.getProperty(Environment.DBCP_PS_MAXACTIVE) ), *************** *** 139,142 **** --- 141,156 ---- } + /** + * @see net.sf.hibernate.connection.ConnectionProvider#close() + */ + public void close() throws HibernateException { + try { + connectionPool.close(); + } + catch (Exception e) { + throw new HibernateException("could not close DBCP pool", e); + } + } + } Index: DatasourceConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection/DatasourceConnectionProvider.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DatasourceConnectionProvider.java 26 Jan 2003 01:33:35 -0000 1.4 --- DatasourceConnectionProvider.java 22 Feb 2003 06:42:07 -0000 1.5 *************** *** 12,15 **** --- 12,16 ---- import java.sql.*; + import javax.sql.DataSource; *************** *** 78,81 **** --- 79,85 ---- } + public void close() { + } + } Index: DriverManagerConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection/DriverManagerConnectionProvider.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DriverManagerConnectionProvider.java 26 Jan 2003 01:33:35 -0000 1.6 --- DriverManagerConnectionProvider.java 22 Feb 2003 06:42:08 -0000 1.7 *************** *** 136,141 **** protected void finalize() { ! log.info("cleaning up dereferenced connection pool: " + url); Iterator iter = pool.iterator(); --- 136,145 ---- protected void finalize() { + close(); + } + + public void close() { ! log.info("cleaning up connection pool: " + url); Iterator iter = pool.iterator(); *************** *** 148,153 **** } } } ! } --- 152,159 ---- } } + pool.clear(); + } ! } Index: UserSuppliedConnectionProvider.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/connection/UserSuppliedConnectionProvider.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** UserSuppliedConnectionProvider.java 5 Jan 2003 02:11:20 -0000 1.3 --- UserSuppliedConnectionProvider.java 22 Feb 2003 06:42:08 -0000 1.4 *************** *** 46,49 **** --- 46,52 ---- } + public void close() { + } + } |
From: <one...@us...> - 2003-02-22 06:42:14
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv17247/sf/hibernate/impl Modified Files: SessionFactoryImpl.java Log Message: fixed a problem with HibernateService added convenience createBlob() improved some logging added SessionFactory.close() Index: SessionFactoryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionFactoryImpl.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** SessionFactoryImpl.java 19 Feb 2003 02:02:09 -0000 1.12 --- SessionFactoryImpl.java 22 Feb 2003 06:42:07 -0000 1.13 *************** *** 102,106 **** private transient final String[] queryImports; private transient final Dialect dialect; ! private transient final PreparedStatementCache stCache; private transient final TransactionFactory transactionFactory; private transient final int jdbcBatchSize; --- 102,106 ---- private transient final String[] queryImports; private transient final Dialect dialect; ! private transient final PreparedStatementCache statementCache; private transient final TransactionFactory transactionFactory; private transient final int jdbcBatchSize; *************** *** 145,149 **** int cacheSize = PropertiesHelper.getInt(Environment.STATEMENT_CACHE_SIZE, properties, 0); ! stCache = ( cacheSize<1 || connections.isStatementCache() ) ? null : new PreparedStatementCache(cacheSize); statementFetchSize = PropertiesHelper.getInteger(Environment.STATEMENT_FETCH_SIZE, properties); --- 145,149 ---- int cacheSize = PropertiesHelper.getInt(Environment.STATEMENT_CACHE_SIZE, properties, 0); ! statementCache = ( cacheSize<1 || connections.isStatementCache() ) ? null : new PreparedStatementCache(cacheSize); statementFetchSize = PropertiesHelper.getInteger(Environment.STATEMENT_FETCH_SIZE, properties); *************** *** 521,526 **** if (showSql) System.out.println("Hibernate: " + sql); ! if (stCache!=null) { ! return stCache.getPreparedStatement(sql, conn, scrollable); } else { --- 521,526 ---- if (showSql) System.out.println("Hibernate: " + sql); ! if (statementCache!=null) { ! return statementCache.getPreparedStatement(sql, conn, scrollable); } else { *************** *** 539,546 **** public void closePreparedStatement(PreparedStatement ps) throws SQLException { ! if (stCache!=null) { ps.setMaxRows(0); ps.setFetchSize(0); ! stCache.closePreparedStatement(ps); } else { --- 539,546 ---- public void closePreparedStatement(PreparedStatement ps) throws SQLException { ! if (statementCache!=null) { ps.setMaxRows(0); ps.setFetchSize(0); ! statementCache.closePreparedStatement(ps); } else { *************** *** 687,690 **** --- 687,695 ---- } + public void close() throws HibernateException { + if (statementCache!=null) statementCache.close(); + connections.close(); + } + } |
From: <one...@us...> - 2003-02-22 06:42:14
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping In directory sc8-pr-cvs1:/tmp/cvs-serv17247/sf/hibernate/mapping Modified Files: Column.java Log Message: fixed a problem with HibernateService added convenience createBlob() improved some logging added SessionFactory.close() Index: Column.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/mapping/Column.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Column.java 2 Feb 2003 06:41:05 -0000 1.7 --- Column.java 22 Feb 2003 06:42:07 -0000 1.8 *************** *** 72,78 **** } ! public int getSQLType(Mapping pi) throws MappingException { try { ! return getType().sqlTypes(pi)[ getTypeIndex() ]; } catch (Exception e) { --- 72,78 ---- } ! private int getAutoSqlType(Mapping mapping) throws MappingException { try { ! return getType().sqlTypes(mapping)[ getTypeIndex() ]; } catch (Exception e) { *************** *** 90,94 **** public String getSqlType(Dialect dialect, Mapping pi) throws HibernateException { ! return (sqlType==null) ? dialect.getTypeName( getSQLType(pi), getLength() ) : sqlType; } --- 90,94 ---- public String getSqlType(Dialect dialect, Mapping pi) throws HibernateException { ! return (sqlType==null) ? dialect.getTypeName( getAutoSqlType(pi), getLength() ) : sqlType; } |
From: <one...@us...> - 2003-02-22 06:42:12
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg In directory sc8-pr-cvs1:/tmp/cvs-serv17247/sf/hibernate/cfg Modified Files: Configuration.java Environment.java Log Message: fixed a problem with HibernateService added convenience createBlob() improved some logging added SessionFactory.close() Index: Configuration.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Configuration.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Configuration.java 9 Feb 2003 06:28:14 -0000 1.15 --- Configuration.java 22 Feb 2003 06:42:06 -0000 1.16 *************** *** 78,81 **** --- 78,95 ---- private static Log log = LogFactory.getLog(Configuration.class); + protected void reset() { + classes = new HashMap(); + collections = new HashMap(); + tables = new HashMap(); + namedQueries = new HashMap(); + secondPasses = new ArrayList(); + interceptor = EMPTY_INTERCEPTOR; + properties = Environment.getProperties(); + } + + public Configuration() { + reset(); + } + /** * Returns the identifier type of a mapped class *************** *** 585,588 **** --- 599,610 ---- public Configuration setProperties(Properties properties) { this.properties = properties; + return this; + } + + /** + * Set the given properties + */ + public Configuration addProperties(Properties properties) { + this.properties.putAll(properties); return this; } Index: Environment.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Environment.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Environment.java 3 Feb 2003 12:11:36 -0000 1.3 --- Environment.java 22 Feb 2003 06:42:06 -0000 1.4 *************** *** 300,304 **** try { properties.load(stream); ! log.info("loaded properties from resource hibernate.properties"); } catch (Exception e) { --- 300,304 ---- try { properties.load(stream); ! log.info("loaded properties from resource hibernate.properties: " + properties); } catch (Exception e) { |
From: <one...@us...> - 2003-02-22 06:42:12
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv17247/sf/hibernate Modified Files: Hibernate.java SessionFactory.java Log Message: fixed a problem with HibernateService added convenience createBlob() improved some logging added SessionFactory.close() Index: Hibernate.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/Hibernate.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Hibernate.java 26 Jan 2003 01:33:34 -0000 1.5 --- Hibernate.java 22 Feb 2003 06:42:06 -0000 1.6 *************** *** 2,5 **** --- 2,6 ---- package net.sf.hibernate; + import java.io.IOException; import java.io.InputStream; import java.io.Reader; *************** *** 232,235 **** --- 233,245 ---- public static Blob createBlob(InputStream stream, int length) { return new BlobImpl(stream, length); + } + + /** + * Create a new <tt>Blob</tt>. The returned object will be + * initially immutable. + * @param stream a binary stream + */ + public static Blob createBlob(InputStream stream) throws IOException { + return new BlobImpl( stream, stream.available() ); } Index: SessionFactory.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/SessionFactory.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SessionFactory.java 26 Jan 2003 01:33:34 -0000 1.6 --- SessionFactory.java 22 Feb 2003 06:42:06 -0000 1.7 *************** *** 192,195 **** --- 192,203 ---- */ public Map getAllCollectionMetadata() throws HibernateException; + + /** + * Destroy this <tt>SessionFactory</tt> and release all resources + * (connection pools, etc). It is the responsibility of the application + * to ensure that there are no open <tt>Session</tt>s before calling + * <tt>close()</tt>. + */ + public void close() throws HibernateException; } |
From: <one...@us...> - 2003-02-19 12:43:29
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv8915/hibernate/test Modified Files: FooBarTest.java Added Files: FumTest.java Log Message: fixed a bug in PreparedStatement caching refactored composite id tests to new class --- NEW FILE: FumTest.java --- //$Id: FumTest.java,v 1.1 2003/02/19 12:43:24 oneovthafew Exp $ package cirrus.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 cirrus.hibernate.Hibernate; import cirrus.hibernate.LockMode; import cirrus.hibernate.Query; import cirrus.hibernate.Session; import cirrus.hibernate.sql.MckoiDialect; import cirrus.hibernate.type.DateType; import cirrus.hibernate.type.EntityType; import cirrus.hibernate.type.StringType; import cirrus.hibernate.type.Type; public class FumTest extends TestCase { protected short fumKeyShort = 1; public FumTest(String arg) { super(arg); } 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 cirrus.hibernate.test.Fum where not fum.fum='FRIEND'").size()==2, "find composite keyed objects" ); assertTrue( s.find("select fum from fum in class cirrus.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 cirrus.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 cirrus.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 cirrus.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 cirrus.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 cirrus.hibernate.test.Fum").hasNext() ); assertTrue( s.iterate("select fum.id from fum in class cirrus.hibernate.test.Fum").hasNext() ); Query qu = s.createQuery("select fum.fum, fum , fum.fum, fum.id.date from fum in class cirrus.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 cirrus.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 cirrus.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 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.findIdentifiers("from fum in class cirrus.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 cirrus.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 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 cirrus.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; } } } Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/FooBarTest.java,v retrieving revision 1.240 retrieving revision 1.241 diff -C2 -d -r1.240 -r1.241 *** FooBarTest.java 15 Feb 2003 01:14:37 -0000 1.240 --- FooBarTest.java 19 Feb 2003 12:43:24 -0000 1.241 *************** *** 16,22 **** import cirrus.hibernate.sql.SAPDBDialect; import cirrus.hibernate.sql.SybaseDialect; - import cirrus.hibernate.type.DateType; - import cirrus.hibernate.type.EntityType; - import cirrus.hibernate.type.StringType; import cirrus.hibernate.type.Type; --- 16,19 ---- *************** *** 32,36 **** import java.util.List; import java.util.Locale; - import java.util.Properties; import java.util.Set; import java.util.TimeZone; --- 29,32 ---- *************** *** 1459,1610 **** } - 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 cirrus.hibernate.test.Fum where not fum.fum='FRIEND'").size()==2, - "find composite keyed objects" - ); - assertTrue( - s.find("select fum from fum in class cirrus.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 cirrus.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 cirrus.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 cirrus.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 cirrus.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 cirrus.hibernate.test.Fum").hasNext() - ); - assertTrue( - s.iterate("select fum.id from fum in class cirrus.hibernate.test.Fum").hasNext() - ); - Query qu = s.createQuery("select fum.fum, fum , fum.fum, fum.id.date from fum in class cirrus.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 cirrus.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 ) { --- 1455,1458 ---- *************** *** 1645,1684 **** } - 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(); --- 1493,1496 ---- *************** *** 2057,2104 **** } - 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 cirrus.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(); --- 1869,1872 ---- *************** *** 2466,2493 **** } - 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.findIdentifiers("from fum in class cirrus.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 cirrus.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(); --- 2234,2237 ---- *************** *** 2587,2635 **** 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 cirrus.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(); } --- 2331,2334 ---- |
From: <one...@us...> - 2003-02-19 12:43:29
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv8915/hibernate/impl Modified Files: SessionFactoryImpl.java Log Message: fixed a bug in PreparedStatement caching refactored composite id tests to new class Index: SessionFactoryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl/SessionFactoryImpl.java,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** SessionFactoryImpl.java 14 Jan 2003 13:01:09 -0000 1.62 --- SessionFactoryImpl.java 19 Feb 2003 12:43:24 -0000 1.63 *************** *** 494,497 **** --- 494,499 ---- public void closePreparedStatement(PreparedStatement ps) throws SQLException { if (stCache!=null) { + ps.setMaxRows(0); + ps.setFetchSize(0); stCache.closePreparedStatement(ps); } |
From: <one...@us...> - 2003-02-19 12:39:05
|
Update of /cvsroot/hibernate/Hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv7312 Modified Files: changelog.txt Log Message: recent changes Index: changelog.txt =================================================================== RCS file: /cvsroot/hibernate/Hibernate/changelog.txt,v retrieving revision 1.296 retrieving revision 1.297 diff -C2 -d -r1.296 -r1.297 *** changelog.txt 28 Jan 2003 13:07:43 -0000 1.296 --- changelog.txt 19 Feb 2003 12:38:54 -0000 1.297 *************** *** 1,4 **** --- 1,11 ---- Hibernate Changelog =================== + Changes in version 1.2.4 + ------------------------ + * fixed an exception that occurred wrapping collections with sort="MyComparator" (Jason Horne) + * mutable="false" objects are now never updated + * fixed an exception that occurs with <key-many-to-one> association to a class with a composite id (Stefano Travelli) + * fixed a bug in Hibernate PreparedStatement cache where maxRows and FetchSize were not cleared before re-caching + Changes in version 1.2.3 (28.1.2003) ------------------------------------ |
From: <one...@us...> - 2003-02-19 12:38:28
|
Update of /cvsroot/hibernate/Hibernate2 In directory sc8-pr-cvs1:/tmp/cvs-serv7092 Modified Files: changelog.txt Log Message: recent changes Index: changelog.txt =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/changelog.txt,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** changelog.txt 2 Feb 2003 06:47:05 -0000 1.6 --- changelog.txt 19 Feb 2003 12:38:24 -0000 1.7 *************** *** 1,4 **** --- 1,25 ---- Hibernate Changelog =================== + Changes in version 2.0 beta 3 (2.2.2003) + ---------------------------------------- + * collections now deserialize correctly (fix for bug in beta 2) + * standardised on dom4j for XML parsing + * fixed bugs in collection caching (an exception occurred for some sorted collections and some kinds of maps) + * allowed null discriminators + * set autocommit to true in SchemaUpdate + * fixed a stack overflow that could occur in toString() of classes created with hbm2java (Max Andersen) + * fixed a bug where composite-element <parent> property was not being set after retrieval from cache + * added where attribute to collection mappings + * fixed a exception that occurred when wrapping collections with sort="MyComparator" (Jason Horne) + * objects with mutable="false" are now never updated + * fixed an exception that occurs with <key-many-to-one> association to a class with a composite id (Stefano Travelli) + * added SchemaExport Ant task (Rong C Ou) + * integrated latest CGLIB release (Juozas Baliuka) + - added support for new CGLIB reflection optimizer (Juozas Baliuka) + * improved query cache algorithm (Who?) + * fixed a bug in "object" type + * Lists and arrays now represent null elements as a missing row + * fixed a bug in Hibernate PreparedStatement cache where maxRows and fetchSize were not cleared before re-caching + Changes in version 2.0 beta 2 (2.2.2003) ---------------------------------------- |
From: <one...@us...> - 2003-02-19 02:02:45
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/engine In directory sc8-pr-cvs1:/tmp/cvs-serv6974/engine Modified Files: SessionImplementor.java Log Message: fixed a problem in ObjectType fixed a bug where PreparedStatements were returned to cache with setMaxRows() still set Index: SessionImplementor.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/engine/SessionImplementor.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SessionImplementor.java 3 Feb 2003 10:28:46 -0000 1.7 --- SessionImplementor.java 19 Feb 2003 02:02:12 -0000 1.8 *************** *** 173,176 **** --- 173,185 ---- public Serializable getEntityIdentifier(Object obj); + /** + * Return the identifier of the persistent or transient object, or throw + * an exception if the instance is "unsaved" + */ + public Serializable getEntityIdentifierIfNotUnsaved(Object object) throws HibernateException; + + /** + * Instantiate the entity class, initializing with the given identifier + */ public Object instantiate(Class clazz, Serializable id) throws HibernateException; |
From: <one...@us...> - 2003-02-19 02:02:45
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv6974/impl Modified Files: SessionFactoryImpl.java SessionImpl.java Log Message: fixed a problem in ObjectType fixed a bug where PreparedStatements were returned to cache with setMaxRows() still set Index: SessionFactoryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionFactoryImpl.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** SessionFactoryImpl.java 16 Feb 2003 01:55:05 -0000 1.11 --- SessionFactoryImpl.java 19 Feb 2003 02:02:09 -0000 1.12 *************** *** 540,543 **** --- 540,545 ---- public void closePreparedStatement(PreparedStatement ps) throws SQLException { if (stCache!=null) { + ps.setMaxRows(0); + ps.setFetchSize(0); stCache.closePreparedStatement(ps); } Index: SessionImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionImpl.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** SessionImpl.java 16 Feb 2003 01:55:05 -0000 1.21 --- SessionImpl.java 19 Feb 2003 02:02:10 -0000 1.22 *************** *** 719,723 **** return null; } ! else if ( type.isEntityType() ) { return ( isTransient(value, earlyInsert, self) ) ? null : value; } --- 719,723 ---- return null; } ! else if ( type.isEntityType() || type.isObjectType() ) { return ( isTransient(value, earlyInsert, self) ) ? null : value; } *************** *** 2112,2116 **** EntityEntry entry = getEntry(object); return (entry!=null) ? entry.id : null; ! //return getPersister(object).getID(object); } } --- 2112,2153 ---- EntityEntry entry = getEntry(object); return (entry!=null) ? entry.id : null; ! } ! } ! ! public Serializable getEntityIdentifierIfNotUnsaved(Object object) throws HibernateException { ! if (object == null) { ! return null; ! } ! else { ! if (object instanceof HibernateProxy) { ! return HibernateProxyHelper.getLazyInitializer( (HibernateProxy) object ).getIdentifier(); ! } ! else { ! ! EntityEntry entry = getEntry(object); ! if (entry!=null) { ! return entry.id; ! } ! else { ! ClassPersister persister = getPersister(object); ! Serializable id; ! try { ! // we only allow this case to support Session.update() ! id = persister.getIdentifier(object); ! } ! catch (HibernateException he) { ! // transient instance with no identifier property ! id = null; ! } ! ! Boolean isUnsaved = (id==null) ? Boolean.TRUE : interceptor.isUnsaved(object); ! if ( ( isUnsaved!=null && isUnsaved.booleanValue() ) || persister.isUnsaved(id) ) { ! throw new HibernateException( ! "object references an unsaved transient instance - save the transient instance before flushing" ! ); ! } ! return id; ! } ! } } } |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type In directory sc8-pr-cvs1:/tmp/cvs-serv6974/type Modified Files: AbstractType.java EntityType.java ManyToOneType.java ObjectType.java Type.java Log Message: fixed a problem in ObjectType fixed a bug where PreparedStatements were returned to cache with setMaxRows() still set Index: AbstractType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/AbstractType.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AbstractType.java 9 Feb 2003 07:41:16 -0000 1.6 --- AbstractType.java 19 Feb 2003 02:02:07 -0000 1.7 *************** *** 60,74 **** SessionImplementor session, Object owner) ! throws HibernateException, SQLException { ! return nullSafeGet(rs, names, session, owner); ! } ! public Object resolveIdentifier(Object value, SessionImplementor session, Object owner) ! throws HibernateException, SQLException { ! return value; ! } } --- 60,79 ---- SessionImplementor session, Object owner) ! throws HibernateException, SQLException { ! return nullSafeGet(rs, names, session, owner); ! } ! public Object resolveIdentifier(Object value, SessionImplementor session, Object owner) ! throws HibernateException, SQLException { ! return value; ! } + + public boolean isObjectType() { + return false; } + + } Index: EntityType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/EntityType.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** EntityType.java 9 Feb 2003 07:41:16 -0000 1.6 --- EntityType.java 19 Feb 2003 02:02:07 -0000 1.7 *************** *** 51,74 **** } ! protected Serializable getIdentifier(Object value, SessionImplementor session) throws HibernateException { ! if (value == null) { ! return null; ! } ! else { ! Serializable id = session.getEntityIdentifier(value); ! if (id==null) { ! try { ! // we only allow this case to support Session.update() ! id = session.getFactory().getPersister(persistentClass).getIdentifier(value); ! } ! catch (HibernateException he) { ! // transient instance with no identifier property ! } ! if (id==null) throw new HibernateException( ! "object references a transient instance - save the transient instance first" ! ); ! } ! return id; ! } } --- 51,56 ---- } ! protected final Serializable getIdentifier(Object value, SessionImplementor session) throws HibernateException { ! return session.getEntityIdentifierIfNotUnsaved(value); } Index: ManyToOneType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/ManyToOneType.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ManyToOneType.java 9 Feb 2003 07:41:16 -0000 1.4 --- ManyToOneType.java 19 Feb 2003 02:02:07 -0000 1.5 *************** *** 48,69 **** SessionImplementor session, Object owner) ! throws HibernateException, SQLException { ! return (Serializable) session.getFactory().getIdentifierType( getPersistentClass() ) ! .nullSafeGet(rs, names, session, owner); ! } ! public Object resolveIdentifier(Object value, SessionImplementor session, Object owner) ! throws HibernateException, SQLException { ! ! if (value==null) { ! return null; ! } ! else { ! return session.internalLoad( getPersistentClass(), (Serializable) value ); ! } ! } } --- 48,68 ---- SessionImplementor session, Object owner) ! throws HibernateException, SQLException { ! return (Serializable) session.getFactory().getIdentifierType( getPersistentClass() ).nullSafeGet(rs, names, session, owner); ! } ! public Object resolveIdentifier(Object value, SessionImplementor session, Object owner) ! throws HibernateException, SQLException { + if (value==null) { + return null; + } + else { + return session.internalLoad( getPersistentClass(), (Serializable) value ); + } } + + } Index: ObjectType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/ObjectType.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ObjectType.java 19 Jan 2003 11:47:08 -0000 1.4 --- ObjectType.java 19 Feb 2003 02:02:08 -0000 1.5 *************** *** 77,80 **** --- 77,82 ---- throws HibernateException, SQLException { + //if ( names.length!=2 ) throw new HibernateException("object type mapping must specify exactly two columns"); + String className = (String) Hibernate.STRING.nullSafeGet( rs, names[0] ); Serializable id = (Serializable) Hibernate.SERIALIZABLE.nullSafeGet( rs, names[1] ); *************** *** 103,108 **** } else { String className = value.getClass().getName(); - Serializable id = session.getEntityIdentifier(value); Hibernate.STRING.nullSafeSet(st, className, index, session); Hibernate.SERIALIZABLE.nullSafeSet(st, id, index+1, session); --- 105,110 ---- } else { + Serializable id = session.getEntityIdentifierIfNotUnsaved(value); String className = value.getClass().getName(); Hibernate.STRING.nullSafeSet(st, className, index, session); Hibernate.SERIALIZABLE.nullSafeSet(st, id, index+1, session); *************** *** 149,166 **** SessionImplementor session, Object owner) ! throws HibernateException, SQLException { ! ObjectTypeCacheEntry e = (ObjectTypeCacheEntry) cached; ! return (cached==null) ? null : session.load(e.clazz, e.id); ! } ! /** ! * @see net.sf.hibernate.type.Type#disassemble(Object, SessionImplementor) ! */ ! public Serializable disassemble(Object value, SessionImplementor session) ! throws HibernateException { ! return (value==null) ? null : new ObjectTypeCacheEntry( value.getClass(), session.getEntityIdentifier(value) ); ! } } --- 151,176 ---- SessionImplementor session, Object owner) ! throws HibernateException, SQLException { ! ObjectTypeCacheEntry e = (ObjectTypeCacheEntry) cached; ! return (cached==null) ? null : session.load(e.clazz, e.id); ! } + /** + * @see net.sf.hibernate.type.Type#disassemble(Object, SessionImplementor) + */ + public Serializable disassemble(Object value, SessionImplementor session) + throws HibernateException { + return (value==null) ? null : new ObjectTypeCacheEntry( value.getClass(), session.getEntityIdentifier(value) ); } + + /** + * @see net.sf.hibernate.type.Type#isObjectType() + */ + public boolean isObjectType() { + return true; + } + + } Index: Type.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/Type.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Type.java 9 Feb 2003 07:41:16 -0000 1.7 --- Type.java 19 Feb 2003 02:02:09 -0000 1.8 *************** *** 52,55 **** --- 52,65 ---- /** + * Is this an "object" type, ie. a reference to a persistent entity + * that is not modelled as a (foreign key) association. + * + * @param mapping + * @return int[] + * @throws MappingException + */ + public boolean isObjectType(); + + /** * Return the SQL type codes for the columns mapped by this type. The codes * are defined on <tt>java.sql.Types</tt>. |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv6974/test Modified Files: FooBarTest.java Glarch.hbm.xml Glarch.java Parent.java ParentChild.hbm.xml ParentChildTest.java Log Message: fixed a problem in ObjectType fixed a bug where PreparedStatements were returned to cache with setMaxRows() still set Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** FooBarTest.java 15 Feb 2003 08:00:52 -0000 1.22 --- FooBarTest.java 19 Feb 2003 02:02:13 -0000 1.23 *************** *** 273,281 **** s.iterate("select one, max(one.manies.elements) from one in class net.sf.hibernate.test.One group by one"); Iterator iter = s.iterate("select baz.fooArray.elements from baz in class Baz where baz.id=?", baz.getCode(), Hibernate.STRING); ! assertTrue( iter.next()==null && iter.next()==foos[1] && !iter.hasNext() ); List list = s.find("select baz.fooArray.elements from baz in class Baz where baz.id=?", baz.getCode(), Hibernate.STRING); ! assertTrue( list.size()==2 ); iter = s.iterate("select indices(baz.fooArray) from baz in class Baz where baz.id=?", baz.getCode(), Hibernate.STRING); ! assertTrue( iter.next().equals( new Integer(0) ) && iter.next().equals( new Integer(1) ) && !iter.hasNext() ); iter = s.iterate("select baz, max(baz.timeArray.elements) from baz in class Baz group by baz"); --- 273,284 ---- s.iterate("select one, max(one.manies.elements) from one in class net.sf.hibernate.test.One group by one"); Iterator iter = s.iterate("select baz.fooArray.elements from baz in class Baz where baz.id=?", baz.getCode(), Hibernate.STRING); ! //WAS: assertTrue( iter.next()==null && iter.next()==foos[1] && !iter.hasNext() ); ! assertTrue( iter.next()==foos[1] && !iter.hasNext() ); List list = s.find("select baz.fooArray.elements from baz in class Baz where baz.id=?", baz.getCode(), Hibernate.STRING); ! //WAS: assertTrue( list.size()==2 ); ! assertTrue( list.size()==1 ); iter = s.iterate("select indices(baz.fooArray) from baz in class Baz where baz.id=?", baz.getCode(), Hibernate.STRING); ! //WAS: assertTrue( iter.next().equals( new Integer(0) ) && iter.next().equals( new Integer(1) ) && !iter.hasNext() ); ! assertTrue( iter.next().equals( new Integer(1) ) && !iter.hasNext() ); iter = s.iterate("select baz, max(baz.timeArray.elements) from baz in class Baz group by baz"); *************** *** 886,890 **** assertTrue( list.size()==2, "component query" ); } ! list = s.find("from foo in class net.sf.hibernate.test.Foo where foo.component.importantDates.size = 4"); assertTrue( list.size()==2, "component query" ); list = s.find("from foo in class net.sf.hibernate.test.Foo where 0 = foo.component.importantDates.size"); --- 889,893 ---- assertTrue( list.size()==2, "component query" ); } ! list = s.find("from foo in class net.sf.hibernate.test.Foo where foo.component.importantDates.size = 3"); //WAS: 4 assertTrue( list.size()==2, "component query" ); list = s.find("from foo in class net.sf.hibernate.test.Foo where 0 = foo.component.importantDates.size"); *************** *** 931,935 **** assertTrue( row[0] instanceof String && ( row[1]==null || row[1] instanceof Date ) ); } ! assertTrue(i==4); iter = s.iterate( "select max(foo.component.importantDates.elements) from foo in class net.sf.hibernate.test.Foo group by foo.id" --- 934,938 ---- assertTrue( row[0] instanceof String && ( row[1]==null || row[1] instanceof Date ) ); } ! assertTrue(i==3); //WAS: 4 iter = s.iterate( "select max(foo.component.importantDates.elements) from foo in class net.sf.hibernate.test.Foo group by foo.id" *************** *** 2435,2439 **** } ! public void testUserProvidedConnection() throws Exception { ConnectionProvider dcp = new DriverManagerConnectionProvider(); --- 2438,2442 ---- } ! public void testUserProvidedConnection() throws Exception { ConnectionProvider dcp = new DriverManagerConnectionProvider(); *************** *** 2541,2544 **** --- 2544,2567 ---- } assertTrue(err); + s.connection().commit(); + s.close(); + } + + public void testObjectType() throws Exception { + Session s = sessions.openSession(); + Glarch g = new Glarch(); + Foo foo = new Foo(); + g.setAny(foo); + Serializable gid = s.save(g); + s.save(foo); + s.flush(); + s.connection().commit(); + s.close(); + s = sessions.openSession(); + g = (Glarch) s.load(Glarch.class, gid); + assertTrue( g.getAny()!=null && g.getAny() instanceof Foo ); + s.delete( g.getAny() ); + s.delete(g); + s.flush(); s.connection().commit(); s.close(); Index: Glarch.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Glarch.hbm.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Glarch.hbm.xml 2 Feb 2003 06:41:06 -0000 1.5 --- Glarch.hbm.xml 19 Feb 2003 02:02:15 -0000 1.6 *************** *** 46,49 **** --- 46,53 ---- <property name="immutable" update="false"/> <property name="derivedVersion" insert="false" update="false" column="version"/> + <property name="any" type="object"> + <column name="any_id"/> + <column name="any_class"/> + </property> </class> Index: Glarch.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Glarch.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Glarch.java 28 Jan 2003 10:22:21 -0000 1.6 --- Glarch.java 19 Feb 2003 02:02:15 -0000 1.7 *************** *** 32,35 **** --- 32,36 ---- private String immutable; private int derivedVersion; + private Object any; public int getVersion() { *************** *** 191,194 **** --- 192,211 ---- public void setDerivedVersion(int derivedVersion) { this.derivedVersion = derivedVersion; + } + + /** + * Returns the any. + * @return Object + */ + public Object getAny() { + return any; + } + + /** + * Sets the any. + * @param any The any to set + */ + public void setAny(Object any) { + this.any = any; } Index: Parent.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Parent.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Parent.java 5 Jan 2003 02:11:23 -0000 1.3 --- Parent.java 19 Feb 2003 02:02:15 -0000 1.4 *************** *** 6,9 **** --- 6,10 ---- private int count; private Child child; + private Object any; public int getCount() { *************** *** 36,40 **** } ! } --- 37,48 ---- } ! public Object getAny() { ! return any; ! } ! ! public void setAny(Object any) { ! this.any = any; ! } ! } Index: ParentChild.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/ParentChild.hbm.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ParentChild.hbm.xml 28 Jan 2003 10:22:21 -0000 1.3 --- ParentChild.hbm.xml 19 Feb 2003 02:02:16 -0000 1.4 *************** *** 11,14 **** --- 11,18 ---- <property name="count" column="count_"/> <one-to-one name="child"/> + <property name="any" type="object"> + <column name="any_id"/> + <column name="any_class"/> + </property> </class> Index: ParentChildTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/ParentChildTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ParentChildTest.java 9 Feb 2003 06:28:16 -0000 1.5 --- ParentChildTest.java 19 Feb 2003 02:02:16 -0000 1.6 *************** *** 296,300 **** System.out.println( c.getComponents() ); System.out.println( c.getComposites() ); ! assertTrue( c.getComponents().size()==2 ); assertTrue( c.getComposites().size()==2 ); assertTrue( c.getOneToMany().size()==2 ); --- 296,300 ---- System.out.println( c.getComponents() ); System.out.println( c.getComposites() ); ! assertTrue( c.getComponents().size()==1 ); //WAS: 2 assertTrue( c.getComposites().size()==2 ); assertTrue( c.getOneToMany().size()==2 ); *************** *** 314,318 **** System.out.println( c.getComponents() ); System.out.println( c.getComposites() ); ! assertTrue( c.getComponents().size()==2 ); assertTrue( c.getComposites().size()==2 ); assertTrue( ( (Container.ContainerInnerClass) c.getComponents().get(0) ).getName().equals("a different name") ); --- 314,318 ---- System.out.println( c.getComponents() ); System.out.println( c.getComposites() ); ! assertTrue( c.getComponents().size()==1 ); //WAS: 2 assertTrue( c.getComposites().size()==2 ); assertTrue( ( (Container.ContainerInnerClass) c.getComponents().get(0) ).getName().equals("a different name") ); *************** *** 582,585 **** --- 582,605 ---- s.delete(s1); s.delete(s2); s.delete(s3); s.delete(s4); tx.commit(); + s.close(); + } + + public void testObjectType() throws Exception { + Session s = sessions.openSession(); + Parent g = new Parent(); + Foo foo = new Foo(); + g.setAny(foo); + s.save(g); + s.save(foo); + s.flush(); + s.connection().commit(); + s.close(); + s = sessions.openSession(); + g = (Parent) s.load( Parent.class, new Long( g.getId() ) ); + assertTrue( g.getAny()!=null && g.getAny() instanceof Foo ); + s.delete( g.getAny() ); + s.delete(g); + s.flush(); + s.connection().commit(); s.close(); } |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection In directory sc8-pr-cvs1:/tmp/cvs-serv3845 Modified Files: ArrayHolder.java Bag.java CollectionPersister.java List.java Map.java PersistentCollection.java Set.java SortedSet.java Log Message: collections now represent null values as a missing row performance improvement for collection dirty-searching Index: ArrayHolder.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/ArrayHolder.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ArrayHolder.java 9 Feb 2003 07:41:15 -0000 1.8 --- ArrayHolder.java 19 Feb 2003 01:51:30 -0000 1.9 *************** *** 8,12 **** import java.sql.SQLException; import java.util.ArrayList; - import java.util.HashSet; import java.util.Iterator; --- 8,11 ---- *************** *** 202,209 **** public Iterator getDeletes(Type elemType) throws HibernateException { ! java.util.Set deletes = new HashSet(); ! int size = Array.getLength( getSnapshot() ); ! for ( int i=Array.getLength(array); i<size; i++ ) { ! deletes.add( new Integer(i) ); } return deletes.iterator(); --- 201,218 ---- public Iterator getDeletes(Type elemType) throws HibernateException { ! java.util.List deletes = new ArrayList(); ! Serializable sn = getSnapshot(); ! int snSize = Array.getLength(sn); ! int arraySize = Array.getLength(array); ! int end; ! if ( snSize > arraySize ) { ! for ( int i=arraySize; i<snSize; i++ ) deletes.add( new Integer(i) ); ! end = arraySize; ! } ! else { ! end = snSize; ! } ! for ( int i=0; i<end; i++ ) { ! if ( Array.get(array, i)==null && Array.get(sn, i)!=null ) deletes.add( new Integer(i) ); } return deletes.iterator(); *************** *** 211,220 **** public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException { ! return i >= Array.getLength(getSnapshot()); } public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException { ! Serializable snapshot = getSnapshot(); ! return i<Array.getLength(snapshot) && elemType.isDirty( Array.get(array, i), Array.get(snapshot, i), session ); } /** --- 220,233 ---- public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException { ! Serializable sn = getSnapshot(); ! return Array.get(array, i)!=null && ( i >= Array.getLength(sn) || Array.get(sn, i)==null ); } public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException { ! Serializable sn = getSnapshot(); ! return i<Array.getLength(sn) && ! Array.get(sn, i)!=null && ! Array.get(array, i)!=null && ! elemType.isDirty( Array.get(array, i), Array.get(sn, i), session ); } /** *************** *** 225,228 **** --- 238,248 ---- } + /** + * @see net.sf.hibernate.collection.PersistentCollection#entryExists(java.lang.Object, int) + */ + public boolean entryExists(Object entry, int i) { + return entry!=null; + } + } Index: Bag.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/Bag.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Bag.java 9 Feb 2003 07:41:15 -0000 1.7 --- Bag.java 19 Feb 2003 01:51:30 -0000 1.8 *************** *** 478,481 **** --- 478,488 ---- }*/ + /** + * @see net.sf.hibernate.collection.PersistentCollection#entryExists(java.lang.Object, int) + */ + public boolean entryExists(Object entry, int i) { + return entry!=null; + } + } Index: CollectionPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/CollectionPersister.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** CollectionPersister.java 15 Feb 2003 01:00:51 -0000 1.11 --- CollectionPersister.java 19 Feb 2003 01:51:30 -0000 1.12 *************** *** 523,527 **** while ( entries.hasNext() ) { Object entry = entries.next(); ! if ( !isOneToMany || entry!=null ) { writeKey(st, id, false, session); collection.writeTo(st, this, entry, i, false); --- 523,527 ---- while ( entries.hasNext() ) { Object entry = entries.next(); ! if ( collection.entryExists(entry, i) ) { writeKey(st, id, false, session); collection.writeTo(st, this, entry, i, false); *************** *** 619,623 **** while ( entries.hasNext() ) { Object entry = entries.next(); ! if ( entry!=null && collection.needsUpdating(entry, i, elementType) ) { if (insst==null) insst = session.getBatcher().prepareBatchStatement( getSQLInsertRowString() ); writeKey(insst, id, false, session); --- 619,623 ---- while ( entries.hasNext() ) { Object entry = entries.next(); ! if ( collection.needsUpdating(entry, i, elementType) ) { if (insst==null) insst = session.getBatcher().prepareBatchStatement( getSQLInsertRowString() ); writeKey(insst, id, false, session); *************** *** 664,668 **** while ( entries.hasNext() ) { Object entry = entries.next(); ! if ( collection.needsInserting(entry, i, elementType) && ( !isOneToMany || entry!=null ) ) { if (st==null) st = session.getBatcher().prepareBatchStatement( getSQLInsertRowString() ); writeKey(st, id, false, session); --- 664,668 ---- while ( entries.hasNext() ) { Object entry = entries.next(); ! if ( collection.needsInserting(entry, i, elementType) ) { if (st==null) st = session.getBatcher().prepareBatchStatement( getSQLInsertRowString() ); writeKey(st, id, false, session); Index: List.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/List.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** List.java 9 Feb 2003 07:41:15 -0000 1.8 --- List.java 19 Feb 2003 01:51:30 -0000 1.9 *************** *** 6,10 **** import java.sql.ResultSet; import java.sql.SQLException; - import java.util.HashSet; import java.util.Iterator; import java.util.Collection; --- 6,9 ---- *************** *** 340,358 **** public Iterator getDeletes(Type elemType) throws HibernateException { ! java.util.Set deletes = new HashSet(); ! for ( int i=list.size(); i<( (java.util.List) getSnapshot() ).size(); i++ ) { ! deletes.add( new Integer(i) ); } return deletes.iterator(); } ! public boolean needsInserting(Object entry, int i,Type elemType) throws HibernateException { final java.util.List sn = (java.util.List) getSnapshot(); ! return i >= sn.size(); } public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException { final java.util.List sn = (java.util.List) getSnapshot(); ! return i<sn.size() && elemType.isDirty( list.get(i), sn.get(i), session ); } --- 339,366 ---- public Iterator getDeletes(Type elemType) throws HibernateException { ! java.util.List deletes = new ArrayList(); ! java.util.List sn = (java.util.List) getSnapshot(); ! int end; ! if ( sn.size() > list.size() ) { ! for ( int i=list.size(); i<sn.size(); i++ ) deletes.add( new Integer(i) ); ! end = list.size(); ! } ! else { ! end = sn.size(); ! } ! for ( int i=0; i<end; i++ ) { ! if ( list.get(i)==null && sn.get(i)!=null ) deletes.add( new Integer(i) ); } return deletes.iterator(); } ! public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException { final java.util.List sn = (java.util.List) getSnapshot(); ! return list.get(i)!=null && ( i >= sn.size() || sn.get(i)==null ); } public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException { final java.util.List sn = (java.util.List) getSnapshot(); ! return i<sn.size() && sn.get(i)!=null && list.get(i)!=null && elemType.isDirty( list.get(i), sn.get(i), session ); } *************** *** 401,404 **** --- 409,419 ---- } + /** + * @see net.sf.hibernate.collection.PersistentCollection#entryExists(java.lang.Object, int) + */ + public boolean entryExists(Object entry, int i) { + return entry!=null; + } + } Index: Map.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/Map.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Map.java 9 Feb 2003 07:41:15 -0000 1.8 --- Map.java 19 Feb 2003 01:51:30 -0000 1.9 *************** *** 7,12 **** import java.sql.ResultSet; import java.sql.SQLException; import java.util.Collection; - import java.util.HashSet; import java.util.Iterator; --- 7,12 ---- import java.sql.ResultSet; import java.sql.SQLException; + import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; *************** *** 335,344 **** public Iterator getDeletes(Type elemType) throws HibernateException { ! java.util.Set deletes = new HashSet(); Iterator iter = ( (java.util.Map) getSnapshot() ).entrySet().iterator(); while ( iter.hasNext() ) { java.util.Map.Entry e = (java.util.Map.Entry) iter.next(); Object key = e.getKey(); ! if ( !map.containsKey(key) ) deletes.add(key); } return deletes.iterator(); --- 335,344 ---- public Iterator getDeletes(Type elemType) throws HibernateException { ! java.util.List deletes = new ArrayList(); Iterator iter = ( (java.util.Map) getSnapshot() ).entrySet().iterator(); while ( iter.hasNext() ) { java.util.Map.Entry e = (java.util.Map.Entry) iter.next(); Object key = e.getKey(); ! if ( e.getValue()!=null && map.get(key)==null ) deletes.add(key); } return deletes.iterator(); *************** *** 348,352 **** final java.util.Map sn = (java.util.Map) getSnapshot(); java.util.Map.Entry e = (java.util.Map.Entry) entry; ! return !sn.containsKey( e.getKey() ); } --- 348,352 ---- final java.util.Map sn = (java.util.Map) getSnapshot(); java.util.Map.Entry e = (java.util.Map.Entry) entry; ! return e.getValue()!=null && sn.get( e.getKey() )==null; } *************** *** 354,358 **** final java.util.Map sn = (java.util.Map) getSnapshot(); java.util.Map.Entry e = (java.util.Map.Entry) entry; ! return sn.containsKey( e.getKey() ) && elemType.isDirty( e.getValue(), sn.get( e.getKey() ), session ); } --- 354,361 ---- final java.util.Map sn = (java.util.Map) getSnapshot(); java.util.Map.Entry e = (java.util.Map.Entry) entry; ! Object snValue = sn.get( e.getKey() ); ! return e.getValue()!=null && ! snValue!=null && ! elemType.isDirty( snValue, e.getValue(), session ); } *************** *** 372,375 **** --- 375,385 ---- } + /** + * @see net.sf.hibernate.collection.PersistentCollection#entryExists(java.lang.Object, int) + */ + public boolean entryExists(Object entry, int i) { + return ( (Map.Entry) entry ).getValue()!=null; + } + } Index: PersistentCollection.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/PersistentCollection.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PersistentCollection.java 9 Feb 2003 06:28:14 -0000 1.7 --- PersistentCollection.java 19 Feb 2003 01:51:30 -0000 1.8 *************** *** 188,193 **** } ! public abstract boolean needsInserting(Object key, int i, Type elemType) throws HibernateException; ! public abstract boolean needsUpdating(Object key, int i, Type elemType) throws HibernateException; public abstract Iterator getDeletes(Type elemType) throws HibernateException; --- 188,194 ---- } ! public abstract boolean entryExists(Object entry, int i); ! public abstract boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException; ! public abstract boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException; public abstract Iterator getDeletes(Type elemType) throws HibernateException; Index: Set.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/Set.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Set.java 9 Feb 2003 07:41:15 -0000 1.7 --- Set.java 19 Feb 2003 01:51:30 -0000 1.8 *************** *** 4,7 **** --- 4,8 ---- import java.util.ArrayList; import java.util.Collection; + import java.util.HashMap; import java.util.Iterator; import java.util.Map; *************** *** 28,35 **** public Serializable snapshot(CollectionPersister persister) throws HibernateException { //if (set==null) return new Set(session); ! HashSet clonedSet = new HashSet( set.size() ); Iterator iter = set.iterator(); while ( iter.hasNext() ) { ! clonedSet.add( persister.getElementType().deepCopy( iter.next() ) ); } return clonedSet; --- 29,37 ---- public Serializable snapshot(CollectionPersister persister) throws HibernateException { //if (set==null) return new Set(session); ! HashMap clonedSet = new HashMap( set.size() ); Iterator iter = set.iterator(); while ( iter.hasNext() ) { ! Object copied = persister.getElementType().deepCopy( iter.next() ); ! clonedSet.put(copied, copied); } return clonedSet; *************** *** 37,60 **** public boolean equalsSnapshot(Type elementType) throws HibernateException { ! java.util.Set sn = (java.util.Set) getSnapshot(); if ( sn.size()!=set.size() ) { return false; } - else if ( elementType.hasNiceEquals() ) { - return sn.equals(set); - } else { Iterator iter = set.iterator(); while ( iter.hasNext() ) { Object test = iter.next(); ! Iterator sniter = sn.iterator(); ! boolean success=false; ! while ( sniter.hasNext() ) { ! if ( elementType.equals( test, sniter.next() ) ) { ! success=true; ! break; ! } ! } ! if (!success) return false; } return true; --- 39,52 ---- public boolean equalsSnapshot(Type elementType) throws HibernateException { ! java.util.Map sn = (java.util.Map) getSnapshot(); if ( sn.size()!=set.size() ) { return false; } else { Iterator iter = set.iterator(); while ( iter.hasNext() ) { Object test = iter.next(); ! Object oldValue = sn.get(test); ! if ( oldValue==null || elementType.isDirty(oldValue, test, session) ) return false; } return true; *************** *** 266,288 **** public Iterator getDeletes(Type elemType) throws HibernateException { ! final java.util.Set sn = (java.util.Set) getSnapshot(); ArrayList deletes = new ArrayList( sn.size() ); ! Iterator iter = sn.iterator(); while ( iter.hasNext() ) { Object test = iter.next(); if ( !set.contains(test) ) { deletes.add(test); } ! else if ( !elemType.hasNiceEquals() ) { ! Iterator setiter = set.iterator(); ! boolean found = false; ! while ( setiter.hasNext() ) { ! if ( elemType.equals( setiter.next(), test ) ) { ! found=true; ! break; ! } ! } ! if (!found) deletes.add(test); ! } } --- 258,278 ---- public Iterator getDeletes(Type elemType) throws HibernateException { ! final java.util.Map sn = (java.util.Map) getSnapshot(); ArrayList deletes = new ArrayList( sn.size() ); ! Iterator iter = sn.keySet().iterator(); while ( iter.hasNext() ) { Object test = iter.next(); if ( !set.contains(test) ) { + // the element has been removed from the set deletes.add(test); } ! } ! iter = set.iterator(); ! while ( iter.hasNext() ) { ! Object test = iter.next(); ! Object oldValue = sn.get(test); ! if ( oldValue!=null && elemType.isDirty(test, oldValue, session) ) { ! // the element has changed ! deletes.add(test); } } *************** *** 291,308 **** public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException { ! final java.util.Set sn = (java.util.Set) getSnapshot(); ! if ( !sn.contains(entry) ) { ! return true; ! } ! else if ( !elemType.hasNiceEquals() ) { ! Iterator iter = sn.iterator(); ! while ( iter.hasNext() ) { ! if ( elemType.equals( iter.next(), entry ) ) return false; ! } ! return true; ! } ! else { ! return false; ! } } --- 281,287 ---- public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException { ! final java.util.Map sn = (java.util.Map) getSnapshot(); ! Object oldValue = sn.get(entry); ! return oldValue==null || elemType.isDirty(oldValue, entry, session); } *************** *** 392,395 **** --- 371,381 ---- } + /** + * @see net.sf.hibernate.collection.PersistentCollection#entryExists(java.lang.Object, int) + */ + public boolean entryExists(Object key, int i) { + return true; + } + } Index: SortedSet.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/SortedSet.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SortedSet.java 15 Feb 2003 01:00:51 -0000 1.7 --- SortedSet.java 19 Feb 2003 01:51:30 -0000 1.8 *************** *** 5,8 **** --- 5,9 ---- import java.sql.SQLException; import java.util.Iterator; + import java.util.TreeMap; import java.util.TreeSet; import java.util.Comparator; *************** *** 24,31 **** public Serializable snapshot(CollectionPersister persister) throws HibernateException { //if (set==null) return new Set(session); ! TreeSet clonedSet = new TreeSet(comparator); Iterator iter = set.iterator(); while ( iter.hasNext() ) { ! clonedSet.add( persister.getElementType().deepCopy( iter.next() ) ); } return clonedSet; --- 25,33 ---- public Serializable snapshot(CollectionPersister persister) throws HibernateException { //if (set==null) return new Set(session); ! TreeMap clonedSet = new TreeMap(comparator); Iterator iter = set.iterator(); while ( iter.hasNext() ) { ! Object copy = persister.getElementType().deepCopy( iter.next() ); ! clonedSet.put(copy, copy); } return clonedSet; |
From: <max...@us...> - 2003-02-17 18:22:50
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java In directory sc8-pr-cvs1:/tmp/cvs-serv25831/src/net/sf/hibernate/tool/hbm2java Modified Files: Field.java BasicRenderer.java Log Message: Added support for "gen-property" meta tag. If gen-property is false, then no field, getter and setters will be generated. Usecase is to be able to have an non persistent base class which provides the field and its getter and setters instead. (consider this as an experimental feature as it result in incomplete constructors) Index: Field.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java/Field.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Field.java 2 Feb 2003 17:34:09 -0000 1.6 --- Field.java 17 Feb 2003 18:22:42 -0000 1.7 *************** *** 48,51 **** --- 48,52 ---- this.foreignKeys = foreignKeys; setMeta(metaattribs); + } *************** *** 63,67 **** public String getGetterType() { ! return (getType().toLowerCase().equals("boolean") ) ? " is" : " get"; } --- 64,68 ---- public String getGetterType() { ! return (getType().toLowerCase().equals("boolean") ) ? "is" : "get"; } *************** *** 110,117 **** */ private void setMeta(MultiMap multiMap) { - if(multiMap==null) { - - throw new RuntimeException("Forget it!"); - } metaattribs = multiMap; } --- 111,114 ---- *************** *** 141,152 **** public boolean getMetaAsBool(String attribute) { ! Collection c= getMeta(attribute); ! ! if(c==null || c.isEmpty()) { ! return false; ! } else { ! return Boolean.valueOf(c.iterator().next().toString()).booleanValue(); ! } } /** * Returns the foreignClass. --- 138,154 ---- public boolean getMetaAsBool(String attribute) { ! return getMetaAsBool(attribute,false); } + + public boolean getMetaAsBool(String attribute, boolean defaultValue) { + Collection c= getMeta(attribute); + + if(c==null || c.isEmpty()) { + return defaultValue; + } else { + return Boolean.valueOf(c.iterator().next().toString()).booleanValue(); + } + } + /** * Returns the foreignClass. *************** *** 181,183 **** --- 183,188 ---- } + public boolean isGeneratedAsProperty() { + return getMetaAsBool("gen-property", true); + } } Index: BasicRenderer.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java/BasicRenderer.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** BasicRenderer.java 16 Feb 2003 12:49:02 -0000 1.10 --- BasicRenderer.java 17 Feb 2003 18:22:42 -0000 1.11 *************** *** 24,27 **** --- 24,28 ---- static private Log log = LogFactory.getLog(BasicRenderer.class); + /** * Returns the true name for the given class name. By true name is *************** *** 252,256 **** writer.print(field.getName()); if(fields.hasNext()) { ! writer.print(StringHelper.COMMA_SPACE); } } --- 253,257 ---- writer.print(field.getName()); if(fields.hasNext()) { ! writer.print(", "); } } *************** *** 261,265 **** for(Iterator fields = classMapping.getLocalFieldsForFullConstructor().iterator(); fields.hasNext();) { Field field = (Field) fields.next(); ! writer.println(" this." + field.getName() + " = " + field.getName() + ";"); } writer.println(" }"); --- 262,268 ---- for(Iterator fields = classMapping.getLocalFieldsForFullConstructor().iterator(); fields.hasNext();) { Field field = (Field) fields.next(); ! if(field.isGeneratedAsProperty()) { ! writer.println(" this." + field.getName() + " = " + field.getName() + ";"); ! } } writer.println(" }"); *************** *** 307,311 **** for (Iterator fields = classMapping.getLocalFieldsForMinimalConstructor().iterator(); fields.hasNext();) { Field field = (Field) fields.next(); ! writer.println(" this." + field.getName() + " = " + field.getName() + ";"); } writer.println(" }"); --- 310,316 ---- for (Iterator fields = classMapping.getLocalFieldsForMinimalConstructor().iterator(); fields.hasNext();) { Field field = (Field) fields.next(); ! if(field.isGeneratedAsProperty()) { ! writer.println(" this." + field.getName() + " = " + field.getName() + ";"); ! } } writer.println(" }"); *************** *** 319,322 **** --- 324,328 ---- Field field = (Field) fields.next(); + if(field.isGeneratedAsProperty()) { String fieldScope = getFieldScope(field, "scope-field", "private"); writer.println( *************** *** 332,336 **** ';' ); ! writer.println(); } --- 338,342 ---- ';' ); ! } writer.println(); } *************** *** 346,350 **** Field field = (Field) fields.next(); if ( field.isIdentifier() ) { ! writer.println(" .append(this." + field.getName() + ", castOther." + field.getName() + StringHelper.CLOSE_PAREN); } } --- 352,356 ---- Field field = (Field) fields.next(); if ( field.isIdentifier() ) { ! writer.println(" .append(this." + field.getGetterSignature() + ", castOther." + field.getGetterSignature() + StringHelper.CLOSE_PAREN); } } *************** *** 358,362 **** Field field = (Field) fields.next(); if ( field.isIdentifier() ) { ! writer.println(" .append(" + field.getName() + StringHelper.CLOSE_PAREN); } } --- 364,368 ---- Field field = (Field) fields.next(); if ( field.isIdentifier() ) { ! writer.println(" .append(" + field.getGetterSignature() + StringHelper.CLOSE_PAREN); } } *************** *** 418,421 **** --- 424,428 ---- for (Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { Field field = (Field) fields.next(); + if(field.isGeneratedAsProperty()) { // getter *************** *** 426,430 **** writer.println(" /** \n" + toJavaDoc(field.getMetaAsString("description"), 4) + " */"); } ! writer.println(" " + getAccessScope + " " + getTrueTypeName(field, class2classmap) + field.getGetterSignature() + " {"); writer.println(" return this." + field.getName() + ";"); writer.println(" }"); --- 433,437 ---- writer.println(" /** \n" + toJavaDoc(field.getMetaAsString("description"), 4) + " */"); } ! writer.println(" " + getAccessScope + " " + getTrueTypeName(field, class2classmap) + " " + field.getGetterSignature() + " {"); writer.println(" return this." + field.getName() + ";"); writer.println(" }"); *************** *** 495,498 **** --- 502,506 ---- } */ + } } return fieldTypes; |
From: <max...@us...> - 2003-02-16 12:49:05
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java In directory sc8-pr-cvs1:/tmp/cvs-serv15397/src/net/sf/hibernate/tool/hbm2java Modified Files: ClassMapping.java BasicRenderer.java ClassName.java Log Message: Applied patch:685440 hbm2java generate Beans style property events by Klaus Zimmermann with small bugfix changes. Index: ClassMapping.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java/ClassMapping.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ClassMapping.java 2 Feb 2003 17:34:09 -0000 1.11 --- ClassMapping.java 16 Feb 2003 12:49:02 -0000 1.12 *************** *** 581,584 **** --- 581,585 ---- if ( hibernateType.equals("binary") ) { cn.setFullyQualifiedName("byte[]",true); + cn.setIsArray(true); return cn; } Index: BasicRenderer.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java/BasicRenderer.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** BasicRenderer.java 2 Feb 2003 17:34:09 -0000 1.9 --- BasicRenderer.java 16 Feb 2003 12:49:02 -0000 1.10 *************** *** 5,8 **** --- 5,9 ---- import java.io.StringWriter; import java.util.Collection; + import java.util.HashMap; import java.util.Iterator; import java.util.List; *************** *** 17,20 **** --- 18,25 ---- public class BasicRenderer implements Renderer { + + static final protected int ORDINARY = 0; + static final protected int BOUND = 1; + static final protected int CONSTRAINT = 3;//any constraint properties are bound as well static private Log log = LogFactory.getLog(BasicRenderer.class); *************** *** 41,44 **** --- 46,60 ---- } + private String makeSupportField(String fieldName, List fieldList) { + String suffix=""; + boolean needSuffix=false; + for( Iterator fields = fieldList.iterator(); fields.hasNext();) { + String name = ((Field)fields.next()).getName(); + if(name.equals(fieldName)) needSuffix=true; + suffix+=name; + } + return needSuffix ? fieldName+"_"+suffix : fieldName; + } + String getTrueTypeName(ClassName cn, Map class2classmap) { String name = cn.getFullyQualifiedName(); *************** *** 117,133 **** writer.println(" {"); writer.println(); - - doFields(classMapping, writer); ! doConstructors(classMapping, class2classmap, writer); ! doFieldAccessors(classMapping, class2classmap, writer); ! doToString(classMapping, writer); ! doEqualsAndHashCode(classMapping, writer); ! writer.println("}"); // finally write the imports --- 133,161 ---- writer.println(" {"); writer.println(); ! // switch to another writer to be able to insert the ! // veto- and changeSupport fields ! StringWriter strPropWriter = new StringWriter(); ! PrintWriter propWriter = new PrintWriter(strPropWriter); ! ! doFields(classMapping, propWriter); ! ! doConstructors(classMapping, class2classmap, propWriter); ! String vetoSupport = makeSupportField("vetos", classMapping.getAllFields()); ! String changeSupport = makeSupportField("changes", classMapping.getAllFields()); ! int fieldTypes = doFieldAccessors(classMapping, class2classmap, propWriter, vetoSupport, changeSupport); ! doSupportMethods(fieldTypes, vetoSupport, changeSupport, propWriter); ! doToString(classMapping, propWriter); ! doEqualsAndHashCode(classMapping, propWriter); ! propWriter.println("}"); + //insert change and VetoSupport + doSupports(fieldTypes, classMapping, vetoSupport, changeSupport, writer); + + writer.print(strPropWriter.toString()); // finally write the imports *************** *** 138,141 **** --- 166,230 ---- } + /** + * Method doSupportMethods. + * @param fieldTypes + * @param vetoSupport + * @param changeSupport + * @param propWriter + */ + private void doSupportMethods( + int fieldTypes, + String vetoSupport, + String changeSupport, + PrintWriter writer) { + if((fieldTypes&CONSTRAINT)==CONSTRAINT) { + writer.println(" public void addVetoableChangeListener( VetoableChangeListener l ) {"); + writer.println(" "+vetoSupport+".addVetoableChangeListener(l);"); + writer.println(" }"); + writer.println(" public void removeVetoableChangeListener( VetoableChangeListener l ) {"); + writer.println(" "+vetoSupport+".removeVetoableChangeListener(l);"); + writer.println(" }"); + writer.println(); + } + if((fieldTypes&BOUND)==BOUND) { + writer.println(" public void addPropertyChangeListener( PropertyChangeListener l ) {"); + writer.println(" "+changeSupport+".addPropertyChangeListener(l);"); + writer.println(" }"); + writer.println(" public void removePropertyChangeListener( PropertyChangeListener l ) {"); + writer.println(" "+changeSupport+".removePropertyChangeListener(l);"); + writer.println(" }"); + writer.println(); + } + } + + + /** + * Method doSupports. + * @param vetoSupport + * @param changeSupport + * @param writer + */ + private void doSupports( int fieldTypes, + ClassMapping classMapping, + String vetoSupport, + String changeSupport, + PrintWriter writer) { + if((fieldTypes&CONSTRAINT)==CONSTRAINT) { + writer.println( " private VetoableChangeSupport "+vetoSupport+ + " = new VetoableChangeSupport(this);" ); + classMapping.getImports().add("java.beans.VetoableChangeSupport"); + classMapping.getImports().add("java.beans.PropertyVetoException"); + classMapping.getImports().add("java.beans.VetoableChangeListener"); + } + if((fieldTypes&BOUND)==BOUND) { + writer.println( " private PropertyChangeSupport "+changeSupport+ + " = new PropertyChangeSupport(this);" ); + writer.println(); + classMapping.getImports().add("java.beans.PropertyChangeSupport"); + classMapping.getImports().add("java.beans.PropertyChangeListener"); + } + } + + public void doConstructors(ClassMapping classMapping, Map class2classmap, PrintWriter writer) { // full constructor *************** *** 293,298 **** } ! public void doFieldAccessors(ClassMapping classMapping, Map class2classmap, PrintWriter writer) { // field accessors for (Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { --- 382,418 ---- } + + static Map primitiveToObject = new HashMap(); + { + primitiveToObject.put("char", "Character"); + + primitiveToObject.put("byte", "Byte"); + primitiveToObject.put("short", "Short"); + primitiveToObject.put("int", "Integer"); + primitiveToObject.put("long", "Long"); + + primitiveToObject.put("boolean", "Boolean"); + + primitiveToObject.put("float", "Float"); + primitiveToObject.put("double", "Double"); + + } + private String getFieldAsObject(boolean prependThis, Field field) { + ClassName type = field.getClassType(); + if(type != null && type.isPrimitive() && !type.isArray()) { + String typeName = (String) primitiveToObject.get(type.getName()); + typeName = "new "+typeName+"( "; + typeName += prependThis ? "this." : ""; + return typeName+field.getName()+" )"; + } + return field.getName(); + } ! public int doFieldAccessors(ClassMapping classMapping, ! Map class2classmap, ! PrintWriter writer, ! String vetoSupport, ! String changeSupport) { ! int fieldTypes=ORDINARY; // field accessors for (Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { *************** *** 312,318 **** // setter String setAccessScope = getFieldScope(field, "scope-set", "public"); ! writer.println(" " + setAccessScope + " void set" + field.getAsSuffix() + StringHelper.OPEN_PAREN + getTrueTypeName(field, class2classmap) + " " + field.getName() + ") {"); writer.println(" this." + field.getName() + " = " + field.getName() + ";"); writer.println(" }"); writer.println(); --- 432,461 ---- // setter + int fieldType=0; + if(field.getMeta("beans-property-type")!=null) { + String beansPropertyType = field.getMetaAsString("beans-property-type").trim().toLowerCase(); + if(beansPropertyType.equals("constraint") ) { + fieldTypes = (fieldTypes | CONSTRAINT); + fieldType = CONSTRAINT; + } + else if(beansPropertyType.equals("bound") ) { + fieldTypes = (fieldTypes | BOUND); + fieldType = BOUND; + } + } String setAccessScope = getFieldScope(field, "scope-set", "public"); ! writer.print(" " + setAccessScope + " void set" + field.getAsSuffix() + StringHelper.OPEN_PAREN + getTrueTypeName(field, class2classmap) + " " + field.getName() + ")"); ! writer.println((fieldType&CONSTRAINT)==CONSTRAINT ? " throws PropertyVetoException {" : " {"); ! if((fieldType&CONSTRAINT)==CONSTRAINT) { ! writer.println(" "+vetoSupport+".fireVetoableChange(\""+field.getName()+"\","); ! writer.println(" "+getFieldAsObject(true, field)+","); ! writer.println(" "+getFieldAsObject(false, field)+");"); ! } writer.println(" this." + field.getName() + " = " + field.getName() + ";"); + if((fieldType&BOUND)==BOUND) { + writer.println(" "+changeSupport+".firePropertyChange(\""+field.getName()+"\","); + writer.println(" "+getFieldAsObject(true, field)+","); + writer.println(" "+getFieldAsObject(false, field)+");"); + } writer.println(" }"); writer.println(); *************** *** 353,356 **** --- 496,500 ---- */ } + return fieldTypes; } Index: ClassName.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java/ClassName.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ClassName.java 16 Jan 2003 20:52:38 -0000 1.4 --- ClassName.java 16 Feb 2003 12:49:02 -0000 1.5 *************** *** 2,6 **** package net.sf.hibernate.tool.hbm2java; - public class ClassName { private String fullyQualifiedName = null; --- 2,5 ---- *************** *** 9,62 **** private boolean primitive = false; private boolean isArray = false; ! public void setFullyQualifiedName(String fullyQualifiedName) { ! setFullyQualifiedName(fullyQualifiedName,false); } ! public void setFullyQualifiedName(String fullyQualifiedName, boolean isPrimitive) { this.fullyQualifiedName = fullyQualifiedName; primitive = isPrimitive; if (!isPrimitive) { ! if (fullyQualifiedName != null) { ! int lastDot = fullyQualifiedName.lastIndexOf("."); if (lastDot < 0) { name = fullyQualifiedName; packageName = null; ! } ! else { name = fullyQualifiedName.substring(lastDot + 1); packageName = fullyQualifiedName.substring(0, lastDot); } ! } ! else { name = fullyQualifiedName; packageName = null; } } } ! public String getFullyQualifiedName() { return this.fullyQualifiedName; } ! public String getPackageName() { return this.packageName; } ! public String getName() { return this.name; } ! public boolean inJavaLang() { return "java.lang".equals(packageName); } ! public boolean inSamePackage(ClassName other) { ! return other.packageName==this.packageName || ! ( other.packageName!=null && other.packageName.equals(this.packageName) ); } ! public boolean equals(Object other) { ClassName otherClassName = (ClassName) other; --- 8,63 ---- private boolean primitive = false; private boolean isArray = false; ! public void setFullyQualifiedName(String fullyQualifiedName) { ! setFullyQualifiedName(fullyQualifiedName, false); } ! public void setFullyQualifiedName(String fullyQualifiedName, boolean isPrimitive) { this.fullyQualifiedName = fullyQualifiedName; primitive = isPrimitive; if (!isPrimitive) { ! if (fullyQualifiedName != null) { ! int lastDot = fullyQualifiedName.lastIndexOf("."); if (lastDot < 0) { name = fullyQualifiedName; packageName = null; ! } else { name = fullyQualifiedName.substring(lastDot + 1); packageName = fullyQualifiedName.substring(0, lastDot); } ! } else { name = fullyQualifiedName; packageName = null; } + } else { + name = fullyQualifiedName; + packageName = null; } + } ! public String getFullyQualifiedName() { return this.fullyQualifiedName; } ! public String getPackageName() { return this.packageName; } ! public String getName() { return this.name; } ! public boolean inJavaLang() { return "java.lang".equals(packageName); } ! public boolean inSamePackage(ClassName other) { ! return other.packageName == this.packageName ! || (other.packageName != null && other.packageName.equals(this.packageName)); } ! public boolean equals(Object other) { ClassName otherClassName = (ClassName) other; *************** *** 75,79 **** */ public void setIsArray(boolean b) { ! isArray=b; } /** --- 76,80 ---- */ public void setIsArray(boolean b) { ! isArray = b; } /** *************** *** 85,97 **** } ! public String toString() { ! return getFullyQualifiedName(); ! } ! ! } ! ! ! ! ! --- 86,92 ---- } ! public String toString() { ! return getFullyQualifiedName(); ! } + } |
From: <one...@us...> - 2003-02-16 04:09:31
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv8207/reference/src Modified Files: basic_or_mapping.xml Log Message: added table attribute to example Index: basic_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/basic_or_mapping.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** basic_or_mapping.xml 1 Feb 2003 00:35:05 -0000 1.7 --- basic_or_mapping.xml 16 Feb 2003 04:09:28 -0000 1.8 *************** *** 989,993 **** <one-to-many class="eg.Cat"/> </set> ! <joined-subclass name="eg.DomesticCat"> <key column="CAT"/> <property name="name" type="string"/> --- 989,993 ---- <one-to-many class="eg.Cat"/> </set> ! <joined-subclass name="eg.DomesticCat" table="DOMESTIC_CATS"> <key column="CAT"/> <property name="name" type="string"/> |
From: <one...@us...> - 2003-02-16 01:55:10
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister In directory sc8-pr-cvs1:/tmp/cvs-serv7760/hibernate/persister Modified Files: AbstractEntityPersister.java Log Message: enable use of JDK IdentityHashMap in 1.4+ Index: AbstractEntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister/AbstractEntityPersister.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** AbstractEntityPersister.java 15 Feb 2003 08:00:50 -0000 1.13 --- AbstractEntityPersister.java 16 Feb 2003 01:55:06 -0000 1.14 *************** *** 32,35 **** --- 32,36 ---- import net.sf.hibernate.id.IdentityGenerator; import net.sf.hibernate.mapping.Column; + import net.sf.hibernate.mapping.Component; import net.sf.hibernate.mapping.PersistentClass; import net.sf.hibernate.mapping.Property; *************** *** 554,558 **** if ( idValue.isComposite() ) { ! iter = ( (net.sf.hibernate.mapping.Component) idValue ).getPropertyIterator(); while ( iter.hasNext() ) { --- 555,559 ---- if ( idValue.isComposite() ) { ! iter = ( (Component) idValue ).getPropertyIterator(); while ( iter.hasNext() ) { *************** *** 671,674 **** --- 672,676 ---- opt = MetaClass.getInstance( mappedClass.getClassLoader(), mappedClass, getterNames, setterNames, types ); opt.setPropertyValues( opt.newInstance(), opt.getPropertyValues( opt.newInstance() ) ); + //throw new NullPointerException(); } catch(Throwable t) { |