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-05-21 13:00:41
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader In directory sc8-pr-cvs1:/tmp/cvs-serv21077 Modified Files: Loader.java Log Message: minor change Index: Loader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/Loader.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Loader.java 21 May 2003 12:10:35 -0000 1.27 --- Loader.java 21 May 2003 13:00:37 -0000 1.28 *************** *** 136,147 **** final ResultSet rs = getResultSet(st, selection, session); - PersistentCollection rowCollection = null; - if (singleCollection) { - optionalCollection.beginRead(); - rowCollection = optionalCollection; - } - try { final Key[] keys = new Key[cols]; //we can reuse it each time --- 136,147 ---- final ResultSet rs = getResultSet(st, selection, session); try { + PersistentCollection rowCollection = null; + if (singleCollection) { + optionalCollection.beginRead(); + rowCollection = optionalCollection; + } + final Key[] keys = new Key[cols]; //we can reuse it each time |
From: <one...@us...> - 2003-05-21 12:13:43
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/transaction In directory sc8-pr-cvs1:/tmp/cvs-serv23115/hibernate/transaction Modified Files: WeblogicTransactionManagerLookup.java Log Message: changed the JNDI name Index: WeblogicTransactionManagerLookup.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/transaction/WeblogicTransactionManagerLookup.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WeblogicTransactionManagerLookup.java 25 Apr 2003 03:40:36 -0000 1.4 --- WeblogicTransactionManagerLookup.java 21 May 2003 12:13:40 -0000 1.5 *************** *** 12,16 **** */ protected String getName() { ! return "javax.transaction.TransactionCoordinator"; } --- 12,16 ---- */ protected String getName() { ! return "javax.transaction.TransactionManager"; } |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv20246/hibernate/impl Modified Files: BatcherImpl.java IteratorImpl.java ScrollableResultsImpl.java SessionFactoryImpl.java Log Message: * added default constructors for collection wrapperds * fixed some problems when using Hibernate PreparedStatementCache Index: BatcherImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/BatcherImpl.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** BatcherImpl.java 8 May 2003 10:51:31 -0000 1.5 --- BatcherImpl.java 21 May 2003 12:10:34 -0000 1.6 *************** *** 3,6 **** --- 3,7 ---- import java.sql.PreparedStatement; + import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashSet; *************** *** 33,36 **** --- 34,38 ---- private HashSet statementsToClose = new HashSet(); + private HashSet resultSetsToClose = new HashSet(); public BatcherImpl(SessionImplementor session) { *************** *** 56,68 **** } ! public void closeQueryStatement(PreparedStatement ps) throws SQLException { ! statementsToClose.remove(ps); ! logClose(); ! factory.closePreparedStatement(ps); } ! ! public void closeStatement(PreparedStatement ps) throws SQLException { ! logClose(); ! factory.closePreparedStatement(ps); } --- 58,76 ---- } ! public ResultSet getResultSet(PreparedStatement ps) throws SQLException { ! ResultSet rs = ps.executeQuery(); ! resultSetsToClose.add(rs); ! return rs; } ! ! public void closeQueryStatement(PreparedStatement ps, ResultSet rs) throws SQLException { ! statementsToClose.remove(ps); ! if (rs!=null) resultSetsToClose.remove(rs); ! try { ! if (rs!=null) rs.close(); ! } ! finally { ! closeQueryStatement(ps); ! } } *************** *** 89,97 **** } public void closeStatements() { ! Iterator iter = statementsToClose.iterator(); while ( iter.hasNext() ) { try { ! closeStatement( (PreparedStatement) iter.next() ); } catch (SQLException e) { --- 97,128 ---- } + public void closeStatement(PreparedStatement ps) throws SQLException { + logClose(); + factory.closePreparedStatement(ps); + } + + private void closeQueryStatement(PreparedStatement ps) throws SQLException { + logClose(); + factory.closeQueryStatement(ps); + } + public void closeStatements() { ! Iterator iter = resultSetsToClose.iterator(); while ( iter.hasNext() ) { try { ! ( (ResultSet) iter.next() ).close(); ! } ! catch (SQLException e) { ! // no big deal ! log.warn("Could not close a JDBC result set", e); ! } ! iter.remove(); ! } ! resultSetsToClose.clear(); ! ! iter = statementsToClose.iterator(); ! while ( iter.hasNext() ) { ! try { ! closeQueryStatement( (PreparedStatement) iter.next() ); } catch (SQLException e) { *************** *** 114,119 **** private static void logClose() { ! if ( log.isTraceEnabled() ) ! open--; } } --- 145,149 ---- private static void logClose() { ! if ( log.isTraceEnabled() ) open--; } } Index: IteratorImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/IteratorImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IteratorImpl.java 19 Apr 2003 03:26:07 -0000 1.4 --- IteratorImpl.java 21 May 2003 12:10:34 -0000 1.5 *************** *** 2,5 **** --- 2,6 ---- package net.sf.hibernate.impl; + import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; *************** *** 27,35 **** private boolean hasNext; private final String[][] names; ! public IteratorImpl(ResultSet rs, SessionImplementor sess, Type[] types, String[][] columnNames) throws HibernateException, SQLException { this.rs=rs; this.sess = sess; this.types = types; --- 28,38 ---- private boolean hasNext; private final String[][] names; + private final PreparedStatement ps; ! public IteratorImpl(ResultSet rs, PreparedStatement ps, SessionImplementor sess, Type[] types, String[][] columnNames) throws HibernateException, SQLException { this.rs=rs; + this.ps=ps; this.sess = sess; this.types = types; *************** *** 46,50 **** log.debug("exhausted results"); nextResults = null; ! rs.close(); } else { --- 49,53 ---- log.debug("exhausted results"); nextResults = null; ! sess.getBatcher().closeQueryStatement(ps, rs); //not absolutely necessary, but good } else { Index: ScrollableResultsImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/ScrollableResultsImpl.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ScrollableResultsImpl.java 8 May 2003 10:51:31 -0000 1.8 --- ScrollableResultsImpl.java 21 May 2003 12:10:34 -0000 1.9 *************** *** 5,8 **** --- 5,9 ---- import java.sql.Blob; import java.sql.Clob; + import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; *************** *** 27,30 **** --- 28,32 ---- private final ResultSet rs; + private final PreparedStatement ps; private final SessionImplementor sess; private final Type[] types; *************** *** 119,125 **** } ! public ScrollableResultsImpl(ResultSet rs, SessionImplementor sess, Type[] types) throws MappingException { this.rs=rs; this.sess = sess; this.types = types; --- 121,128 ---- } ! public ScrollableResultsImpl(ResultSet rs, PreparedStatement ps, SessionImplementor sess, Type[] types) throws MappingException { this.rs=rs; + this.ps=ps; this.sess = sess; this.types = types; *************** *** 268,272 **** public void close() throws HibernateException { try { ! rs.close(); } catch (SQLException sqle) { --- 271,275 ---- public void close() throws HibernateException { try { ! sess.getBatcher().closeQueryStatement(ps, rs); //not absolutely necessary } catch (SQLException sqle) { Index: SessionFactoryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionFactoryImpl.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** SessionFactoryImpl.java 20 May 2003 12:56:12 -0000 1.21 --- SessionFactoryImpl.java 21 May 2003 12:10:34 -0000 1.22 *************** *** 583,586 **** --- 583,602 ---- } + public void closeQueryStatement(PreparedStatement ps) throws SQLException { + if (statementCache!=null) { + statementCache.closeQueryStatement(ps); + } + else { + try { + log.trace("closing query statement"); + ps.close(); + } + catch (SQLException sqle) { + JDBCExceptionReporter.logExceptions(sqle); + throw sqle; + } + } + } + public boolean useJdbcBatch() { return jdbcBatchSize>0; |
From: <one...@us...> - 2003-05-21 12:10:40
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/engine In directory sc8-pr-cvs1:/tmp/cvs-serv20246/hibernate/engine Modified Files: Batcher.java SessionFactoryImplementor.java Log Message: * added default constructors for collection wrapperds * fixed some problems when using Hibernate PreparedStatementCache Index: Batcher.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/engine/Batcher.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Batcher.java 25 Apr 2003 03:40:32 -0000 1.4 --- Batcher.java 21 May 2003 12:10:34 -0000 1.5 *************** *** 3,6 **** --- 3,7 ---- import java.sql.PreparedStatement; + import java.sql.ResultSet; import java.sql.SQLException; *************** *** 27,32 **** * Close a prepared statement opened with <tt>prepareQueryStatement()</tt> */ ! public void closeQueryStatement(PreparedStatement ps) throws SQLException; ! /** * Get a non-batchable prepared statement to use for inserting / deleting / updating. --- 28,33 ---- * Close a prepared statement opened with <tt>prepareQueryStatement()</tt> */ ! public void closeQueryStatement(PreparedStatement ps, ResultSet rs) throws SQLException; ! /** * Get a non-batchable prepared statement to use for inserting / deleting / updating. *************** *** 61,64 **** --- 62,66 ---- */ public void closeStatements(); + public ResultSet getResultSet(PreparedStatement ps) throws SQLException; } Index: SessionFactoryImplementor.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/engine/SessionFactoryImplementor.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SessionFactoryImplementor.java 25 Apr 2003 03:40:32 -0000 1.9 --- SessionFactoryImplementor.java 21 May 2003 12:10:34 -0000 1.10 *************** *** 92,95 **** --- 92,99 ---- /** + * Dispose of a query prepared statement + */ + public void closeQueryStatement(PreparedStatement ps) throws SQLException; + /** * Obtain a prepared statement */ |
From: <one...@us...> - 2003-05-21 12:10:40
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection In directory sc8-pr-cvs1:/tmp/cvs-serv20246/hibernate/collection Modified Files: Bag.java IdentifierBag.java List.java Map.java ODMGCollection.java PersistentCollection.java Set.java SortedMap.java SortedSet.java Log Message: * added default constructors for collection wrapperds * fixed some problems when using Hibernate PreparedStatementCache Index: Bag.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/Bag.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Bag.java 2 May 2003 09:14:29 -0000 1.13 --- Bag.java 21 May 2003 12:10:33 -0000 1.14 *************** *** 51,54 **** --- 51,56 ---- } + public Bag() {} //needed for SOAP libraries, etc + /** * @see net.sf.hibernate.collections.PersistentCollection#elements() Index: IdentifierBag.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/IdentifierBag.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IdentifierBag.java 2 May 2003 09:14:29 -0000 1.1 --- IdentifierBag.java 21 May 2003 12:10:33 -0000 1.2 *************** *** 38,41 **** --- 38,43 ---- } + public IdentifierBag() {} //needed for SOAP libraries, etc + public IdentifierBag(SessionImplementor session, java.util.Collection coll) { super(session); Index: List.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/List.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** List.java 2 May 2003 09:14:30 -0000 1.14 --- List.java 21 May 2003 12:10:33 -0000 1.15 *************** *** 64,67 **** --- 64,69 ---- } + public List() {} //needed for SOAP libraries, etc + /** * @see List#size() Index: Map.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/Map.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Map.java 2 May 2003 09:14:30 -0000 1.14 --- Map.java 21 May 2003 12:10:33 -0000 1.15 *************** *** 55,58 **** --- 55,60 ---- } + public Map() {} //needed for SOAP libraries, etc + public void beforeInitialize(CollectionPersister persister) { this.map = persister.hasOrdering() ? LinkedHashCollectionHelper.createLinkedHashMap() : new HashMap(); Index: ODMGCollection.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/ODMGCollection.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ODMGCollection.java 20 May 2003 12:56:08 -0000 1.9 --- ODMGCollection.java 21 May 2003 12:10:33 -0000 1.10 *************** *** 20,31 **** public abstract class ODMGCollection extends PersistentCollection implements DCollection { - /** - * Constructor for ODMGCollection. - * @param session - */ public ODMGCollection(SessionImplementor session) { super(session); } /** * @see org.odmg.DCollection#existsElement(String) --- 20,29 ---- public abstract class ODMGCollection extends PersistentCollection implements DCollection { public ODMGCollection(SessionImplementor session) { super(session); } + public ODMGCollection() {} //needed for SOAP libraries, etc + /** * @see org.odmg.DCollection#existsElement(String) Index: PersistentCollection.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/PersistentCollection.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PersistentCollection.java 20 May 2003 12:56:08 -0000 1.16 --- PersistentCollection.java 21 May 2003 12:10:34 -0000 1.17 *************** *** 111,114 **** --- 111,120 ---- throw new AssertionFailure("Collection does not support delayed initialization"); } + + /** + * Not called by Hibernate, but used by non-JDK serialization, + * eg SOAP libraries. + */ + public PersistentCollection() {} protected PersistentCollection(SessionImplementor session) { Index: Set.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/Set.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Set.java 20 May 2003 12:56:09 -0000 1.15 --- Set.java 21 May 2003 12:10:34 -0000 1.16 *************** *** 62,65 **** --- 62,67 ---- } + public Set() {} //needed for SOAP libraries, etc + public void beforeInitialize(CollectionPersister persister) { this.set = persister.hasOrdering() ? Index: SortedMap.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/SortedMap.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SortedMap.java 25 Apr 2003 03:40:31 -0000 1.9 --- SortedMap.java 21 May 2003 12:10:34 -0000 1.10 *************** *** 70,73 **** --- 70,75 ---- } + public SortedMap() {} //needed for SOAP libraries, etc + /** * @see SortedMap#comparator() Index: SortedSet.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/SortedSet.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SortedSet.java 25 Apr 2003 03:40:31 -0000 1.10 --- SortedSet.java 21 May 2003 12:10:34 -0000 1.11 *************** *** 51,54 **** --- 51,56 ---- } + public SortedSet() {} //needed for SOAP libraries, etc + /** * @see SortedSet#comparator() |
From: <one...@us...> - 2003-05-21 12:10:39
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/ps In directory sc8-pr-cvs1:/tmp/cvs-serv20246/hibernate/ps Modified Files: PreparedStatementCache.java Log Message: * added default constructors for collection wrapperds * fixed some problems when using Hibernate PreparedStatementCache Index: PreparedStatementCache.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/ps/PreparedStatementCache.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PreparedStatementCache.java 25 Apr 2003 03:40:36 -0000 1.8 --- PreparedStatementCache.java 21 May 2003 12:10:35 -0000 1.9 *************** *** 98,101 **** --- 98,120 ---- } + public void closeQueryStatement(PreparedStatement ps) { + + try { + if ( ps.getMaxRows()!=0 ) ps.setMaxRows(0); + if ( ps.getQueryTimeout()!=0 ) ps.setQueryTimeout(0); + } + catch (Exception e) { + log.warn("could not close statement", e); + try { + ps.close(); + } + catch (SQLException sqle) { + log.warn("could not close statement", sqle); + } + } + + closePreparedStatement(ps); + } + public void closePreparedStatement(PreparedStatement ps) { |
From: <one...@us...> - 2003-05-21 12:10:39
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv20246/hibernate/test Modified Files: FooBarTest.java Log Message: * added default constructors for collection wrapperds * fixed some problems when using Hibernate PreparedStatementCache Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** FooBarTest.java 20 May 2003 12:56:14 -0000 1.67 --- FooBarTest.java 21 May 2003 12:10:35 -0000 1.68 *************** *** 86,89 **** --- 86,90 ---- public void testQueryLockMode() throws Exception { + Session s = sessions.openSession(); Bar bar = new Bar(); *************** *** 134,137 **** --- 135,139 ---- public void testManyToManyBag() throws Exception { + Session s = sessions.openSession(); Baz baz = new Baz(); *************** *** 152,156 **** assertTrue( !Hibernate.isInitialized( baz.getFooBag() ) ); assertTrue( baz.getFooBag().size()==1 ); ! assertTrue( Hibernate.isInitialized( baz.getFooBag().iterator().next() ) ); s.delete(baz); s.flush(); --- 154,158 ---- assertTrue( !Hibernate.isInitialized( baz.getFooBag() ) ); assertTrue( baz.getFooBag().size()==1 ); ! if ( !(dialect instanceof HSQLDialect) ) assertTrue( Hibernate.isInitialized( baz.getFooBag().iterator().next() ) ); s.delete(baz); s.flush(); |
From: <one...@us...> - 2003-05-21 12:10:39
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader In directory sc8-pr-cvs1:/tmp/cvs-serv20246/hibernate/loader Modified Files: Loader.java Log Message: * added default constructors for collection wrapperds * fixed some problems when using Hibernate PreparedStatementCache Index: Loader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/Loader.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** Loader.java 20 May 2003 12:56:14 -0000 1.26 --- Loader.java 21 May 2003 12:10:35 -0000 1.27 *************** *** 187,196 **** } finally { ! try { ! rs.close(); ! } ! finally { ! closePreparedStatement(st, selection, session); ! } } --- 187,191 ---- } finally { ! closeQueryStatement(st, rs, session); } *************** *** 426,430 **** StringHelper.unQuoteInPlace(cols); ! values[i] = types[i].hydrate( rs, cols, session, object ); } return values; --- 421,425 ---- StringHelper.unQuoteInPlace(cols); ! values[i] = types[i].hydrate(rs, cols, session, object); } return values; *************** *** 491,496 **** try { - if (selection!=null && selection.getTimeout()!=null) st.setQueryTimeout( selection.getTimeout().intValue() ); - int col=1; for ( int i=0; i<values.length; i++) { --- 486,489 ---- *************** *** 502,513 **** if (useLimit) bindPagingSelectParameters(st, col, selection, session); } catch (SQLException sqle) { JDBCExceptionReporter.logExceptions(sqle); ! closePreparedStatement(st, selection, session); throw sqle; } catch (HibernateException he) { ! closePreparedStatement(st, selection, session); throw he; } --- 495,509 ---- if (useLimit) bindPagingSelectParameters(st, col, selection, session); + if (!useLimit) setMaxRows(st, selection); + if (selection!=null && selection.getTimeout()!=null) + st.setQueryTimeout( selection.getTimeout().intValue() ); } catch (SQLException sqle) { JDBCExceptionReporter.logExceptions(sqle); ! closeQueryStatement(st, null, session); throw sqle; } catch (HibernateException he) { ! closeQueryStatement(st, null, session); throw he; } *************** *** 541,570 **** throws SQLException, HibernateException { ! boolean useLimit = useLimit(selection, session); ! ! try { ! if (!useLimit) setMaxRows(st, selection); ! ResultSet rs = st.executeQuery(); ! if (!useLimit) advance(rs, selection, session); return rs; } catch (SQLException sqle) { JDBCExceptionReporter.logExceptions(sqle); ! closePreparedStatement(st, selection, session); throw sqle; } } ! protected final void closePreparedStatement(PreparedStatement st, RowSelection selection, SessionImplementor session) throws SQLException, HibernateException { ! try { ! if (selection!=null) { ! if (selection.getMaxRows()!=null) st.setMaxRows(0); ! if (selection.getTimeout()!=null) st.setQueryTimeout(0); ! } ! } ! finally { ! session.getBatcher().closeQueryStatement(st); ! } } --- 537,556 ---- throws SQLException, HibernateException { ! ResultSet rs = null; ! try { ! rs = session.getBatcher().getResultSet(st); ! if ( !useLimit(selection, session) ) advance(rs, selection, session); return rs; } catch (SQLException sqle) { JDBCExceptionReporter.logExceptions(sqle); ! closeQueryStatement(st, rs, session); throw sqle; } } ! protected final void closeQueryStatement(PreparedStatement st, ResultSet rs, SessionImplementor session) throws SQLException, HibernateException { ! session.getBatcher().closeQueryStatement(st, rs); } |
From: <one...@us...> - 2003-05-21 12:10:39
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql In directory sc8-pr-cvs1:/tmp/cvs-serv20246/hibernate/hql Modified Files: QueryTranslator.java Log Message: * added default constructors for collection wrapperds * fixed some problems when using Hibernate PreparedStatementCache Index: QueryTranslator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql/QueryTranslator.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** QueryTranslator.java 20 May 2003 12:56:12 -0000 1.31 --- QueryTranslator.java 21 May 2003 12:10:34 -0000 1.32 *************** *** 772,776 **** ); ResultSet rs = getResultSet(st, selection, session); ! return new IteratorImpl( rs, session, getReturnTypes(), getScalarColumnNames() ); } --- 772,776 ---- ); ResultSet rs = getResultSet(st, selection, session); ! return new IteratorImpl( rs, st, session, getReturnTypes(), getScalarColumnNames() ); } *************** *** 783,787 **** ); ResultSet rs = getResultSet(st, selection, session); ! return new ScrollableResultsImpl( rs, session, getReturnTypes() ); } --- 783,787 ---- ); ResultSet rs = getResultSet(st, selection, session); ! return new ScrollableResultsImpl( rs, st, session, getReturnTypes() ); } |
From: <one...@us...> - 2003-05-20 12:56:45
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql In directory sc8-pr-cvs1:/tmp/cvs-serv27564/hibernate/hql Modified Files: FromParser.java QueryTranslator.java Log Message: added fetch keyword to HQL added evict() methods to SessionFactory for JVM-level cache destroy caches from SessionFactory.close() Index: FromParser.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql/FromParser.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** FromParser.java 7 May 2003 15:09:04 -0000 1.12 --- FromParser.java 20 May 2003 12:56:11 -0000 1.13 *************** *** 29,32 **** --- 29,33 ---- private Queryable classPersister; private int joinType; + private boolean afterFetch; private static final int NONE = -666; *************** *** 59,62 **** --- 60,70 ---- } } + else if ( lcToken.equals("fetch") ) { + if ( q.isShallowQuery() ) throw new QueryException("fetch may not be used with scroll() or iterate()"); + if (joinType==NONE) throw new QueryException("unexpected token: fetch"); + if (joinType==JoinFragment.FULL_JOIN || joinType==JoinFragment.RIGHT_OUTER_JOIN) + throw new QueryException("fetch may only be used with inner join or left outer join"); + afterFetch = true; + } else if ( lcToken.equals("outer") ) { // 'outer' is optional and is ignored *************** *** 181,189 **** } else { ! entityName = peParser.addFromAssociation(q); } ! expectingAs = true; joinType = NONE; peParser.setJoinType(JoinFragment.INNER_JOIN); } } --- 189,217 ---- } else { ! entityName = peParser.addFromAssociation(q); } ! joinType = NONE; peParser.setJoinType(JoinFragment.INNER_JOIN); + + if (afterFetch) { + + if ( peParser.isCollectionValued() ) { + //TODO: is this correct for many-to-manys? NO! entityName is wrong! + q.setCollectionToFetch( peParser.getCollectionRole(), peParser.getCollectionName() ); + } + q.addEntityToFetch(entityName); + + afterAs = false; + afterFetch = false; + expectingJoin = true; + expectingAs = false; + entityName = null; + classPersister = null; + } + else { + expectingAs = true; + } + } } Index: QueryTranslator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql/QueryTranslator.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** QueryTranslator.java 18 May 2003 15:45:13 -0000 1.30 --- QueryTranslator.java 20 May 2003 12:56:12 -0000 1.31 *************** *** 70,76 **** --- 70,79 ---- private final List groupByTokens = new ArrayList(); private final Set identifierSpaces = new HashSet(); + private final Set entitiesToFetch = new HashSet(); private Queryable[] persisters; private String[] names; + private boolean[] includeInSelect; + private int selectLength; private Type[] types; private String[][] scalarColumnNames; *************** *** 89,92 **** --- 92,98 ---- private QueryTranslator superQuery; + private CollectionPersister collectionPersister; + private String fetchName; + private String[] suffixes; *************** *** 210,213 **** --- 216,223 ---- } + void addEntityToFetch(String name) { + entitiesToFetch.add(name); + } + protected String getSQLString() { logQuery(queryString, sqlString); *************** *** 410,416 **** --- 420,435 ---- private void renderSQL() throws QueryException, MappingException { + final int rtsize; if ( returnTypes.size()==0 && scalarTypes.size()==0 ) { //ie no select clause in HQL returnTypes = fromTypes; + rtsize = returnTypes.size(); + } + else { + rtsize = returnTypes.size(); + Iterator iter = entitiesToFetch.iterator(); + while ( iter.hasNext() ) { + returnTypes.add( iter.next() ); + } } int size = returnTypes.size(); *************** *** 418,427 **** names = new String[size]; suffixes = new String[size]; for ( int i=0; i<size; i++ ) { String name = (String) returnTypes.get(i); //if ( !isName(name) ) throw new QueryException("unknown type: " + name); persisters[i] = getPersisterForName(name); names[i] = name; ! suffixes[i] = (size==1) ? StringHelper.EMPTY_STRING : Integer.toString(i) + StringHelper.UNDERSCORE; } --- 437,451 ---- names = new String[size]; suffixes = new String[size]; + includeInSelect = new boolean[size]; for ( int i=0; i<size; i++ ) { String name = (String) returnTypes.get(i); //if ( !isName(name) ) throw new QueryException("unknown type: " + name); persisters[i] = getPersisterForName(name); + suffixes[i] = (size==1) ? + StringHelper.EMPTY_STRING : + Integer.toString(i) + StringHelper.UNDERSCORE; names[i] = name; ! includeInSelect[i] = !entitiesToFetch.contains(name); ! if ( includeInSelect[i] ) selectLength++; } *************** *** 429,433 **** int scalarSize = scalarTypes.size(); ! hasScalars = scalarTypes.size()!=size; types = new Type[scalarSize]; --- 453,457 ---- int scalarSize = scalarTypes.size(); ! hasScalars = scalarTypes.size()!=rtsize; //TODO: VERY WRONG!!! types = new Type[scalarSize]; *************** *** 444,447 **** --- 468,475 ---- } + if ( collectionPersister!=null ) { + sql.addSelectFragmentString( collectionPersister.multiselectClauseFragment(fetchName) ); + } + if ( hasScalars || shallowQuery ) sql.addSelectFragmentString(scalarSelect); *************** *** 646,651 **** } protected CollectionPersister getCollectionPersister() { ! return null; } --- 674,687 ---- } + /** + * Overrides method from Loader + */ protected CollectionPersister getCollectionPersister() { ! return collectionPersister; ! } ! ! void setCollectionToFetch(String role, String name) throws QueryException { ! fetchName = name; ! collectionPersister = getCollectionPersister(role); } *************** *** 863,866 **** --- 899,903 ---- protected Object getResultColumnOrRow(Object[] row, ResultSet rs, SessionImplementor session) throws SQLException, HibernateException { Type[] returnTypes = getReturnTypes(); + row = toResultRow(row); if (hasScalars) { String[][] names = getScalarColumnNames(); *************** *** 885,888 **** --- 922,939 ---- catch (Exception e) { throw new QueryException("could not instantiate: " + holderClass, e); + } + } + + private Object[] toResultRow(Object[] row) { + if (selectLength==row.length) { + return row; + } + else { + Object[] result = new Object[selectLength]; + int j=0; + for (int i=0; i<row.length; i++) { + if ( includeInSelect[i] ) result[j++] = row[i]; + } + return result; } } |
From: <one...@us...> - 2003-05-20 12:56:45
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/engine In directory sc8-pr-cvs1:/tmp/cvs-serv27564/hibernate/engine Modified Files: SessionImplementor.java Log Message: added fetch keyword to HQL added evict() methods to SessionFactory for JVM-level cache destroy caches from SessionFactory.close() Index: SessionImplementor.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/engine/SessionImplementor.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** SessionImplementor.java 18 May 2003 15:45:13 -0000 1.13 --- SessionImplementor.java 20 May 2003 12:56:11 -0000 1.14 *************** *** 68,71 **** --- 68,75 ---- public boolean isInverseCollection(PersistentCollection collection); + public PersistentCollection getLoadingCollection(CollectionPersister persister, Serializable id) throws HibernateException; + public PersistentCollection getLoadingCollection(String role, Serializable id); + public void endLoadingCollections(CollectionPersister persister) throws HibernateException; + /** * Load an instance without checking if it was deleted. If it does not exist, throw an exception. |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection In directory sc8-pr-cvs1:/tmp/cvs-serv27564/hibernate/collection Modified Files: CollectionPersister.java ODMGCollection.java PersistentCollection.java Set.java Log Message: added fetch keyword to HQL added evict() methods to SessionFactory for JVM-level cache destroy caches from SessionFactory.close() Index: CollectionPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/CollectionPersister.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** CollectionPersister.java 2 May 2003 09:14:29 -0000 1.22 --- CollectionPersister.java 20 May 2003 12:56:08 -0000 1.23 *************** *** 76,82 **** --- 76,84 ---- private final String[] unquotedIndexColumnNames; private final String[] unquotedElementColumnNames; + private final String[] unquotedKeyColumnNames; private String[] rowSelectColumnNames; //TODO: make final again private final String[] indexColumnAliases; private final String[] elementColumnAliases; + private final String[] keyColumnAliases; private Type rowSelectType; //TODO: make final again private final boolean primitiveArray; *************** *** 113,116 **** --- 115,119 ---- role = collection.getRole(); ownerClass = collection.getOwnerClass(); + Alias alias = new Alias("__"); sqlOrderByString = collection.getOrderBy(); *************** *** 125,134 **** --- 128,141 ---- int span = collection.getKey().getColumnSpan(); keyColumnNames = new String[span]; + String[] keyAliases = new String[span]; int k=0; while ( iter.hasNext() ) { Column col = ( (Column) iter.next() ); keyColumnNames[k] = col.getName(); + keyAliases[k] = col.getAlias(); k++; } + keyColumnAliases = alias.toAliasStrings(keyAliases); + unquotedKeyColumnNames = StringHelper.unQuote(keyColumnAliases); //isSet = collection.isSet(); *************** *** 167,175 **** } - Alias alias = new Alias("__"); elementColumnAliases = alias.toAliasStrings(aliases); unquotedElementColumnNames = StringHelper.unQuote(elementColumnAliases); - if ( hasIndex = collection.isIndexed() ) { IndexedCollection indexedMap = (IndexedCollection) collection; --- 174,180 ---- *************** *** 256,259 **** --- 261,272 ---- } + public CacheConcurrencyStrategy getCache() { + return cache; + } + + public boolean hasCache() { + return cache!=null; + } + public PersistentCollection getCachedCollection(Serializable id, Object owner, SessionImplementor s) throws HibernateException { if (cache==null) { *************** *** 279,282 **** --- 292,299 ---- } + public PersistentCollectionType getType() { + return collectionType; + } + private static final java.util.Set keywords = new HashSet(); static { *************** *** 382,385 **** --- 399,406 ---- } + public Object readKey(ResultSet rs, SessionImplementor session) throws HibernateException, SQLException { + return getKeyType().nullSafeGet(rs, unquotedKeyColumnNames, session, null); + } + public void writeElement(PreparedStatement st, Object elt, boolean writeOrder, SessionImplementor session) throws HibernateException, SQLException { *************** *** 428,431 **** --- 449,466 ---- .setSuffix(StringHelper.EMPTY_STRING) .addColumns(alias, elementColumnNames, elementColumnAliases); + if (hasIndex) frag.addColumns(alias, indexColumnNames, indexColumnAliases); + if (hasIdentifier) frag.addColumn(alias, identifierColumnName, identifierColumnAlias); + return frag.toFragmentString() + .substring(2); //strip leading ',' + } + + /** + * Generate a list of collection index, key and element columns + */ + public String multiselectClauseFragment(String alias) { + SelectFragment frag = new SelectFragment() + .setSuffix(StringHelper.EMPTY_STRING) + .addColumns(alias, elementColumnNames, elementColumnAliases) + .addColumns(alias, keyColumnNames, keyColumnAliases); if (hasIndex) frag.addColumns(alias, indexColumnNames, indexColumnAliases); if (hasIdentifier) frag.addColumn(alias, identifierColumnName, identifierColumnAlias); Index: ODMGCollection.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/ODMGCollection.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ODMGCollection.java 25 Apr 2003 03:40:31 -0000 1.8 --- ODMGCollection.java 20 May 2003 12:56:08 -0000 1.9 *************** *** 32,38 **** */ public boolean existsElement(String queryString) throws QueryInvalidException { ! return select(queryString).hasNext(); ! //TODO: when we can use scalars in a filter, use: ! /*try { return ( (Integer) session.filter( this, "select count(*) " + queryString ).iterator().next() ).intValue() > 0; } --- 32,37 ---- */ public boolean existsElement(String queryString) throws QueryInvalidException { ! //return select(queryString).hasNext(); ! try { return ( (Integer) session.filter( this, "select count(*) " + queryString ).iterator().next() ).intValue() > 0; } *************** *** 40,46 **** throw new QueryInvalidException( he.getMessage() ); } - catch (SQLException sqle) { - throw new QueryInvalidException( sqle.getMessage() ); - }*/ } --- 39,42 ---- Index: PersistentCollection.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/PersistentCollection.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PersistentCollection.java 2 May 2003 09:14:30 -0000 1.15 --- PersistentCollection.java 20 May 2003 12:56:08 -0000 1.16 *************** *** 127,130 **** --- 127,131 ---- public Object getCachedValue() { + initialized = true; //TODO: only needed for query FETCH, so should move out of here return this; } Index: Set.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/collection/Set.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Set.java 2 May 2003 09:14:30 -0000 1.14 --- Set.java 20 May 2003 12:56:09 -0000 1.15 *************** *** 63,67 **** public void beforeInitialize(CollectionPersister persister) { ! this.set = persister.hasOrdering() ? LinkedHashCollectionHelper.createLinkedHashSet() : new HashSet(); } public Set(SessionImplementor session, java.util.Set set) { --- 63,69 ---- public void beforeInitialize(CollectionPersister persister) { ! this.set = persister.hasOrdering() ? ! LinkedHashCollectionHelper.createLinkedHashSet() : ! new HashSet(); } public Set(SessionImplementor session, java.util.Set set) { |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache In directory sc8-pr-cvs1:/tmp/cvs-serv27564/hibernate/cache Modified Files: Cache.java CacheConcurrencyStrategy.java CacheTest.java JCSCache.java NonstrictReadWriteCache.java ReadOnlyCache.java ReadWriteCache.java Log Message: added fetch keyword to HQL added evict() methods to SessionFactory for JVM-level cache destroy caches from SessionFactory.close() Index: Cache.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/Cache.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Cache.java 2 Feb 2003 00:29:06 -0000 1.4 --- Cache.java 20 May 2003 12:56:07 -0000 1.5 *************** *** 8,12 **** public interface Cache { /** ! * Get some cached data * @param key * @return the cached object or <tt>null</tt> --- 8,12 ---- public interface Cache { /** ! * Get an item from the cache * @param key * @return the cached object or <tt>null</tt> *************** *** 15,19 **** public Object get(Object key) throws CacheException; /** ! * Cache some data * @param key * @param value --- 15,19 ---- public Object get(Object key) throws CacheException; /** ! * Add an item to the cache * @param key * @param value *************** *** 22,30 **** public void put(Object key, Object value) throws CacheException; /** ! * Set the period after which data expires ! * @param timeout period in milliseconds ! * @deprecated not needed for JCS */ ! public void setTimeout(int timeout); /** * Set the cache region name --- 22,36 ---- public void put(Object key, Object value) throws CacheException; /** ! * Remove an item from the cache */ ! public void remove(Object key) throws CacheException; ! /** ! * Clear the cache ! */ ! public void clear() throws CacheException; ! /** ! * Clean up ! */ ! public void destroy() throws CacheException; /** * Set the cache region name Index: CacheConcurrencyStrategy.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/CacheConcurrencyStrategy.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CacheConcurrencyStrategy.java 5 Jan 2003 02:11:20 -0000 1.3 --- CacheConcurrencyStrategy.java 20 May 2003 12:56:08 -0000 1.4 *************** *** 38,42 **** */ public void release(Object key) throws CacheException; ! } --- 38,44 ---- */ public void release(Object key) throws CacheException; ! public void remove(Object key) throws CacheException; ! public void clear() throws CacheException; ! public void destroy(); } Index: CacheTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/CacheTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CacheTest.java 2 Feb 2003 00:29:06 -0000 1.5 --- CacheTest.java 20 May 2003 12:56:08 -0000 1.6 *************** *** 25,29 **** cache.setRegion( String.class.getName() ); ! cache.setTimeout(1000); CacheConcurrencyStrategy ccs = new ReadWriteCache(cache); --- 25,29 ---- cache.setRegion( String.class.getName() ); ! //cache.setTimeout(1000); CacheConcurrencyStrategy ccs = new ReadWriteCache(cache); Index: JCSCache.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/JCSCache.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** JCSCache.java 2 Feb 2003 00:29:06 -0000 1.4 --- JCSCache.java 20 May 2003 12:56:08 -0000 1.5 *************** *** 42,46 **** } ! public void setTimeout(int timeout) { } } --- 42,75 ---- } ! public void remove(Object key) throws CacheException { ! try { ! region.remove(key); ! } ! catch (org.apache.jcs.access.exception.CacheException e) { ! log.error("could not remove from JCS region", e); ! throw new CacheException(e); ! } ! } ! ! public void clear() throws CacheException { ! try { ! region.remove(); ! } ! catch (org.apache.jcs.access.exception.CacheException e) { ! log.error("could not remove from JCS region", e); ! throw new CacheException(e); ! } ! } ! ! public void destroy() throws CacheException { ! try { ! region.destroy(); ! } ! catch (org.apache.jcs.access.exception.CacheException e) { ! log.error("could not destroy JCS region", e); ! throw new CacheException(e); ! } ! } ! } Index: NonstrictReadWriteCache.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/NonstrictReadWriteCache.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NonstrictReadWriteCache.java 10 Apr 2003 09:49:15 -0000 1.2 --- NonstrictReadWriteCache.java 20 May 2003 12:56:08 -0000 1.3 *************** *** 60,63 **** --- 60,82 ---- cache.put( key, new Long( Timestamper.next() / Timestamper.ONE_MS ) ); } + + public void remove(Object key) throws CacheException { + if ( log.isDebugEnabled() ) log.debug("Removing: " + key); + cache.remove(key); + } + + public void clear() throws CacheException { + if ( log.isDebugEnabled() ) log.debug("Clearing"); + cache.clear(); + } + + public void destroy() { + try { + cache.destroy(); + } + catch (Exception e) { + log.warn("could not destroy cache", e); + } + } } Index: ReadOnlyCache.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/ReadOnlyCache.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ReadOnlyCache.java 4 Apr 2003 13:51:59 -0000 1.4 --- ReadOnlyCache.java 20 May 2003 12:56:08 -0000 1.5 *************** *** 40,43 **** --- 40,61 ---- } + public void clear() throws CacheException { + cache.clear(); + } + + public void remove(Object key) throws CacheException { + cache.remove(key); + } + + public void destroy() { + try { + cache.destroy(); + } + catch (Exception e) { + log.warn("could not destroy cache", e); + } + } + + } Index: ReadWriteCache.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cache/ReadWriteCache.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ReadWriteCache.java 5 Jan 2003 02:11:20 -0000 1.3 --- ReadWriteCache.java 20 May 2003 12:56:08 -0000 1.4 *************** *** 87,90 **** --- 87,108 ---- } + public void clear() throws CacheException { + cache.clear(); + } + + public void remove(Object key) throws CacheException { + cache.remove(key); + } + + public void destroy() { + try { + cache.destroy(); + } + catch (Exception e) { + log.warn("could not destroy cache", e); + } + } + + } |
From: <one...@us...> - 2003-05-20 12:56:42
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv27564/hibernate Modified Files: SessionFactory.java Log Message: added fetch keyword to HQL added evict() methods to SessionFactory for JVM-level cache destroy caches from SessionFactory.close() Index: SessionFactory.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/SessionFactory.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SessionFactory.java 25 Apr 2003 03:40:30 -0000 1.9 --- SessionFactory.java 20 May 2003 12:56:07 -0000 1.10 *************** *** 105,114 **** /** ! * 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; } --- 105,139 ---- /** ! * Destroy this <tt>SessionFactory</tt> and release all resources (caches, ! * 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; + + /** + * Evict all entries from the process-level JCS cache. This method occurs outside + * of any transaction; it performs an immediate "hard" remove, so does not respect + * any transaction isolation semantics of the usage strategy. Use with care. + */ + public void evict(Class persistentClass) throws HibernateException; + /** + * Evict an entry from the process-level JCS cache. This method occurs outside + * of any transaction; it performs an immediate "hard" remove, so does not respect + * any transaction isolation semantics of the usage strategy. Use with care. + */ + public void evict(Class persistentClass, Serializable id) throws HibernateException; + /** + * Evict all entries from the process-level JCS cache. This method occurs outside + * of any transaction; it performs an immediate "hard" remove, so does not respect + * any transaction isolation semantics of the usage strategy. Use with care. + */ + public void evictCollection(String roleName) throws HibernateException; + /** + * Evict an entry from the process-level JCS cache. This method occurs outside + * of any transaction; it performs an immediate "hard" remove, so does not respect + * any transaction isolation semantics of the usage strategy. Use with care. + */ + public void evictCollection(String roleName, Serializable id) throws HibernateException; } |
From: <one...@us...> - 2003-05-20 12:56:19
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type In directory sc8-pr-cvs1:/tmp/cvs-serv27564/hibernate/type Modified Files: ArrayType.java BagType.java IdentifierBagType.java ListType.java MapType.java PersistentCollectionType.java SetType.java SortedMapType.java SortedSetType.java Log Message: added fetch keyword to HQL added evict() methods to SessionFactory for JVM-level cache destroy caches from SessionFactory.close() Index: ArrayType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/ArrayType.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ArrayType.java 8 May 2003 10:52:40 -0000 1.9 --- ArrayType.java 20 May 2003 12:56:14 -0000 1.10 *************** *** 30,34 **** } ! protected PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister) throws HibernateException { return new ArrayHolder(session, persister); } --- 30,34 ---- } ! public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister) throws HibernateException { return new ArrayHolder(session, persister); } Index: BagType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/BagType.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** BagType.java 6 Apr 2003 10:11:12 -0000 1.8 --- BagType.java 20 May 2003 12:56:15 -0000 1.9 *************** *** 16,20 **** } ! protected PersistentCollection instantiate( SessionImplementor session, CollectionPersister persister) --- 16,20 ---- } ! public PersistentCollection instantiate( SessionImplementor session, CollectionPersister persister) Index: IdentifierBagType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/IdentifierBagType.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IdentifierBagType.java 2 May 2003 09:17:13 -0000 1.1 --- IdentifierBagType.java 20 May 2003 12:56:15 -0000 1.2 *************** *** 16,20 **** } ! protected PersistentCollection instantiate( SessionImplementor session, CollectionPersister persister) --- 16,20 ---- } ! public PersistentCollection instantiate( SessionImplementor session, CollectionPersister persister) Index: ListType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/ListType.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ListType.java 6 Apr 2003 10:11:12 -0000 1.8 --- ListType.java 20 May 2003 12:56:15 -0000 1.9 *************** *** 16,20 **** } ! protected PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister) { return new List(session); } --- 16,20 ---- } ! public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister) { return new List(session); } Index: MapType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/MapType.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MapType.java 6 Apr 2003 10:11:13 -0000 1.8 --- MapType.java 20 May 2003 12:56:15 -0000 1.9 *************** *** 18,22 **** } ! protected PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister) { return new Map(session); } --- 18,22 ---- } ! public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister) { return new Map(session); } Index: PersistentCollectionType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/PersistentCollectionType.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PersistentCollectionType.java 25 Apr 2003 03:40:37 -0000 1.10 --- PersistentCollectionType.java 20 May 2003 12:56:15 -0000 1.11 *************** *** 44,48 **** } ! protected abstract PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister) throws HibernateException; public Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner) throws HibernateException, SQLException { --- 44,48 ---- } ! public abstract PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister) throws HibernateException; public Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner) throws HibernateException, SQLException { *************** *** 56,62 **** public Object getCollection(Serializable id, Object owner, SessionImplementor session) throws HibernateException { CollectionPersister persister = session.getFactory().getCollectionPersister(role); ! PersistentCollection collection = persister.getCachedCollection(id, owner, session); if (collection!=null) { session.addInitializedCollection(collection, persister, id); --- 56,65 ---- public Object getCollection(Serializable id, Object owner, SessionImplementor session) throws HibernateException { + PersistentCollection collection = session.getLoadingCollection(role, id); + if (collection!=null) return collection.getCachedValue(); //TODO: yuck .. call another method + CollectionPersister persister = session.getFactory().getCollectionPersister(role); ! collection = persister.getCachedCollection(id, owner, session); if (collection!=null) { session.addInitializedCollection(collection, persister, id); Index: SetType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/SetType.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SetType.java 6 Apr 2003 10:11:13 -0000 1.8 --- SetType.java 20 May 2003 12:56:15 -0000 1.9 *************** *** 16,20 **** } ! protected PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister) { return new Set(session); } --- 16,20 ---- } ! public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister) { return new Set(session); } Index: SortedMapType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/SortedMapType.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SortedMapType.java 6 Apr 2003 10:11:13 -0000 1.8 --- SortedMapType.java 20 May 2003 12:56:15 -0000 1.9 *************** *** 21,25 **** } ! protected PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister) { SortedMap map = new SortedMap(session); map.setComparator(comparator); --- 21,25 ---- } ! public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister) { SortedMap map = new SortedMap(session); map.setComparator(comparator); Index: SortedSetType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/SortedSetType.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SortedSetType.java 6 Apr 2003 10:11:13 -0000 1.8 --- SortedSetType.java 20 May 2003 12:56:15 -0000 1.9 *************** *** 21,25 **** } ! protected PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister) { SortedSet set = new SortedSet(session); set.setComparator(comparator); --- 21,25 ---- } ! public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister) { SortedSet set = new SortedSet(session); set.setComparator(comparator); |
From: <one...@us...> - 2003-05-20 12:56:19
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv27564/hibernate/test Modified Files: FooBarTest.java MasterDetailTest.java MultiTableTest.java Log Message: added fetch keyword to HQL added evict() methods to SessionFactory for JVM-level cache destroy caches from SessionFactory.close() Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** FooBarTest.java 18 May 2003 15:45:14 -0000 1.66 --- FooBarTest.java 20 May 2003 12:56:14 -0000 1.67 *************** *** 60,63 **** --- 60,88 ---- } + public void testFetchList() throws Exception { + Session s = sessions.openSession(); + Baz baz = new Baz(); + s.save(baz); + Foo foo = new Foo(); + s.save(foo); + Foo foo2 = new Foo(); + s.save(foo2); + s.flush(); + List list = new ArrayList(); + for ( int i=0; i<5; i++ ) { + Fee fee = new Fee(); + list.add(fee); + } + baz.setFees(list); + list = s.find("from Foo foo, Baz baz left join fetch baz.fees"); + assertTrue( Hibernate.isInitialized( ( (Baz) ( (Object[]) list.get(0) )[1] ).getFees() ) ); + s.delete(foo); + s.delete(foo2); + s.delete(baz); + s.flush(); + s.connection().commit(); + s.close(); + } + public void testQueryLockMode() throws Exception { Session s = sessions.openSession(); *************** *** 1329,1333 **** foo.setFoo(foo2); ! List list = s.find( "select foo, bar from Foo foo left outer join foo.foo bar where foo = ?", foo, --- 1354,1364 ---- foo.setFoo(foo2); ! List list = s.find("from Foo foo inner join fetch foo.foo"); ! Foo foof = (Foo) list.get(0); ! assertTrue( Hibernate.isInitialized( foof.getFoo() ) ); ! ! list = s.find("from Baz baz left outer join fetch baz.fooToGlarch"); ! ! list = s.find( "select foo, bar from Foo foo left outer join foo.foo bar where foo = ?", foo, Index: MasterDetailTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/MasterDetailTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** MasterDetailTest.java 17 May 2003 03:53:38 -0000 1.11 --- MasterDetailTest.java 20 May 2003 12:56:14 -0000 1.12 *************** *** 15,18 **** --- 15,19 ---- import junit.framework.Test; import junit.framework.TestSuite; + import net.sf.hibernate.Hibernate; import net.sf.hibernate.ObjectNotFoundException; import net.sf.hibernate.Query; *************** *** 145,148 **** --- 146,183 ---- s = sessions.openSession(); t = s.beginTransaction(); + List list = s.find("from Master m left join fetch m.details"); + Master m = (Master) list.get(0); + assertTrue( Hibernate.isInitialized( m.getDetails() ) ); + assertTrue( m.getDetails().size()==2 ); + list = s.find("from Detail d inner join fetch d.master"); + Detail dt = (Detail) list.get(0); + Serializable dtid = s.getIdentifier(dt); + assertTrue( dt.getMaster()==m ); + t.commit(); + s.close(); + + s = sessions.openSession(); + t = s.beginTransaction(); + list = s.find("select m from Master m1, Master m left join fetch m.details where m.name=m1.name"); + assertTrue( Hibernate.isInitialized( ( (Master) list.get(0) ).getDetails() ) ); + dt = (Detail) s.load(Detail.class, dtid); + assertTrue( ( (Master) list.get(0) ).getDetails().contains(dt) ); + t.commit(); + s.close(); + + s = sessions.openSession(); + t = s.beginTransaction(); + list = s.find("select m, m1.name from Master m1, Master m left join fetch m.details where m.name=m1.name"); + assertTrue( Hibernate.isInitialized( ( (Master) ( (Object[]) list.get(0) )[0] ).getDetails() ) ); + dt = (Detail) s.load(Detail.class, dtid); + assertTrue( ( (Master) ( (Object[]) list.get(0) )[0] ).getDetails().contains(dt) ); + //list = s.find("select m from Master m, Master m2 left join fetch m.details"); + list = s.find("select m.id from Master m inner join fetch m.details"); + t.commit(); + s.close(); + + + s = sessions.openSession(); + t = s.beginTransaction(); Detail dd = (Detail) s.load(Detail.class, did); master = dd.getMaster(); *************** *** 160,164 **** assertTrue( q.list().size()==0 ); q = s.createFilter( master.getDetails(), "where this.id in (:ids)" ); ! List list = new ArrayList(); list.add(did); list.add(new Long(-1)); --- 195,199 ---- assertTrue( q.list().size()==0 ); q = s.createFilter( master.getDetails(), "where this.id in (:ids)" ); ! list = new ArrayList(); list.add(did); list.add(new Long(-1)); Index: MultiTableTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/MultiTableTest.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** MultiTableTest.java 3 May 2003 07:06:26 -0000 1.15 --- MultiTableTest.java 20 May 2003 12:56:14 -0000 1.16 *************** *** 60,63 **** --- 60,66 ---- s = sessions.openSession(); + s.connection().createStatement().executeQuery( + "select * from leafsubsubclass sm, nonleafsubclass m, rootclass s where sm.sid=m.sid and sm.sid=s.id_ and sm.sid=1" + ).next(); assertTrue( s.find("select s from SubMulti as sm join sm.children as s where s.amount>-1 and s.name is null").size()==2 ); assertTrue( s.find("select elements(sm.children) from SubMulti as sm").size()==2 ); |
From: <one...@us...> - 2003-05-20 12:56:18
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader In directory sc8-pr-cvs1:/tmp/cvs-serv27564/hibernate/loader Modified Files: EntityLoader.java Loader.java SimpleEntityLoader.java Log Message: added fetch keyword to HQL added evict() methods to SessionFactory for JVM-level cache destroy caches from SessionFactory.close() Index: EntityLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/EntityLoader.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** EntityLoader.java 18 May 2003 15:45:13 -0000 1.17 --- EntityLoader.java 20 May 2003 12:56:14 -0000 1.18 *************** *** 3,6 **** --- 3,7 ---- import java.io.Serializable; + import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; *************** *** 38,43 **** List list = loadEntity(session, new Object[] { id }, idType, object, id, false); if ( list.size()==1 ) { ! final int len = classPersisters.length; ! return ( (Object[]) list.get(0) )[len-1]; } else if ( list.size()==0 ) { --- 39,43 ---- List list = loadEntity(session, new Object[] { id }, idType, object, id, false); if ( list.size()==1 ) { ! return list.get(0); } else if ( list.size()==0 ) { *************** *** 52,55 **** --- 52,63 ---- ); } + } + + protected Object getResultColumnOrRow( + Object[] row, + ResultSet rs, + SessionImplementor session) + throws SQLException, HibernateException { + return row[row.length-1]; } Index: Loader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/Loader.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Loader.java 18 May 2003 15:45:13 -0000 1.25 --- Loader.java 20 May 2003 12:56:14 -0000 1.26 *************** *** 107,115 **** final Loadable[] persisters = getPersisters(); final int cols = persisters.length; ! final boolean collection = getCollectionPersister()!=null; final boolean returnsEntities = cols > 0; final String[] suffixes = getSuffixes(); final LockMode[] lockModeArray = getLockModes(lockModes); final ArrayList hydratedObjects = returnsEntities ? new ArrayList() : null; --- 107,120 ---- final Loadable[] persisters = getPersisters(); final int cols = persisters.length; ! final CollectionPersister collectionPersister = getCollectionPersister(); final boolean returnsEntities = cols > 0; final String[] suffixes = getSuffixes(); final LockMode[] lockModeArray = getLockModes(lockModes); + //this is a CollectionInitializer and we are loading up a single collection + final boolean singleCollection = collectionPersister!=null && optionalCollection!=null; + //this is a query and we are loading multiple instances of the same collection role + final boolean multipleCollections = collectionPersister!=null && optionalCollection==null; + final ArrayList hydratedObjects = returnsEntities ? new ArrayList() : null; *************** *** 131,135 **** final ResultSet rs = getResultSet(st, selection, session); ! if (collection) optionalCollection.beginRead(); try { --- 136,144 ---- final ResultSet rs = getResultSet(st, selection, session); ! PersistentCollection rowCollection = null; ! if (singleCollection) { ! optionalCollection.beginRead(); ! rowCollection = optionalCollection; ! } try { *************** *** 142,145 **** --- 151,162 ---- for ( count=0; count<maxRows && rs.next(); count++ ) { + if (multipleCollections) { + //TODO: what about the owner??? + rowCollection = session.getLoadingCollection( + collectionPersister, + (Serializable) collectionPersister.readKey(rs, session) + ); + } + for ( int i=0; i<cols; i++ ) { keys[i] = getKeyFromResultSet( persisters[i], suffixes[i], (i==cols-1) ? optionalID : null, rs, session ); *************** *** 157,161 **** results.add( getResultColumnOrRow(row, rs, session) ); ! if (collection) optionalCollection.readFrom( rs, getCollectionPersister(), optionalCollectionOwner ); } --- 174,180 ---- results.add( getResultColumnOrRow(row, rs, session) ); ! if (singleCollection || multipleCollections) rowCollection.readFrom( ! rs, getCollectionPersister(), optionalCollectionOwner //TODO: optionalOwner may be missing ! ); } *************** *** 182,186 **** } ! if (collection) optionalCollection.endRead(); return results; --- 201,206 ---- } ! if (multipleCollections) session.endLoadingCollections(collectionPersister); ! if (singleCollection) optionalCollection.endRead(); return results; Index: SimpleEntityLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/SimpleEntityLoader.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SimpleEntityLoader.java 18 May 2003 15:45:14 -0000 1.9 --- SimpleEntityLoader.java 20 May 2003 12:56:14 -0000 1.10 *************** *** 3,6 **** --- 3,7 ---- import java.io.Serializable; + import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; *************** *** 53,57 **** List list = loadEntity(session, new Object[] { id }, idType, object, id, false); if ( list.size()==1 ) { ! return ( (Object[]) list.get(0) )[0]; } else if ( list.size()==0 ) { --- 54,58 ---- List list = loadEntity(session, new Object[] { id }, idType, object, id, false); if ( list.size()==1 ) { ! return list.get(0); } else if ( list.size()==0 ) { *************** *** 66,69 **** --- 67,78 ---- protected LockMode[] getLockModes(Map lockModes) { return lockMode; + } + + protected Object getResultColumnOrRow( + Object[] row, + ResultSet rs, + SessionImplementor session) + throws SQLException, HibernateException { + return row[0]; } |
From: <one...@us...> - 2003-05-20 12:56:17
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/jmx In directory sc8-pr-cvs1:/tmp/cvs-serv27564/hibernate/jmx Modified Files: SessionFactoryStub.java Log Message: added fetch keyword to HQL added evict() methods to SessionFactory for JVM-level cache destroy caches from SessionFactory.close() Index: SessionFactoryStub.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/jmx/SessionFactoryStub.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SessionFactoryStub.java 25 Apr 2003 03:40:34 -0000 1.8 --- SessionFactoryStub.java 20 May 2003 12:56:14 -0000 1.9 *************** *** 4,7 **** --- 4,8 ---- import java.io.InvalidObjectException; import java.io.ObjectStreamException; + import java.io.Serializable; import java.sql.Connection; import java.util.Map; *************** *** 139,142 **** --- 140,161 ---- public void close() throws HibernateException { + } + + public void evict(Class persistentClass, Serializable id) + throws HibernateException { + getImpl().evict(persistentClass, id); + } + + public void evict(Class persistentClass) throws HibernateException { + getImpl().evict(persistentClass); + } + + public void evictCollection(String roleName, Serializable id) + throws HibernateException { + getImpl().evictCollection(roleName, id); + } + + public void evictCollection(String roleName) throws HibernateException { + getImpl().evictCollection(roleName); } |
From: <one...@us...> - 2003-05-20 12:56:17
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/jca In directory sc8-pr-cvs1:/tmp/cvs-serv27564/hibernate/jca Modified Files: JCASessionFactoryImpl.java Log Message: added fetch keyword to HQL added evict() methods to SessionFactory for JVM-level cache destroy caches from SessionFactory.close() Index: JCASessionFactoryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/jca/JCASessionFactoryImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** JCASessionFactoryImpl.java 1 May 2003 01:59:23 -0000 1.3 --- JCASessionFactoryImpl.java 20 May 2003 12:56:13 -0000 1.4 *************** *** 2,5 **** --- 2,6 ---- package net.sf.hibernate.jca; + import java.io.Serializable; import java.sql.Connection; import java.util.Map; *************** *** 120,122 **** --- 121,141 ---- return managedFactory.getSessionFactory(); } + public void evict(Class persistentClass, Serializable id) + throws HibernateException { + getSessionFactory().evict(persistentClass, id); + } + + public void evict(Class persistentClass) throws HibernateException { + getSessionFactory().evict(persistentClass); + } + + public void evictCollection(String roleName, Serializable id) + throws HibernateException { + getSessionFactory().evictCollection(roleName, id); + } + + public void evictCollection(String roleName) throws HibernateException { + getSessionFactory().evictCollection(roleName); + } + } |
From: <one...@us...> - 2003-05-20 12:56:17
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv27564/hibernate/impl Modified Files: SessionFactoryImpl.java SessionImpl.java Log Message: added fetch keyword to HQL added evict() methods to SessionFactory for JVM-level cache destroy caches from SessionFactory.close() Index: SessionFactoryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionFactoryImpl.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** SessionFactoryImpl.java 25 Apr 2003 05:56:33 -0000 1.20 --- SessionFactoryImpl.java 20 May 2003 12:56:12 -0000 1.21 *************** *** 9,12 **** --- 9,13 ---- import java.io.ObjectOutputStream; import java.io.ObjectStreamException; + import java.io.Serializable; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; *************** *** 115,119 **** private transient final boolean showSql; private transient final boolean useOuterJoin; - private transient final boolean supportsLocking; private transient final Templates templates; private transient final Map querySubstitutions; --- 116,119 ---- *************** *** 145,152 **** Dialect dl = null; - boolean sl = false; try { dl = Dialect.getDialect(properties); - sl = dl.supportsForUpdate(); Properties temp = new Properties(); //temp.putAll( Environment.getProperties() ); --- 145,150 ---- *************** *** 160,164 **** } dialect=dl; - supportsLocking = sl; connections = ConnectionProviderFactory.newConnectionProvider(properties); --- 158,161 ---- *************** *** 309,313 **** // Emulates constant time LRU/MRU algorithms for cache // It is better to hold strong refernces on some (LRU/MRU) queries ! private static transient final int MAX_STRONG_REF_COUNT = 128; //TODO: configurable? private transient final Object strongRefs[] = new Object[MAX_STRONG_REF_COUNT]; //strong reference to MRU queries private transient int strongRefIndex = 0; --- 306,310 ---- // Emulates constant time LRU/MRU algorithms for cache // It is better to hold strong refernces on some (LRU/MRU) queries ! private static final int MAX_STRONG_REF_COUNT = 128; //TODO: configurable? private transient final Object strongRefs[] = new Object[MAX_STRONG_REF_COUNT]; //strong reference to MRU queries private transient int strongRefIndex = 0; *************** *** 737,740 **** --- 734,749 ---- log.info("closing"); + Iterator iter = classPersisters.values().iterator(); + while ( iter.hasNext() ) { + ClassPersister p = (ClassPersister) iter.next(); + if ( p.hasCache() ) p.getCache().destroy(); + } + + iter = collectionPersisters.values().iterator(); + while ( iter.hasNext() ) { + CollectionPersister p = (CollectionPersister) iter.next(); + if ( p.hasCache() ) p.getCache().destroy(); + } + if (statementCache!=null) statementCache.close(); try { *************** *** 744,747 **** --- 753,777 ---- SessionFactoryObjectFactory.removeInstance(uuid, name, properties); } + } + + public void evict(Class persistentClass, Serializable id) throws HibernateException { + ClassPersister p = getPersister(persistentClass); + if ( p.hasCache() ) p.getCache().remove(id); + } + + public void evict(Class persistentClass) throws HibernateException { + ClassPersister p = getPersister(persistentClass); + if ( p.hasCache() ) p.getCache().clear(); + } + + public void evictCollection(String roleName, Serializable id) + throws HibernateException { + CollectionPersister p = getCollectionPersister(roleName); + if ( p.hasCache() ) p.getCache().remove(id); + } + + public void evictCollection(String roleName) throws HibernateException { + CollectionPersister p = getCollectionPersister(roleName); + if ( p.hasCache() ) p.getCache().clear(); } Index: SessionImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionImpl.java,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** SessionImpl.java 18 May 2003 15:45:13 -0000 1.46 --- SessionImpl.java 20 May 2003 12:56:12 -0000 1.47 *************** *** 2665,2668 **** --- 2665,2703 ---- } + private Map loadingCollections = new HashMap(); + private String loadingRole; + + public PersistentCollection getLoadingCollection(CollectionPersister persister, Serializable id) throws HibernateException { + PersistentCollection pc = (PersistentCollection) loadingCollections.get(id); + if (pc==null) { + pc = persister.getType().instantiate(this, persister); + pc.beforeInitialize(persister); + pc.beginRead(); + if (loadingRole!=null && !loadingRole.equals( persister.getRole() ) ) + throw new AssertionFailure("recursive collection load"); + loadingCollections.put(id, pc); + loadingRole = persister.getRole(); + } + return pc; + } + + public void endLoadingCollections(CollectionPersister persister) throws HibernateException { + Iterator iter = loadingCollections.entrySet().iterator(); + while ( iter.hasNext() ) { + Map.Entry e = (Map.Entry) iter.next(); + PersistentCollection pc = (PersistentCollection) e.getValue(); + pc.endRead(); + addInitializedCollection( pc, persister, (Serializable) e.getKey() ); + } + loadingCollections.clear(); + loadingRole=null; + } + + public PersistentCollection getLoadingCollection(String role, Serializable id) { + return role.equals(loadingRole) ? + (PersistentCollection) loadingCollections.get(id) : + null; + } + /** * add a collection we just loaded up (still needs initializing) |
From: <one...@us...> - 2003-05-18 15:48:55
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/sql In directory sc8-pr-cvs1:/tmp/cvs-serv14359/hibernate/sql Added Files: ForUpdateFragment.java Log Message: * added Query.setLockMode() * tidied up implementation of Loader --- NEW FILE: ForUpdateFragment.java --- package net.sf.hibernate.sql; /** * @author Gavin King */ public class ForUpdateFragment { private StringBuffer aliases = new StringBuffer(); private boolean nowait; public ForUpdateFragment addTableAlias(String alias) { if ( aliases.length()>0 ) aliases.append(", "); aliases.append(alias); return this; } public String toFragmentString() { return aliases.length()==0 ? "" : " for update of " + aliases + ( nowait ? " nowait" : ""); } public ForUpdateFragment setNowait(boolean nowait) { this.nowait = nowait; return this; } } |
From: <one...@us...> - 2003-05-18 15:45:18
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv10989/hibernate/impl Modified Files: FilterImpl.java QueryImpl.java SessionImpl.java Log Message: * added Query.setLockMode() * tidied up implementation of Loader Index: FilterImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/FilterImpl.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** FilterImpl.java 25 Apr 2003 05:56:33 -0000 1.9 --- FilterImpl.java 18 May 2003 15:45:13 -0000 1.10 *************** *** 32,36 **** Map namedParams = new HashMap( getNamedParams() ); String query = bindParameterLists(namedParams); ! return getSession().iterateFilter(collection, query, valueArray(), typeArray(), getSelection(), namedParams); } --- 32,38 ---- Map namedParams = new HashMap( getNamedParams() ); String query = bindParameterLists(namedParams); ! return getSession().iterateFilter( ! collection, query, valueArray(), typeArray(), getSelection(), namedParams, getLockModes() ! ); } *************** *** 41,45 **** Map namedParams = new HashMap( getNamedParams() ); String query = bindParameterLists(namedParams); ! return getSession().filter(collection, query, valueArray(), typeArray(), getSelection(), namedParams); } --- 43,49 ---- Map namedParams = new HashMap( getNamedParams() ); String query = bindParameterLists(namedParams); ! return getSession().filter( ! collection, query, valueArray(), typeArray(), getSelection(), namedParams, getLockModes() ! ); } Index: QueryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/QueryImpl.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** QueryImpl.java 25 Apr 2003 05:56:33 -0000 1.17 --- QueryImpl.java 18 May 2003 15:45:13 -0000 1.18 *************** *** 17,20 **** --- 17,21 ---- import net.sf.hibernate.Hibernate; import net.sf.hibernate.HibernateException; + import net.sf.hibernate.LockMode; import net.sf.hibernate.MappingException; import net.sf.hibernate.PropertyNotFoundException; *************** *** 48,51 **** --- 49,53 ---- private Map namedParameters = new HashMap(4); private Map namedParameterLists = new HashMap(4); + private Map lockModes = new HashMap(2); public QueryImpl(String queryString, SessionImplementor session) { *************** *** 60,64 **** Map namedParams = new HashMap(namedParameters); String query = bindParameterLists(namedParams); ! return session.iterate(query, values.toArray(), (Type[]) types.toArray(NO_TYPES), selection, namedParams); } --- 62,66 ---- Map namedParams = new HashMap(namedParameters); String query = bindParameterLists(namedParams); ! return session.iterate(query, values.toArray(), (Type[]) types.toArray(NO_TYPES), selection, namedParams, lockModes); } *************** *** 66,70 **** Map namedParams = new HashMap(namedParameters); String query = bindParameterLists(namedParams); ! return session.scroll(query, values.toArray(), (Type[]) types.toArray(NO_TYPES), selection, namedParams); } --- 68,72 ---- Map namedParams = new HashMap(namedParameters); String query = bindParameterLists(namedParams); ! return session.scroll(query, values.toArray(), (Type[]) types.toArray(NO_TYPES), selection, namedParams, lockModes); } *************** *** 72,76 **** Map namedParams = new HashMap(namedParameters); String query = bindParameterLists(namedParams); ! return session.find(query, values.toArray(), (Type[]) types.toArray(NO_TYPES), selection, namedParams); } --- 74,78 ---- Map namedParams = new HashMap(namedParameters); String query = bindParameterLists(namedParams); ! return session.find(query, values.toArray(), (Type[]) types.toArray(NO_TYPES), selection, namedParams, lockModes); } *************** *** 441,444 **** --- 443,454 ---- throws HibernateException { return setParameterList( name, Arrays.asList(vals) ); + } + + public void setLockMode(String alias, LockMode lockMode) { + lockModes.put(alias, lockMode); + } + + Map getLockModes() { + return lockModes; } Index: SessionImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionImpl.java,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** SessionImpl.java 17 May 2003 04:09:42 -0000 1.45 --- SessionImpl.java 18 May 2003 15:45:13 -0000 1.46 *************** *** 524,527 **** --- 524,531 ---- } + public LockMode getLockMode(Object object) { + return getEntry(object).lockMode; + } + private void addEntity(Key key, Object object) { entitiesByKey.put(key, object); *************** *** 534,537 **** --- 538,545 ---- } + public void setLockMode(Object entity, LockMode lockMode) { + getEntry(entity).lockMode = lockMode; + } + private EntityEntry addEntry( Object object, *************** *** 1307,1314 **** public List find(String query, Object[] values, Type[] types) throws HibernateException { ! return find(query, values, types, null, null); } ! public List find(String query, Object[] values, Type[] types, RowSelection selection, Map namedParams) throws HibernateException { if ( log.isTraceEnabled() ) { --- 1315,1322 ---- public List find(String query, Object[] values, Type[] types) throws HibernateException { ! return find(query, values, types, null, null, null); } ! public List find(String query, Object[] values, Type[] types, RowSelection selection, Map namedParams, Map lockModes) throws HibernateException { if ( log.isTraceEnabled() ) { *************** *** 1328,1332 **** List currentResults; try { ! currentResults = q[i].find(this, values, types, true, selection, namedParams); } catch (SQLException sqle) { --- 1336,1340 ---- List currentResults; try { ! currentResults = q[i].find(this, values, types, true, selection, namedParams, lockModes); } catch (SQLException sqle) { *************** *** 1371,1378 **** public Iterator iterate(String query, Object[] values, Type[] types) throws HibernateException { ! return iterate(query, values, types, null, null); } ! public Iterator iterate(String query, Object[] values, Type[] types, RowSelection selection, Map namedParams) throws HibernateException { if ( log.isTraceEnabled() ) { --- 1379,1386 ---- public Iterator iterate(String query, Object[] values, Type[] types) throws HibernateException { ! return iterate(query, values, types, null, null, null); } ! public Iterator iterate(String query, Object[] values, Type[] types, RowSelection selection, Map namedParams, Map lockModes) throws HibernateException { if ( log.isTraceEnabled() ) { *************** *** 1394,1398 **** try { ! result = q[i].iterate(values, types, selection, namedParams, this); } catch (SQLException sqle) { --- 1402,1406 ---- try { ! result = q[i].iterate(values, types, selection, namedParams, lockModes, this); } catch (SQLException sqle) { *************** *** 1408,1412 **** } ! public ScrollableResults scroll(String query, Object[] values, Type[] types, RowSelection selection, Map namedParams) throws HibernateException { if ( log.isTraceEnabled() ) { --- 1416,1420 ---- } ! public ScrollableResults scroll(String query, Object[] values, Type[] types, RowSelection selection, Map namedParams, Map lockModes) throws HibernateException { if ( log.isTraceEnabled() ) { *************** *** 1420,1424 **** autoFlushIfRequired( q.getQuerySpaces() ); try { ! return q.scroll(values, types, selection, namedParams, this); } catch (SQLException sqle) { --- 1428,1432 ---- autoFlushIfRequired( q.getQuerySpaces() ); try { ! return q.scroll(values, types, selection, namedParams, lockModes, this); } catch (SQLException sqle) { *************** *** 1733,1737 **** * later. This should return an existing proxy where appropriate. */ ! private Object doLoadByClass(Class clazz, Serializable id, boolean checkDeleted, boolean allowProxyCreation) throws HibernateException { if ( log.isTraceEnabled() ) log.trace( "loading " + MessageHelper.infoString(clazz, id) ); --- 1741,1746 ---- * later. This should return an existing proxy where appropriate. */ ! private Object doLoadByClass(Class clazz, Serializable id, boolean checkDeleted, boolean allowProxyCreation) ! throws HibernateException { if ( log.isTraceEnabled() ) log.trace( "loading " + MessageHelper.infoString(clazz, id) ); *************** *** 2844,2852 **** public Collection filter(Object collection, String filter) throws HibernateException { ! return filter( collection, filter, new Object[1], new Type[1], null, null ); } public Collection filter(Object collection, String filter, Object value, Type type) throws HibernateException { ! return filter(collection, filter, new Object[] { null, value }, new Type[] { null, type }, null, null ); } --- 2853,2861 ---- public Collection filter(Object collection, String filter) throws HibernateException { ! return filter(collection, filter, new Object[1], new Type[1], null, null, null); } public Collection filter(Object collection, String filter, Object value, Type type) throws HibernateException { ! return filter(collection, filter, new Object[] { null, value }, new Type[] { null, type }, null, null, null); } *************** *** 2856,2860 **** System.arraycopy(values, 0, vals, 1, values.length); System.arraycopy(types, 0, typs, 1, types.length); ! return filter(collection, filter, vals, typs, null, null); //todo } --- 2865,2869 ---- System.arraycopy(values, 0, vals, 1, values.length); System.arraycopy(types, 0, typs, 1, types.length); ! return filter(collection, filter, vals, typs, null, null, null); } *************** *** 2902,2906 **** } ! public List filter(Object collection, String filter, Object[] values, Type[] types, RowSelection selection, Map namedParams) throws HibernateException { String[] concreteFilters = QueryTranslator.concreteQueries(filter, factory); --- 2911,2915 ---- } ! public List filter(Object collection, String filter, Object[] values, Type[] types, RowSelection selection, Map namedParams, Map lockModes) throws HibernateException { String[] concreteFilters = QueryTranslator.concreteQueries(filter, factory); *************** *** 2918,2922 **** List currentResults; try { ! currentResults = filters[i].find(this, values, types, true, selection, namedParams); } catch (SQLException sqle) { --- 2927,2931 ---- List currentResults; try { ! currentResults = filters[i].find(this, values, types, true, selection, namedParams, lockModes); } catch (SQLException sqle) { *************** *** 2934,2938 **** } ! public Iterator iterateFilter(Object collection, String filter, Object[] values, Type[] types, RowSelection selection, Map namedParams) throws HibernateException { String[] concreteFilters = QueryTranslator.concreteQueries(filter, factory); --- 2943,2947 ---- } ! public Iterator iterateFilter(Object collection, String filter, Object[] values, Type[] types, RowSelection selection, Map namedParams, Map lockModes) throws HibernateException { String[] concreteFilters = QueryTranslator.concreteQueries(filter, factory); *************** *** 2954,2958 **** try { ! result = filters[i].iterate(values, types, selection, namedParams, this); } catch (SQLException sqle) { --- 2963,2967 ---- try { ! result = filters[i].iterate(values, types, selection, namedParams, lockModes, this); } catch (SQLException sqle) { *************** *** 3081,3084 **** --- 3090,3097 ---- } } + } + + public Object getVersion(Object entity) { + return getEntry(entity).lastVersion; } |
From: <one...@us...> - 2003-05-18 15:45:18
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql In directory sc8-pr-cvs1:/tmp/cvs-serv10989/hibernate/hql Modified Files: QueryTranslator.java Log Message: * added Query.setLockMode() * tidied up implementation of Loader Index: QueryTranslator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql/QueryTranslator.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** QueryTranslator.java 10 May 2003 09:59:11 -0000 1.29 --- QueryTranslator.java 18 May 2003 15:45:13 -0000 1.30 *************** *** 18,25 **** --- 18,27 ---- import net.sf.hibernate.Hibernate; import net.sf.hibernate.HibernateException; + import net.sf.hibernate.LockMode; import net.sf.hibernate.MappingException; import net.sf.hibernate.QueryException; import net.sf.hibernate.ScrollableResults; import net.sf.hibernate.collection.CollectionPersister; + import net.sf.hibernate.dialect.Dialect; import net.sf.hibernate.engine.RowSelection; import net.sf.hibernate.engine.SessionFactoryImplementor; *************** *** 31,34 **** --- 33,37 ---- import net.sf.hibernate.persister.Loadable; import net.sf.hibernate.persister.Queryable; + import net.sf.hibernate.sql.ForUpdateFragment; import net.sf.hibernate.sql.JoinFragment; import net.sf.hibernate.sql.QueryJoinFragment; *************** *** 69,72 **** --- 72,76 ---- private Queryable[] persisters; + private String[] names; private Type[] types; private String[][] scalarColumnNames; *************** *** 190,197 **** aliasNames.put(alias, name); } String unalias(String path) { String alias = StringHelper.root(path); ! String name = (String) aliasNames.get(alias); if (name!=null) { return name + path.substring( alias.length() ); --- 194,205 ---- aliasNames.put(alias, name); } + String getAliasName(String alias) { + String name = (String) aliasNames.get(alias); + return name==null ? alias : name; + } String unalias(String path) { String alias = StringHelper.root(path); ! String name = (String) aliasNames.get(alias); if (name!=null) { return name + path.substring( alias.length() ); *************** *** 408,411 **** --- 416,420 ---- int size = returnTypes.size(); persisters = new Queryable[size]; + names = new String[size]; suffixes = new String[size]; for ( int i=0; i<size; i++ ) { *************** *** 413,416 **** --- 422,426 ---- //if ( !isName(name) ) throw new QueryException("unknown type: " + name); persisters[i] = getPersisterForName(name); + names[i] = name; suffixes[i] = (size==1) ? StringHelper.EMPTY_STRING : Integer.toString(i) + StringHelper.UNDERSCORE; } *************** *** 719,725 **** } ! public Iterator iterate(Object[] values, Type[] types, RowSelection selection, Map namedParams, SessionImplementor session) throws HibernateException, SQLException { ! PreparedStatement st = prepareQueryStatement( getSQLString(), values, types, namedParams, selection, false, session ); ResultSet rs = getResultSet(st, selection, session); return new IteratorImpl( rs, session, getReturnTypes(), getScalarColumnNames() ); --- 729,738 ---- } ! public Iterator iterate(Object[] values, Type[] types, RowSelection selection, Map namedParams, Map lockModes, SessionImplementor session) throws HibernateException, SQLException { ! PreparedStatement st = prepareQueryStatement( ! applyLocks( getSQLString(), lockModes, session.getFactory().getDialect() ), ! values, types, namedParams, selection, false, session ! ); ResultSet rs = getResultSet(st, selection, session); return new IteratorImpl( rs, session, getReturnTypes(), getScalarColumnNames() ); *************** *** 727,733 **** } ! public ScrollableResults scroll(Object[] values, Type[] types, RowSelection selection, Map namedParams, SessionImplementor session) throws HibernateException, SQLException { ! PreparedStatement st = prepareQueryStatement( getSQLString(), values, types, namedParams, selection, true, session ); ResultSet rs = getResultSet(st, selection, session); return new ScrollableResultsImpl( rs, session, getReturnTypes() ); --- 740,749 ---- } ! public ScrollableResults scroll(Object[] values, Type[] types, RowSelection selection, Map namedParams, Map lockModes, SessionImplementor session) throws HibernateException, SQLException { ! PreparedStatement st = prepareQueryStatement( ! applyLocks( getSQLString(), lockModes, session.getFactory().getDialect() ), ! values, types, namedParams, selection, true, session ! ); ResultSet rs = getResultSet(st, selection, session); return new ScrollableResultsImpl( rs, session, getReturnTypes() ); *************** *** 839,845 **** boolean returnProxies, RowSelection selection, ! Map namedParams) throws SQLException, HibernateException { ! return super.find(session, values, types, returnProxies, selection, namedParams); } --- 855,862 ---- boolean returnProxies, RowSelection selection, ! Map namedParams, ! Map lockModes) throws SQLException, HibernateException { ! return super.find(session, values, types, returnProxies, selection, namedParams, lockModes); } *************** *** 877,880 **** --- 894,949 ---- void setHolderClass(Class clazz) { holderClass = clazz; + } + + public LockMode[] getLockModes(Map lockModes) { + HashMap nameLockModes = new HashMap(); + if (lockModes!=null) { + Iterator iter = lockModes.entrySet().iterator(); + while ( iter.hasNext() ) { + Map.Entry me = (Map.Entry) iter.next(); + nameLockModes.put( + getAliasName( (String) me.getKey() ), + me.getValue() + ); + } + } + LockMode[] lockModeArray = new LockMode[names.length]; + for ( int i=0; i<names.length; i++ ) { + LockMode lm = (LockMode) nameLockModes.get( names[i] ); + if (lm==null) lm = LockMode.NONE; + lockModeArray[i] = lm; + } + return lockModeArray; + } + + protected String applyLocks(String sql, Map lockModes, Dialect dialect) throws QueryException { + if ( lockModes==null || lockModes.size()==0 ) { + return sql; + } + else if ( dialect.supportsForUpdateOf() ) { + LockMode upgradeType = null; + ForUpdateFragment updateClause = new ForUpdateFragment(); + Iterator iter = lockModes.entrySet().iterator(); + Map.Entry me = (Map.Entry) iter.next(); + String name = getAliasName( (String) me.getKey() ); + LockMode lockMode = (LockMode) me.getValue(); + if ( LockMode.READ.lessThan(lockMode) ) { + updateClause.addTableAlias(name); + if ( upgradeType!=null && lockMode!=upgradeType ) throw new QueryException("mixed LockModes"); + upgradeType = lockMode; + } + if ( upgradeType==LockMode.UPGRADE_NOWAIT && dialect.supportsForUpdateNowait() ) { + updateClause.setNowait(true); + } + return sql + updateClause.toFragmentString(); + } + else { + log.debug("dialect does not support FOR UPDATE OF"); + return sql; + } + } + + protected boolean upgradeLocks() { + return true; } |
From: <one...@us...> - 2003-05-18 15:45:18
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv10989/hibernate/test Modified Files: Baz.hbm.xml Baz.java FooBarTest.java Log Message: * added Query.setLockMode() * tidied up implementation of Loader Index: Baz.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Baz.hbm.xml,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Baz.hbm.xml 2 May 2003 09:21:59 -0000 1.19 --- Baz.hbm.xml 18 May 2003 15:45:14 -0000 1.20 *************** *** 10,13 **** --- 10,14 ---- <property name="count" column="count_count"/> <property name="name" column="name_b"/> + <many-to-one name="foo" outer-join="true" class="net.sf.hibernate.test.Foo"/> <list name="stringList" table="string_list"> Index: Baz.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Baz.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Baz.java 2 May 2003 09:21:59 -0000 1.10 --- Baz.java 18 May 2003 15:45:14 -0000 1.11 *************** *** 44,47 **** --- 44,48 ---- private Collection idFooBag; private Collection byteBag; + private FooProxy foo; Baz() {} *************** *** 357,360 **** --- 358,369 ---- public void setByteBag(Collection list) { byteBag = list; + } + + public FooProxy getFoo() { + return foo; + } + + public void setFoo(FooProxy foo) { + this.foo = foo; } Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** FooBarTest.java 17 May 2003 03:53:37 -0000 1.65 --- FooBarTest.java 18 May 2003 15:45:14 -0000 1.66 *************** *** 60,63 **** --- 60,111 ---- } + public void testQueryLockMode() throws Exception { + Session s = sessions.openSession(); + Bar bar = new Bar(); + s.save(bar); + s.flush(); + bar.setString("changed"); + Baz baz = new Baz(); + baz.setFoo(bar); + s.save(baz); + Query q = s.createQuery("from Foo foo, Bar bar"); + q.setLockMode("bar", LockMode.UPGRADE); + Object[] result = (Object[]) q.list().get(0); + Object b = result[0]; + assertTrue( s.getCurrentLockMode(b)==LockMode.WRITE && s.getCurrentLockMode( result[1] )==LockMode.WRITE ); + s.flush(); + s.connection().commit(); + s.disconnect(); + s.reconnect(); + assertTrue( s.getCurrentLockMode(b)==LockMode.NONE ); + s.find("from Foo foo"); + assertTrue( s.getCurrentLockMode(b)==LockMode.NONE ); + q = s.createQuery("from Foo foo"); + q.setLockMode("foo", LockMode.READ); + q.list(); + assertTrue( s.getCurrentLockMode(b)==LockMode.READ ); + s.evict(baz); + s.connection().commit(); + s.disconnect(); + s.reconnect(); + assertTrue( s.getCurrentLockMode(b)==LockMode.NONE ); + s.delete( s.load( Baz.class, baz.getCode() ) ); + assertTrue( s.getCurrentLockMode(b)==LockMode.NONE ); + s.flush(); + s.connection().commit(); + s.close(); + + s = sessions.openSession(); + q = s.createQuery("from Foo foo, Bar bar, Bar bar2"); + q.setLockMode("bar", LockMode.UPGRADE); + q.setLockMode("bar2", LockMode.READ); + result = (Object[]) q.list().get(0); + assertTrue( s.getCurrentLockMode( result[0] )==LockMode.UPGRADE && s.getCurrentLockMode( result[1] )==LockMode.UPGRADE ); + s.delete( result[0] ); + s.flush(); + s.connection().commit(); + s.close(); + } + public void testManyToManyBag() throws Exception { Session s = sessions.openSession(); |
From: <one...@us...> - 2003-05-18 15:45:18
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type In directory sc8-pr-cvs1:/tmp/cvs-serv10989/hibernate/type Modified Files: AbstractType.java Log Message: * added Query.setLockMode() * tidied up implementation of Loader Index: AbstractType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/AbstractType.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** AbstractType.java 25 Apr 2003 03:40:37 -0000 1.9 --- AbstractType.java 18 May 2003 15:45:14 -0000 1.10 *************** *** 62,66 **** Object owner) throws HibernateException, SQLException { ! return nullSafeGet(rs, names, session, owner); } --- 62,66 ---- Object owner) throws HibernateException, SQLException { ! //TODO: this is very suboptimal, since it does not take advantage of two-phase-load return nullSafeGet(rs, names, session, owner); } |