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...> - 2002-11-05 10:42:56
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister In directory usw-pr-cvs1:/tmp/cvs-serv30123/hibernate/persister Modified Files: EntityPersister.java MultiTableEntityPersister.java Log Message: support native id generation for normalized mappings Index: EntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister/EntityPersister.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** EntityPersister.java 5 Nov 2002 03:44:01 -0000 1.36 --- EntityPersister.java 5 Nov 2002 10:42:52 -0000 1.37 *************** *** 312,319 **** * Generate the SQL that inserts a row */ ! protected String generateInsertString(boolean identityString, String identityColumnInsertString) { boolean hasPropertyColumns = columnNames.length > 0; ! boolean insertIdentifierColumns = !identityString || identityColumnInsertString!=null; String commaAfterProperties = hasPropertyColumns && ( insertIdentifierColumns || isPolymorphic() ) ? ", " : ""; String commaAfterIdentifiers = insertIdentifierColumns && isPolymorphic() ? ", " : ""; --- 312,319 ---- * Generate the SQL that inserts a row */ ! protected String generateInsertString(boolean identityInsert, String identityColumnInsertString) { boolean hasPropertyColumns = columnNames.length > 0; ! boolean insertIdentifierColumns = !identityInsert || identityColumnInsertString!=null; String commaAfterProperties = hasPropertyColumns && ( insertIdentifierColumns || isPolymorphic() ) ? ", " : ""; String commaAfterIdentifiers = insertIdentifierColumns && isPolymorphic() ? ", " : ""; *************** *** 331,337 **** .append( hasPropertyColumns ? "?" : "" ) .append(commaAfterProperties); ! if ( !identityString ) { buf.append( StringHelper.repeat( "?, ", identifierColumnNames.length-1 ) ) ! .append( identifierColumnNames.length > 0 ? "?" : "" ); } else if ( identityColumnInsertString!=null ) { --- 331,337 ---- .append( hasPropertyColumns ? "?" : "" ) .append(commaAfterProperties); ! if ( !identityInsert ) { buf.append( StringHelper.repeat( "?, ", identifierColumnNames.length-1 ) ) ! .append("?"); } else if ( identityColumnInsertString!=null ) { *************** *** 539,547 **** try { - dehydrate(null, fields, statement, session); - statement.executeUpdate(); - } catch (SQLException sqle) { --- 539,544 ---- Index: MultiTableEntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister/MultiTableEntityPersister.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** MultiTableEntityPersister.java 5 Nov 2002 03:44:01 -0000 1.26 --- MultiTableEntityPersister.java 5 Nov 2002 10:42:52 -0000 1.27 *************** *** 5,8 **** --- 5,10 ---- import cirrus.hibernate.helpers.JDBCExceptionReporter; import cirrus.hibernate.helpers.StringHelper; + import cirrus.hibernate.id.IdentifierGenerator; + import cirrus.hibernate.id.NativeGenerator; import cirrus.hibernate.loader.EntityLoader; import cirrus.hibernate.loader.SimpleEntityLoader; *************** *** 67,76 **** private transient final String[] deleteStrings; private transient final String[] insertStrings; private transient final String[] updateStrings; - private transient final String identityInsertString; private transient final String identitySelectString; private transient final boolean useIdentityColumn; ! private transient final String[] identifierColumnNames; private transient final Cascades.IdentifierValue unsavedIdentifierValue; --- 69,78 ---- private transient final String[] deleteStrings; private transient final String[] insertStrings; + private transient final String[] identityInsertStrings; private transient final String[] updateStrings; private transient final String identitySelectString; private transient final boolean useIdentityColumn; ! private transient final String[] identifierColumnNames; private transient final Cascades.IdentifierValue unsavedIdentifierValue; *************** *** 295,300 **** * The query that inserts a row, letting the database generate an id */ ! protected final String sqlIdentityInsert() { ! return identityInsertString; } --- 297,302 ---- * The query that inserts a row, letting the database generate an id */ ! protected final String[] sqlIdentityInsert() { ! return identityInsertStrings; } *************** *** 332,336 **** * Generate the SQL that inserts a row */ ! protected String[] generateInsertStrings() { String[] result = new String[tableNames.length]; for ( int j=0; j<tableNames.length; j++ ) { --- 334,338 ---- * Generate the SQL that inserts a row */ ! protected String[] generateInsertStrings(boolean identityInsert, String identityColumnInsertString) { String[] result = new String[tableNames.length]; for ( int j=0; j<tableNames.length; j++ ) { *************** *** 347,360 **** } StringBuffer buf = new StringBuffer("insert into ") ! .append( tableNames[j] ) ! .append(" ( ") ! .append( setters.toString() ) ! ! .append( StringHelper.join( ", ", tableKeyColumns[j] ) ) ! .append(" ) values ( ") ! .append( StringHelper.repeat( "?, ", count ) ) ! .append( StringHelper.repeat( "?, ", identifierColumnNames.length-1 ) ) ! .append( identifierColumnNames.length > 0 ? "?" : "" ); result[j] = buf.append(" )").toString(); --- 349,377 ---- } + boolean hasPropertyColumns = count > 0; + boolean insertIdentifierColumns = !identityInsert || j>0 || identityColumnInsertString!=null; + StringBuffer buf = new StringBuffer("insert into ") ! .append( tableNames[j] ) ! .append(" ( ") ! .append( setters.toString() ); ! ! if (insertIdentifierColumns) { ! buf.append( StringHelper.join( ", ", tableKeyColumns[j] ) ); ! } ! else if (hasPropertyColumns) { ! buf.setLength( buf.length()-2 ); ! } ! ! buf.append(" ) values ( ") ! .append( StringHelper.repeat( "?, ", count ) ); ! ! if (insertIdentifierColumns) { ! buf.append( StringHelper.repeat( "?, ", identifierColumnNames.length-1 ) ) ! .append("?"); ! } ! else if (hasPropertyColumns) { ! buf.setLength( buf.length()-2 ); ! } result[j] = buf.append(" )").toString(); *************** *** 493,497 **** * Marshall the fields of a persistent instance to a prepared statement */ ! protected int dehydrate(Serializable id, Object[] fields, PreparedStatement[] sts, SessionImplementor session) throws SQLException, HibernateException { if ( log.isTraceEnabled() ) log.trace("Dehydrating entity: " + getClassName() + '#' + id); --- 510,514 ---- * Marshall the fields of a persistent instance to a prepared statement */ ! protected int dehydrate(Serializable id, Object[] fields, PreparedStatement[] statements, SessionImplementor session) throws SQLException, HibernateException { if ( log.isTraceEnabled() ) log.trace("Dehydrating entity: " + getClassName() + '#' + id); *************** *** 500,526 **** for ( int i=0; i<tableNames.length; i++ ) { ! int index = 1; ! for (int j=0; j<hydrateSpan; j++) { ! ! if ( propertyTables[j]==i ) { ! getPropertyTypes()[j].nullSafeSet( sts[i], fields[j], index, session ); ! index += propertyColumnSpans[j]; ! } ! ! } ! if ( id!=null ) { ! getIdentifierType().nullSafeSet( sts[i], id, index, session ); ! index+=identifierColumnNames.length; } - if (i==0) versionParam = index; - } ! return versionParam; ! } // Execute the SQL: --- 517,549 ---- for ( int i=0; i<tableNames.length; i++ ) { + int index = dehydrate(id, fields, i, statements[i], session); + if (i==0) versionParam = index; + } ! return versionParam; ! ! } ! ! private int dehydrate(Serializable id, Object[] fields, int table, PreparedStatement statement, SessionImplementor session) throws SQLException, HibernateException { ! ! int index = 1; ! ! for (int j=0; j<hydrateSpan; j++) { ! if ( propertyTables[j]==table ) { ! getPropertyTypes()[j].nullSafeSet( statement, fields[j], index, session ); ! index += propertyColumnSpans[j]; } } ! if ( id!=null ) { ! getIdentifierType().nullSafeSet( statement, id, index, session ); ! index+=identifierColumnNames.length; ! } ! ! return index; } + // Execute the SQL: *************** *** 617,636 **** public Serializable insert(Object[] fields, Object object, SessionImplementor session) throws SQLException, HibernateException { ! throw new UnsupportedOperationException(); ! ! /*if ( log.isTraceEnabled() ) { ! log.trace("Inserting entity: " + className + " (native id)"); ! if (versioned) log.trace( "Version: " + Versioning.getVersion(fields, this) ); } ! // Render the SQL query ! PreparedStatement statement = session.getBatcher().prepareStatement( sqlIdentityInsert() ); try { ! ! dehydrate(null, fields, statement, session); ! statement.executeUpdate(); - } catch (SQLException sqle) { --- 640,655 ---- public Serializable insert(Object[] fields, Object object, SessionImplementor session) throws SQLException, HibernateException { ! if ( log.isTraceEnabled() ) { ! log.trace("Inserting entity: " + getClassName() + " (native id)"); ! if ( isVersioned() ) log.trace( "Version: " + Versioning.getVersion(fields, this) ); } ! String[] sql = sqlIdentityInsert(); ! ! PreparedStatement statement = session.getBatcher().prepareStatement( sql[0] ); try { ! dehydrate(null, fields, 0, statement, session); statement.executeUpdate(); } catch (SQLException sqle) { *************** *** 644,652 **** // fetch the generated id: PreparedStatement idselect = session.getBatcher().prepareStatement( sqlIdentitySelect() ); ! try { ResultSet rs = idselect.executeQuery(); - final Serializable id; try { if ( !rs.next() ) throw new HibernateException("The database returned no natively generated identity value"); --- 663,670 ---- // fetch the generated id: PreparedStatement idselect = session.getBatcher().prepareStatement( sqlIdentitySelect() ); ! final Serializable id; try { ResultSet rs = idselect.executeQuery(); try { if ( !rs.next() ) throw new HibernateException("The database returned no natively generated identity value"); *************** *** 658,662 **** log.debug("Natively generated identity: " + id); - return id; } catch (SQLException sqle) { --- 676,679 ---- *************** *** 666,670 **** finally { session.getBatcher().closeStatement(idselect); ! }*/ } --- 683,707 ---- finally { session.getBatcher().closeStatement(idselect); ! } ! ! for ( int i=1; i<tableNames.length; i++ ) { ! ! statement = session.getBatcher().prepareStatement( sql[i] ); ! ! try { ! dehydrate(id, fields, i, statement, session); ! statement.executeUpdate(); ! } ! catch (SQLException sqle) { ! JDBCExceptionReporter.logExceptions(sqle); ! throw sqle; ! } ! finally { ! session.getBatcher().closeStatement(statement); ! } ! ! } ! ! return id; } *************** *** 804,830 **** ! useIdentityColumn=false; ! //idgen = model.getIdentifier().getIdentifierGenerator(); ! /*final String identityColumnInsertString; ! useIdentityColumn = ( dialect!=null ) && dialect.supportsIdentityColumns() && ( idgen instanceof NativeGenerator ); if (useIdentityColumn) { identitySelectString = dialect.getIdentitySelectString(); identityColumnInsertString = dialect.getIdentityInsertString(); } ! else {*/ identitySelectString = null; ! //identityColumnInsertString = null; ! //} ! //MULTITABLES - //HashMap tableids = new HashMap(); - //int id = 0; - ArrayList tables = new ArrayList(); ArrayList keyColumns = new ArrayList(); tables.add(qualifiedTableName); keyColumns.add(identifierColumnNames); - //tableids.put( table, new Integer(id) ); Iterator titer = model.getTableClosureIterator(); --- 841,862 ---- ! final String identityColumnInsertString; ! IdentifierGenerator idgen = model.getIdentifier().getIdentifierGenerator(); ! useIdentityColumn = dialect.supportsIdentityColumns() && ( idgen instanceof NativeGenerator ); if (useIdentityColumn) { identitySelectString = dialect.getIdentitySelectString(); identityColumnInsertString = dialect.getIdentityInsertString(); } ! else { identitySelectString = null; ! identityColumnInsertString = null; ! } ! //MULTITABLES ArrayList tables = new ArrayList(); ArrayList keyColumns = new ArrayList(); tables.add(qualifiedTableName); keyColumns.add(identifierColumnNames); Iterator titer = model.getTableClosureIterator(); *************** *** 838,843 **** for ( int k=0; k<idColumnSpan; k++ ) key[k] = ( (Column) kiter.next() ).getName(); keyColumns.add(key); - - //tableids.put( tab, new Integer(++id) ); } } --- 870,873 ---- *************** *** 1015,1020 **** deleteStrings = generateDeleteStrings(); ! insertStrings = generateInsertStrings(); ! identityInsertString = null; //useIdentityColumn ? generateInsertString(true, identityColumnInsertString) : null; updateStrings = generateUpdateStrings(); --- 1045,1050 ---- deleteStrings = generateDeleteStrings(); ! insertStrings = generateInsertStrings(false, null); ! identityInsertStrings = useIdentityColumn ? generateInsertStrings(true, identityColumnInsertString) : null; updateStrings = generateUpdateStrings(); |
From: <one...@us...> - 2002-11-05 10:42:55
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/test In directory usw-pr-cvs1:/tmp/cvs-serv30123/hibernate/test Modified Files: Multi.hbm.xml MultiTableTest.java Log Message: support native id generation for normalized mappings Index: Multi.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Multi.hbm.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Multi.hbm.xml 5 Nov 2002 03:44:02 -0000 1.11 --- Multi.hbm.xml 5 Nov 2002 10:42:52 -0000 1.12 *************** *** 5,9 **** <class name="cirrus.hibernate.test.Simple" table="rootclass"> <id type="long" column="id_" > ! <generator class="assigned"/> </id> <version name="count" column="count_"/> --- 5,9 ---- <class name="cirrus.hibernate.test.Simple" table="rootclass"> <id type="long" column="id_" > ! <generator class="native"/> </id> <version name="count" column="count_"/> Index: MultiTableTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/MultiTableTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** MultiTableTest.java 5 Nov 2002 03:44:02 -0000 1.9 --- MultiTableTest.java 5 Nov 2002 10:42:52 -0000 1.10 *************** *** 18,66 **** } - public void testMultiTableCollections() throws Exception { - Session s = sessions.openSession(); - Transaction t = s.beginTransaction(); - Multi multi = new Multi(); - multi.setExtraProp("extra"); - //multi.setCount(666); - multi.setName("name"); - Simple simp = new Simple(); - simp.setDate( new Date() ); - simp.setName("simp"); - //simp.setCount(132); - s.save( multi, new Long(123) ); - s.save( simp, new Long(1234) ); - LessSimple ls = new LessSimple(); - ls.setOther(ls); - ls.setAnother(ls); - ls.setYetanother(ls); - ls.setName("Less Simple"); - Set set = new HashSet(); - ls.setSet(set); - set.add(multi); - set.add(simp); - s.save( ls, new Long(2) ); - t.commit(); - s.close(); - - s = sessions.openSession(); - t = s.beginTransaction(); - ls = (LessSimple) s.load( LessSimple.class, new Long(2) ); - assertTrue( ls.getOther()==ls && ls.getAnother()==ls && ls.getYetanother()==ls ); - assertTrue( ls.getSet().size()==2 ); - Iterator iter = ls.getSet().iterator(); - int foundMulti = 0; - int foundSimple = 0; - while ( iter.hasNext() ) { - Object o = iter.next(); - if ( o instanceof Simple ) foundSimple++; - if ( o instanceof Multi ) foundMulti++; - } - assertTrue( foundSimple==2 && foundMulti==1 ); - s.delete("from s in class Simple"); - t.commit(); - s.close(); - } - public void testMultiTable() throws Exception { Session s = sessions.openSession(); --- 18,21 ---- *************** *** 145,151 **** --- 100,164 ---- s.update( multi, new Long(123) ); s.delete(multi); + assertTrue( s.delete("from s in class Simple")==2); t.commit(); s.close(); + } + + public void testMultiTableCollections() throws Exception { + Session s = sessions.openSession(); + Transaction t = s.beginTransaction(); + Multi multi = new Multi(); + multi.setExtraProp("extra"); + //multi.setCount(666); + multi.setName("name"); + Simple simp = new Simple(); + simp.setDate( new Date() ); + simp.setName("simp"); + //simp.setCount(132); + s.save( multi, new Long(123) ); + s.save( simp, new Long(1234) ); + LessSimple ls = new LessSimple(); + ls.setOther(ls); + ls.setAnother(ls); + ls.setYetanother(ls); + ls.setName("Less Simple"); + Set set = new HashSet(); + ls.setSet(set); + set.add(multi); + set.add(simp); + s.save( ls, new Long(2) ); + t.commit(); + s.close(); + + s = sessions.openSession(); + t = s.beginTransaction(); + ls = (LessSimple) s.load( LessSimple.class, new Long(2) ); + assertTrue( ls.getOther()==ls && ls.getAnother()==ls && ls.getYetanother()==ls ); + assertTrue( ls.getSet().size()==2 ); + Iterator iter = ls.getSet().iterator(); + int foundMulti = 0; + int foundSimple = 0; + while ( iter.hasNext() ) { + Object o = iter.next(); + if ( o instanceof Simple ) foundSimple++; + if ( o instanceof Multi ) foundMulti++; + } + assertTrue( foundSimple==2 && foundMulti==1 ); + assertTrue( s.delete("from s in class Simple")==3 ); + t.commit(); + s.close(); + } + + public void testMultiTableNativeId() throws Exception { + Session s = sessions.openSession(); + Transaction t = s.beginTransaction(); + Multi multi = new Multi(); + multi.setExtraProp("extra"); + Long id = (Long) s.save(multi); + assertTrue( id!=null ); + s.delete(multi); + t.commit(); + s.close(); } |
From: <one...@us...> - 2002-11-05 08:04:29
|
Update of /cvsroot/hibernate/Hibernate In directory usw-pr-cvs1:/tmp/cvs-serv24191 Modified Files: changelog.txt Log Message: links page Index: changelog.txt =================================================================== RCS file: /cvsroot/hibernate/Hibernate/changelog.txt,v retrieving revision 1.256 retrieving revision 1.257 diff -C2 -d -r1.256 -r1.257 *** changelog.txt 3 Nov 2002 06:32:49 -0000 1.256 --- changelog.txt 5 Nov 2002 08:03:55 -0000 1.257 *************** *** 8,11 **** --- 8,13 ---- * Hibernate.initialize() allows the user to force initialization of a proxy or persistent collection * fix to minor bug in CodeGenerator by Max Andersen + * fixed a problem with outerjoin fetching of one-to-one associations defined on subclasses + * fixed a minor problem with proxies of classes that override finalize() Changes in version 1.1.8 (30.10.2002) |
From: <one...@us...> - 2002-11-05 08:04:08
|
Update of /cvsroot/hibernate/Hibernate/doc In directory usw-pr-cvs1:/tmp/cvs-serv24191/doc Modified Files: about.html best.html brief.html demo.html dtd.html faq.html features.html hibernate.html jmx.html menu.html performance.html tools.html tutorial.html Added Files: links.aft links.html Log Message: links page --- NEW FILE: links.aft --- #---PASS-HTML <link rel="stylesheet" href="hibernate.css" type="text/css"> *Links -------------------------------------------------------------------------- **External Documentation Tom Sedge has written a piece explaining various Hibernate association styles * http://www.xylax.net/hibernate The Cayenne project maintains a Wiki page comparing features of various Java O / R tools #---PASS-HTML <ul><li> <a href="http://c2.com/cgi-bin/wiki?ObjectRelationalToolComparison">http://c2.com/cgi-bin/wiki?ObjectRelationalToolComparison</a></li></ul> **Related Projects Hibernate uses CGLIB for proxy generation * http://cglib.sourceforge.net Hibernate can use C3P0 for connection pooling * http://sourceforge.net/projects/c3p0 Hibernate uses various pieces of Jakarta commons and Turbine JCS internally * http://jakarta.apache.org --- NEW FILE: links.html --- <link rel="stylesheet" href="hibernate.css" type="text/css"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title></title> <meta name="author" content=""> <meta name="GENERATOR" content = "Almost Free Text v5.0792; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- .Default {background-color: rgb(255,255,255); color: rgb(0,0,0); font-family: 'Tahoma'; font-size: 12pt} .Text-Background {background-color: rgb(255,255,255)} --> </style> </head> <body> <!-- Start SectLevel1 --> <h2><a name="Links">Links</a></h2> <hr> <!-- Start SectLevel2 --> <h3><a name="External Documentation">External Documentation</a></h3> <p class="Body"> Tom Sedge has written a piece explaining various Hibernate association styles </p> <ul> <li> <a href="http://www.xylax.net/hibernate">http://www.xylax.net/hibernate</a></li> </ul> <p class="Body"> The Cayenne project maintains a Wiki page comparing features of various Java O / R tools </p> <ul><li> <a href="http://c2.com/cgi-bin/wiki?ObjectRelationalToolComparison">http://c2.com/cgi-bin/wiki?ObjectRelationalToolComparison</a></li></ul><!--End Section 2--> <h3><a name="Related Projects">Related Projects</a></h3> <p class="Body"> Hibernate uses CGLIB for proxy generation </p> <ul> <li> <a href="http://cglib.sourceforge.net">http://cglib.sourceforge.net</a></li> </ul> <p class="Body"> Hibernate can use C3P0 for connection pooling </p> <ul> <li> <a href="http://sourceforge.net/projects/c3p0">http://sourceforge.net/projects/c3p0</a></li> </ul> <p class="Body"> Hibernate uses various pieces of Jakarta commons and Turbine JCS internally </p> <ul> <li> <a href="http://jakarta.apache.org">http://jakarta.apache.org</a></li> </ul> <!--End Section 2--> <!-- End SectLevel2 --> <!--End Section 1--> <!-- End SectLevel1 --> <br> <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0792</a></small> </p> </body> </html> Index: about.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/about.html,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** about.html 30 Oct 2002 13:34:25 -0000 1.15 --- about.html 5 Nov 2002 08:03:56 -0000 1.16 *************** *** 4,8 **** <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0793; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- --- 4,8 ---- <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0792; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- *************** *** 49,53 **** </p> <!--End Section 3--> ! <h4><a name="What do you mean by "service"?">What do you mean by "service"?</a></h4> <p class="Body"> Some persistence layers work by <strong>imposing</strong> a certain design upon the classes to be persisted. I'll call this the <em>frameworky</em> approach. CMP is a good example. The framework <strong>calls into</strong> the business domain objects; the framework is the client. Typically these kinds of approaches provide a managed environment in which the objects are instantiated. In some cases (eg. entity beans) it is extremely difficult to run the code without that environment. Such approaches often have a slow compile-test-debug cycle which increases development costs. Secondly we have found, at least in the case of EJB, that they often lead to strange and unnatural implementation styles. On the positive side, it is easier for the framework code to control concurrency, security and memory allocation. --- 49,53 ---- </p> <!--End Section 3--> ! <h4><a name="What do you mean by "service"?">What do you mean by "service"?</a></h4> <p class="Body"> Some persistence layers work by <strong>imposing</strong> a certain design upon the classes to be persisted. I'll call this the <em>frameworky</em> approach. CMP is a good example. The framework <strong>calls into</strong> the business domain objects; the framework is the client. Typically these kinds of approaches provide a managed environment in which the objects are instantiated. In some cases (eg. entity beans) it is extremely difficult to run the code without that environment. Such approaches often have a slow compile-test-debug cycle which increases development costs. Secondly we have found, at least in the case of EJB, that they often lead to strange and unnatural implementation styles. On the positive side, it is easier for the framework code to control concurrency, security and memory allocation. *************** *** 89,93 **** <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0793</a></small> </p> </body> </html> --- 89,93 ---- <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0792</a></small> </p> </body> </html> Index: best.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/best.html,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** best.html 20 Oct 2002 08:13:12 -0000 1.22 --- best.html 5 Nov 2002 08:03:57 -0000 1.23 *************** *** 4,8 **** <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0793; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- --- 4,8 ---- <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0792; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- *************** *** 15,19 **** <!-- Start SectLevel1 --> ! <h2><a name="Hibernate ''Best'' Practices">Hibernate <em>Best</em> Practices</a></h2> <hr> <!-- Start SectLevel3 --> --- 15,19 ---- <!-- Start SectLevel1 --> ! <h2><a name="Hibernate ''Best'' Practices">Hibernate ''Best'' Practices</a></h2> <hr> <!-- Start SectLevel3 --> *************** *** 90,94 **** <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0793</a></small> </p> </body> </html> --- 90,94 ---- <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0792</a></small> </p> </body> </html> Index: brief.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/brief.html,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** brief.html 20 Oct 2002 08:13:12 -0000 1.53 --- brief.html 5 Nov 2002 08:03:58 -0000 1.54 *************** *** 4,8 **** <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0793; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- --- 4,8 ---- <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0792; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- *************** *** 113,117 **** <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0793</a></small> </p> </body> </html> --- 113,117 ---- <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0792</a></small> </p> </body> </html> Index: demo.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/demo.html,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** demo.html 20 Oct 2002 08:13:12 -0000 1.15 --- demo.html 5 Nov 2002 08:03:58 -0000 1.16 *************** *** 4,8 **** <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0793; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- --- 4,8 ---- <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0792; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- *************** *** 110,114 **** <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0793</a></small> </p> </body> </html> --- 110,114 ---- <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0792</a></small> </p> </body> </html> Index: dtd.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/dtd.html,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** dtd.html 22 Oct 2002 20:22:16 -0000 1.20 --- dtd.html 5 Nov 2002 08:03:59 -0000 1.21 *************** *** 4,8 **** <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0793; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- --- 4,8 ---- <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0792; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- *************** *** 429,433 **** <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0793</a></small> </p> </body> </html> --- 429,433 ---- <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0792</a></small> </p> </body> </html> Index: faq.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/faq.html,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** faq.html 30 Oct 2002 15:28:05 -0000 1.38 --- faq.html 5 Nov 2002 08:04:00 -0000 1.39 *************** *** 4,8 **** <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0793; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- --- 4,8 ---- <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0792; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- *************** *** 121,125 **** </p> <!--End Section 3--> ! <h4><a name="How does readonly="true" affect the semantics of cascade="all"">How does readonly="true" affect the semantics of cascade="all"</a></h4> <p class="Body"> It doesn't. --- 121,125 ---- </p> <!--End Section 3--> ! <h4><a name="How does readonly="true" affect the semantics of cascade="all"">How does readonly="true" affect the semantics of cascade="all"</a></h4> <p class="Body"> It doesn't. *************** *** 244,248 **** </pre> <!--End Section 3--> ! <h4><a name="I removed an object from a collection mapped with cascade="all" but the object was not deleted !">I removed an object from a collection mapped with cascade="all" but the object was not deleted !</a></h4> <p class="Body"> <tt>cascade="all"</tt> cascades the <tt>delete()</tt> operation from parent to child. Hibernate <strong>never</strong> deletes an entity without an explicit call to <tt>delete()</tt>. If you aren't deleting the parent object, you will have to explicitly delete the child. --- 244,248 ---- </pre> <!--End Section 3--> ! <h4><a name="I removed an object from a collection mapped with cascade="all" but the object was not deleted !">I removed an object from a collection mapped with cascade="all" but the object was not deleted !</a></h4> <p class="Body"> <tt>cascade="all"</tt> cascades the <tt>delete()</tt> operation from parent to child. Hibernate <strong>never</strong> deletes an entity without an explicit call to <tt>delete()</tt>. If you aren't deleting the parent object, you will have to explicitly delete the child. *************** *** 293,297 **** </p> <!--End Section 3--> ! <h4><a name="I'm supplying my own connections to Hibernate and I see exceptions like: "too many opened cursors"">I'm supplying my own connections to Hibernate and I see exceptions like: "too many opened cursors"</a></h4> <p class="Body"> You must disable <tt>PreparedStatement</tt> caching by setting --- 293,297 ---- </p> <!--End Section 3--> ! <h4><a name="I'm supplying my own connections to Hibernate and I see exceptions like: "too many opened cursors"">I'm supplying my own connections to Hibernate and I see exceptions like: "too many opened cursors"</a></h4> <p class="Body"> You must disable <tt>PreparedStatement</tt> caching by setting *************** *** 445,449 **** <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0793</a></small> </p> </body> </html> --- 445,449 ---- <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0792</a></small> </p> </body> </html> Index: features.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/features.html,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** features.html 29 Oct 2002 16:09:05 -0000 1.46 --- features.html 5 Nov 2002 08:04:00 -0000 1.47 *************** *** 4,8 **** <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0793; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- --- 4,8 ---- <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0792; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- *************** *** 182,186 **** <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0793</a></small> </p> </body> </html> --- 182,186 ---- <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0792</a></small> </p> </body> </html> Index: hibernate.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/hibernate.html,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** hibernate.html 29 Oct 2002 16:09:06 -0000 1.31 --- hibernate.html 5 Nov 2002 08:04:01 -0000 1.32 *************** *** 4,8 **** <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0793; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- --- 4,8 ---- <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0792; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- *************** *** 143,147 **** <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0793</a></small> </p> </body> </html> --- 143,147 ---- <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0792</a></small> </p> </body> </html> Index: jmx.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/jmx.html,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** jmx.html 20 Oct 2002 08:13:12 -0000 1.19 --- jmx.html 5 Nov 2002 08:04:02 -0000 1.20 *************** *** 4,8 **** <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0793; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- --- 4,8 ---- <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0792; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- *************** *** 93,97 **** <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0793</a></small> </p> </body> </html> --- 93,97 ---- <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0792</a></small> </p> </body> </html> Index: menu.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/menu.html,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** menu.html 3 Sep 2002 03:03:17 -0000 1.7 --- menu.html 5 Nov 2002 08:04:02 -0000 1.8 *************** *** 23,26 **** --- 23,27 ---- <a href="api/index.html" target="mainFrame">API Javadoc</a><br> <a href="dtd.html" target="mainFrame">Mapping DTD</a><br> + <a href="links.html" target="mainFrame">External Links</a><br> <a href="http://sourceforge.net/projects/hibernate" target="mainFrame">Sourceforge Project</a><br> Index: performance.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/performance.html,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** performance.html 22 Oct 2002 18:54:52 -0000 1.24 --- performance.html 5 Nov 2002 08:04:02 -0000 1.25 *************** *** 4,8 **** <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0793; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- --- 4,8 ---- <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0792; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- *************** *** 126,130 **** <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0793</a></small> </p> </body> </html> --- 126,130 ---- <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0792</a></small> </p> </body> </html> Index: tools.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/tools.html,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** tools.html 26 Oct 2002 08:53:28 -0000 1.78 --- tools.html 5 Nov 2002 08:04:02 -0000 1.79 *************** *** 4,8 **** <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0793; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- --- 4,8 ---- <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0792; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- *************** *** 361,365 **** <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0793</a></small> </p> </body> </html> --- 361,365 ---- <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0792</a></small> </p> </body> </html> Index: tutorial.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/tutorial.html,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** tutorial.html 20 Oct 2002 08:13:12 -0000 1.80 --- tutorial.html 5 Nov 2002 08:04:02 -0000 1.81 *************** *** 4,8 **** <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0793; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- --- 4,8 ---- <title></title> <meta name="author" content=""> ! <meta name="GENERATOR" content = "Almost Free Text v5.0792; Copyright 1996-2002 Todd Coram. All rights reserved."> <style type="text/css"> <!-- *************** *** 2286,2290 **** <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0793</a></small> </p> </body> </html> --- 2286,2290 ---- <!-- End SectLevel1 --> <br> ! <p align="right"> <small>This document was generated using <a href="http://www.maplefish.com/todd/aft.html">AFT v5.0792</a></small> </p> </body> </html> |
From: <one...@us...> - 2002-11-05 07:09:20
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/test In directory usw-pr-cvs1:/tmp/cvs-serv10810/hibernate/test Modified Files: Category.hbm.xml Nameable.hbm.xml SQLFunctionsTest.java Log Message: integrated some small patches by Max Andersen Index: Category.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Category.hbm.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Category.hbm.xml 28 Oct 2002 08:00:48 -0000 1.1 --- Category.hbm.xml 5 Nov 2002 07:09:14 -0000 1.2 *************** *** 5,9 **** <class name="cirrus.hibernate.test.Category" table="category"> <id name="id"> ! <generator class="sequence"/> </id> --- 5,9 ---- <class name="cirrus.hibernate.test.Category" table="category"> <id name="id"> ! <generator class="native"/> </id> Index: Nameable.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Nameable.hbm.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Nameable.hbm.xml 30 Oct 2002 13:34:25 -0000 1.1 --- Nameable.hbm.xml 5 Nov 2002 07:09:14 -0000 1.2 *************** *** 4,8 **** <class name="cirrus.hibernate.test.Nameable"> ! <id name="key"> <generator class="native"/> </id> --- 4,8 ---- <class name="cirrus.hibernate.test.Nameable"> ! <id name="key_"> <generator class="native"/> </id> Index: SQLFunctionsTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/SQLFunctionsTest.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** SQLFunctionsTest.java 28 Oct 2002 13:44:49 -0000 1.29 --- SQLFunctionsTest.java 5 Nov 2002 07:09:14 -0000 1.30 *************** *** 8,11 **** --- 8,12 ---- import cirrus.hibernate.sql.MySQLDialect; import cirrus.hibernate.sql.SAPDBDialect; + import cirrus.hibernate.sql.SybaseDialect; import junit.framework.Test; *************** *** 27,36 **** s.find("from s in class Simple where upper( s.name ) ='SIMPLE 1'").size()==1 ); ! if ( ! (dialect instanceof MySQLDialect) ) { //My SQL has a funny concatenation operator assertTrue( s.find("from s in class Simple where lower( s.name || ' foo' ) ='simple 1 foo'").size()==1 ); } ! Simple other = new Simple(); other.setName("Simple 2"); other.setCount(12); --- 28,44 ---- s.find("from s in class Simple where upper( s.name ) ='SIMPLE 1'").size()==1 ); ! if ( !(dialect instanceof MySQLDialect) && !(dialect instanceof SybaseDialect)) { //My SQL has a funny concatenation operator assertTrue( s.find("from s in class Simple where lower( s.name || ' foo' ) ='simple 1 foo'").size()==1 ); } ! if ( (dialect instanceof SybaseDialect)) { ! assertTrue( ! s.find("from s in class Simple where lower( s.name + ' foo' ) ='simple 1 foo'").size()==1 ! ); ! } ! ! ! Simple other = new Simple(); other.setName("Simple 2"); other.setCount(12); *************** *** 131,135 **** ); return new TestSuite(SQLFunctionsTest.class); ! } } --- 139,143 ---- ); return new TestSuite(SQLFunctionsTest.class); ! } } |
From: <one...@us...> - 2002-11-05 06:46:10
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/proxy In directory usw-pr-cvs1:/tmp/cvs-serv4847/hibernate/proxy Modified Files: HibernateProxy.java LazyInitializer.java Log Message: fixed minor problem with proxies for classes that override finalize Index: HibernateProxy.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/proxy/HibernateProxy.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** HibernateProxy.java 29 Oct 2002 07:50:41 -0000 1.4 --- HibernateProxy.java 5 Nov 2002 06:46:06 -0000 1.5 *************** *** 5,15 **** public interface HibernateProxy extends Serializable { - /*public Object getImplementation_() throws HibernateException, SQLException; - public Serializable getIdentifier_(); - public SessionImplementor getSession_(); - public boolean isUninitialized_(); - public void setSession_(SessionImplementor session) throws HibernateException; - public Class getClass_();*/ - public Object writeReplace(); } --- 5,8 ---- Index: LazyInitializer.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/proxy/LazyInitializer.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** LazyInitializer.java 31 Oct 2002 15:10:57 -0000 1.9 --- LazyInitializer.java 5 Nov 2002 06:46:06 -0000 1.10 *************** *** 8,12 **** import org.apache.commons.logging.LogFactory; - import cirrus.hibernate.AssertionFailure; import cirrus.hibernate.HibernateException; import cirrus.hibernate.LazyInitializationException; --- 8,11 ---- *************** *** 20,53 **** public abstract class LazyInitializer { - //static final Method GET_IMPLEMENTATION; - //static final Method GET_IDENTIFIER; - //static final Method GET_SESSION; - //static final Method GET_CLASS; - //static final Method IS_UNINITIALIZED; - //static final Method SET_SESSION; - static final Method HASH_CODE; - static final Method EQUALS; - static final Method FINALIZE; - //static final Method WRITE_REPLACE; - - static { - try { - //GET_IMPLEMENTATION = HibernateProxy.class.getDeclaredMethod("getImplementation_", null); - //GET_CLASS = HibernateProxy.class.getDeclaredMethod("getClass_", null); - //GET_IDENTIFIER = HibernateProxy.class.getDeclaredMethod("getIdentifier_", null); - //GET_SESSION = HibernateProxy.class.getDeclaredMethod("getSession_", null); - //WRITE_REPLACE = HibernateProxy.class.getDeclaredMethod("writeReplace", null); - //IS_UNINITIALIZED = HibernateProxy.class.getDeclaredMethod("isUninitialized_", null); - //SET_SESSION = HibernateProxy.class.getDeclaredMethod("setSession_", new Class[] { SessionImplementor.class } ); - HASH_CODE = Object.class.getDeclaredMethod("hashCode", null); - EQUALS = Object.class.getDeclaredMethod("equals", new Class[] { Object.class } ); - FINALIZE = Object.class.getDeclaredMethod("finalize", null); - } - catch (Exception e) { - //cannot occur - throw new AssertionFailure( "Exception in static initializer of LazyInitializer", e ); - } - } - protected Object target = null; protected Serializable id; --- 19,22 ---- *************** *** 93,133 **** protected final Object invoke(Method method, Object[] args) throws Throwable { ! // TODO: if ( method.getDeclaringClass()!=Object or HibernateProxy ).... ! if ( "writeReplace".equals( method.getName() ) ) { ! if (target==null && session!=null ) target = session.getEntity( ! new Key( id, session.getFactory().getPersister(persistentClass) ) ! ); ! if (target==null) { ! /*if ( session==null || !session.isOpen() ) { ! return session.getFactory().getPersister(persistentClass).instantiate(id); //A little "empty" object } ! else {*/ ! return serializableProxy(); ! //} } ! else { ! return target; } } ! else if ( !overridesEquals && method.equals(HASH_CODE) ) { ! // kinda dodgy, since it redefines the hashcode of the proxied object. ! // but necessary if we are to keep proxies in HashSets without ! // forcing them to be initialized ! return new Integer( id.hashCode() ); ! } ! else if ( !overridesEquals && method.equals(EQUALS) ) { ! // less dodgy because Hibernate forces == to be same as identifier equals ! return new Boolean( id.equals( getIdentifierMethod.invoke( args[0], null ) ) ); ! } ! else if ( method.equals(getIdentifierMethod) ) { ! return id; ! } ! else if ( method.equals(FINALIZE) ) { ! return null; ! } ! else { ! return method.invoke( getImplementation(), args ); } } --- 62,110 ---- protected final Object invoke(Method method, Object[] args) throws Throwable { ! String methodName = method.getName(); ! int params = method.getParameterTypes().length; ! if ( params==0 ) { ! ! if ( "writeReplace".equals(methodName) ) { ! ! if (target==null && session!=null ) target = session.getEntity( ! new Key( id, session.getFactory().getPersister(persistentClass) ) ! ); ! if (target==null) { ! /*if ( session==null || !session.isOpen() ) { ! return session.getFactory().getPersister(persistentClass).instantiate(id); //A little "empty" object ! } ! else {*/ ! return serializableProxy(); ! //} } ! else { ! return target; ! } ! } ! else if ( !overridesEquals && "hashCode".equals(methodName) ) { ! // kinda dodgy, since it redefines the hashcode of the proxied object. ! // but necessary if we are to keep proxies in HashSets without ! // forcing them to be initialized ! return new Integer( id.hashCode() ); } + else if ( method.equals(getIdentifierMethod) ) { + return id; + } + else if ( "finalize".equals( method.getName() ) ) { + return null; + } + } ! else if ( params==1 && !overridesEquals && "equals".equals(methodName) ) { ! // less dodgy because Hibernate forces == to be same as identifier equals ! return new Boolean( id.equals( getIdentifierMethod.invoke( args[0], null ) ) ); } + + // otherwise: + return method.invoke( getImplementation(), args ); + } |
From: <one...@us...> - 2002-11-05 06:46:10
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/engine In directory usw-pr-cvs1:/tmp/cvs-serv4847/hibernate/engine Modified Files: Key.java Log Message: fixed minor problem with proxies for classes that override finalize Index: Key.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/engine/Key.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Key.java 1 Oct 2002 01:25:29 -0000 1.1 --- Key.java 5 Nov 2002 06:46:06 -0000 1.2 *************** *** 20,35 **** } public Key(Serializable id, ClassPersister p) { this( id, p.getIdentifierSpace() ); } public Key(Serializable id, CollectionPersister p) { this( id, p.getQualifiedTableName() ); } ! public Serializable getIdentifier() { return id; } ! public boolean equals(Object other) { Key otherKey = (Key) other; --- 20,44 ---- } + /** + * Construct a unique identifier for an entity class instance + */ public Key(Serializable id, ClassPersister p) { this( id, p.getIdentifierSpace() ); } + /** + * Construct a unique identifier for a collection instance + */ public Key(Serializable id, CollectionPersister p) { this( id, p.getQualifiedTableName() ); } ! ! /** ! * Get the user-visible identifier ! */ public Serializable getIdentifier() { return id; } ! public boolean equals(Object other) { Key otherKey = (Key) other; |
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader In directory usw-pr-cvs1:/tmp/cvs-serv4847/hibernate/loader Modified Files: CollectionInitializer.java CollectionLoader.java EntityLoader.java OneToManyLoader.java SimpleEntityLoader.java UniqueEntityLoader.java Log Message: fixed minor problem with proxies for classes that override finalize Index: CollectionInitializer.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/CollectionInitializer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CollectionInitializer.java 1 Oct 2002 01:25:30 -0000 1.3 --- CollectionInitializer.java 5 Nov 2002 06:46:06 -0000 1.4 *************** *** 15,18 **** --- 15,21 ---- */ public interface CollectionInitializer { + /** + * Initialize the given collection + */ public void initialize(Serializable id, PersistentCollection collection, SessionImplementor session) throws SQLException, HibernateException; } Index: CollectionLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/CollectionLoader.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CollectionLoader.java 21 Oct 2002 18:21:10 -0000 1.6 --- CollectionLoader.java 5 Nov 2002 06:46:06 -0000 1.7 *************** *** 15,18 **** --- 15,21 ---- import cirrus.hibernate.type.Type; + /** + * Loads a collection of values or a many-to-many association + */ public class CollectionLoader extends OuterJoinLoader implements CollectionInitializer { Index: EntityLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/EntityLoader.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** EntityLoader.java 5 Nov 2002 03:44:01 -0000 1.9 --- EntityLoader.java 5 Nov 2002 06:46:06 -0000 1.10 *************** *** 15,18 **** --- 15,21 ---- import cirrus.hibernate.type.Type; + /** + * Load an entity using outerjoin fetching to fetch associated entities. + */ public class EntityLoader extends OuterJoinLoader implements UniqueEntityLoader { Index: OneToManyLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/OneToManyLoader.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** OneToManyLoader.java 4 Nov 2002 08:10:49 -0000 1.10 --- OneToManyLoader.java 5 Nov 2002 06:46:06 -0000 1.11 *************** *** 16,19 **** --- 16,22 ---- import cirrus.hibernate.type.Type; + /** + * Loads one-to-many associations + */ public class OneToManyLoader extends OuterJoinLoader implements CollectionInitializer { Index: SimpleEntityLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/SimpleEntityLoader.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SimpleEntityLoader.java 2 Oct 2002 06:27:55 -0000 1.4 --- SimpleEntityLoader.java 5 Nov 2002 06:46:06 -0000 1.5 *************** *** 14,18 **** /** ! * Loads entity instances one instance per select */ public final class SimpleEntityLoader extends Loader implements UniqueEntityLoader { --- 14,18 ---- /** ! * Loads entity instances one instance per select (ie. without outerjoin fetching) */ public final class SimpleEntityLoader extends Loader implements UniqueEntityLoader { *************** *** 50,54 **** return lockMode; } ! public Object load(SessionImplementor session, Serializable id, Object object) throws HibernateException, SQLException { List list = loadEntity(session, new Object[] { id }, idType, object, id, false); --- 50,54 ---- return lockMode; } ! public Object load(SessionImplementor session, Serializable id, Object object) throws HibernateException, SQLException { List list = loadEntity(session, new Object[] { id }, idType, object, id, false); Index: UniqueEntityLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/UniqueEntityLoader.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** UniqueEntityLoader.java 1 Oct 2002 01:25:30 -0000 1.2 --- UniqueEntityLoader.java 5 Nov 2002 06:46:06 -0000 1.3 *************** *** 9,12 **** --- 9,16 ---- public interface UniqueEntityLoader { + /** + * Load an entity instance. If <tt>optionalObject</tt> is supplied, + * load the entity state into the given (uninitialized) object. + */ public Object load(SessionImplementor session, Serializable id, Object optionalObject) throws HibernateException, SQLException; } |
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader In directory usw-pr-cvs1:/tmp/cvs-serv27523/hibernate/loader Modified Files: AnsiOuterJoinGenerator.java EntityLoader.java OuterJoinGenerator.java OuterJoinLoader.java Log Message: outerjoin fetching for normalized mappings Index: AnsiOuterJoinGenerator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/AnsiOuterJoinGenerator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AnsiOuterJoinGenerator.java 4 Nov 2002 08:10:48 -0000 1.3 --- AnsiOuterJoinGenerator.java 5 Nov 2002 03:44:01 -0000 1.4 *************** *** 20,37 **** protected final String appendOuterJoinStringAfterFrom(StringBuffer buf, OuterJoinLoader.OuterJoinableAssociation assoc) { ! buf.append(" LEFT OUTER JOIN ") ! .append( assoc.subpersister.getTableName() ) ! .append(' ') ! .append(assoc.subalias ) ! .append(" ON "); String[] keyNames = assoc.subpersister.getIdentifierColumnNames(); for ( int j=0; j<assoc.foreignKeyColumns.length; j++) { ! buf.append( assoc.foreignKeyColumns[j] ) .append('=') .append(assoc.subalias) .append('.') .append( keyNames[j] ); ! if ( j<assoc.foreignKeyColumns.length-1 ) buf.append(" and "); } return buf.toString(); } --- 20,36 ---- protected final String appendOuterJoinStringAfterFrom(StringBuffer buf, OuterJoinLoader.OuterJoinableAssociation assoc) { ! StringBuffer on = new StringBuffer(20).append("ON "); String[] keyNames = assoc.subpersister.getIdentifierColumnNames(); + //TODO: refactor onto Loadable .. this is repeated in two other places for ( int j=0; j<assoc.foreignKeyColumns.length; j++) { ! on.append( assoc.foreignKeyColumns[j] ) .append('=') .append(assoc.subalias) .append('.') .append( keyNames[j] ); ! if ( j<assoc.foreignKeyColumns.length-1 ) on.append(" and "); } + buf.append(" LEFT OUTER JOIN ") + .append( assoc.subpersister.fromClauseFragment( assoc.subalias, on.toString() ) ); return buf.toString(); } Index: EntityLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/EntityLoader.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** EntityLoader.java 4 Nov 2002 08:10:49 -0000 1.8 --- EntityLoader.java 5 Nov 2002 03:44:01 -0000 1.9 *************** *** 22,26 **** public EntityLoader(Loadable persister, SessionFactoryImplementor factory) throws MappingException { ! super(factory.getDialect()); idType = new Type[] { persister.getIdentifierType() }; --- 22,26 ---- public EntityLoader(Loadable persister, SessionFactoryImplementor factory) throws MappingException { ! super( factory.getDialect() ); idType = new Type[] { persister.getIdentifierType() }; Index: OuterJoinGenerator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/OuterJoinGenerator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OuterJoinGenerator.java 28 Sep 2002 00:57:24 -0000 1.2 --- OuterJoinGenerator.java 5 Nov 2002 03:44:01 -0000 1.3 *************** *** 6,10 **** /** ! * Interface defining the methods needed to support generating the sql for * left outer joins. */ --- 6,10 ---- /** ! * Abstract class defining the methods needed to support generating the sql for * left outer joins. */ Index: OuterJoinLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/OuterJoinLoader.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** OuterJoinLoader.java 4 Nov 2002 08:10:50 -0000 1.11 --- OuterJoinLoader.java 5 Nov 2002 03:44:01 -0000 1.12 *************** *** 68,77 **** Type type = persister.getElementType(); ! String[] columns =persister.getElementColumnNames(); if ( type.isEntityType() ) { EntityType etype = (EntityType) type; ! if ( autoEager( persister.enableJoinedFetch(), etype, session ) ) // fetch many-to-many by outerjoin depending value of outer-join in mapping walkTree(etype, columns, persister, alias, associations, new HashSet(), session); } else if ( type.isComponentType() ) { --- 68,78 ---- Type type = persister.getElementType(); ! String[] columns = StringHelper.prefix( persister.getElementColumnNames(), alias + '.' ); if ( type.isEntityType() ) { EntityType etype = (EntityType) type; ! if ( autoEager( persister.enableJoinedFetch(), etype, session ) ) { // fetch many-to-many by outerjoin depending value of outer-join in mapping walkTree(etype, columns, persister, alias, associations, new HashSet(), session); + } } else if ( type.isComponentType() ) { *************** *** 87,105 **** * For an entity class, add to a list of associations to be fetched by outerjoin */ ! private final void walkTree(Loadable persister, String alias, List associations, Set classPersisters, SessionFactoryImplementor session) throws MappingException { if ( !session.enableJoinedFetch() ) return; ! Loadable qcpersister = persister; ! ! int n = qcpersister.countSubclassProperties(); for ( int i=0; i<n; i++ ) { ! Type type = qcpersister.getSubclassPropertyType(i); ! String[] columns = qcpersister.getSubclassPropertyColumnNames(i); if ( type.isEntityType() ) { EntityType etype = (EntityType) type; ! if ( autoEager( qcpersister.enableJoinedFetch(i), etype, session ) ) walkTree(etype, columns, persister, alias, associations, classPersisters, session); } else if ( type.isComponentType() ) { walkTree( (AbstractComponentType) type, columns, persister, alias, associations, classPersisters, session); } --- 88,120 ---- * For an entity class, add to a list of associations to be fetched by outerjoin */ ! private final void walkTree(final Loadable persister, String alias, List associations, Set classPersisters, SessionFactoryImplementor session) throws MappingException { if ( !session.enableJoinedFetch() ) return; ! int n = persister.countSubclassProperties(); for ( int i=0; i<n; i++ ) { ! Type type = persister.getSubclassPropertyType(i); if ( type.isEntityType() ) { EntityType etype = (EntityType) type; ! if ( autoEager( persister.enableJoinedFetch(i), etype, session ) ) { ! ! String[] columns; ! if ( etype.isOneToOne() ) { ! ! if ( persister.isDefinedOnSubclass(i) ) continue; //NOTE: workaround for problem with 1-to-1 defined on a subclass "accidently" picking up an object ! ! columns = StringHelper.prefix( ! ( (Loadable) persister ).getIdentifierColumnNames(), //The cast is safe because collections can't contain a 1-to-1 ! alias + '.' ! ); ! } ! else { ! columns= persister.toColumns(alias, i); ! } ! walkTree(etype, columns, persister, alias, associations, classPersisters, session); + } } else if ( type.isComponentType() ) { + String[] columns = persister.getSubclassPropertyColumnNames(i); walkTree( (AbstractComponentType) type, columns, persister, alias, associations, classPersisters, session); } *************** *** 111,115 **** */ private void walkTree(AbstractComponentType act, String[] cols, Object persister, String alias, List associations, Set classPersisters, SessionFactoryImplementor session) throws MappingException { ! if ( !session.enableJoinedFetch() ) return; Type[] types = act.getSubtypes(); --- 126,133 ---- */ private void walkTree(AbstractComponentType act, String[] cols, Object persister, String alias, List associations, Set classPersisters, SessionFactoryImplementor session) throws MappingException { ! if ( ! !session.enableJoinedFetch() || ! persister instanceof MultiTableEntityPersister //TODO: remove this + enable outerjoin fetching ! ) return; Type[] types = act.getSubtypes(); *************** *** 145,149 **** //TODO: remove this: ! if ( subpersister instanceof MultiTableEntityPersister ) return; if ( !classPersisters.contains(subpersister) ) { // to avoid navigating back up bidirectional associations (and circularities) --- 163,167 ---- //TODO: remove this: ! //if ( subpersister instanceof MultiTableEntityPersister ) return; if ( !classPersisters.contains(subpersister) ) { // to avoid navigating back up bidirectional associations (and circularities) *************** *** 154,170 **** //assoc.persister = persister; assoc.subpersister = subpersister; ! if ( type.isOneToOne() ) { ! assoc.foreignKeyColumns = StringHelper.prefix( ! ( (Loadable) persister ).getIdentifierColumnNames(), //The cast is safe because collections can't contain a 1-to-1 ! alias + '.' ! ); ! } ! /*else if ( persister instanceof Loadable ) { ! //TODO: deal with MultiTableEntityPersister HERE ! }*/ ! else { ! // for a collection ! assoc.foreignKeyColumns = StringHelper.prefix(columns, alias + '.'); ! } String subalias = alias( subpersister.getTableName(), associations.size() ); assoc.subalias = subalias; --- 172,176 ---- //assoc.persister = persister; assoc.subpersister = subpersister; ! assoc.foreignKeyColumns = columns; String subalias = alias( subpersister.getTableName(), associations.size() ); assoc.subalias = subalias; |
From: <one...@us...> - 2002-11-05 03:44:05
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/test In directory usw-pr-cvs1:/tmp/cvs-serv27523/hibernate/test Modified Files: Foo.java LessSimple.java Multi.hbm.xml MultiTableTest.java Qux.java Log Message: outerjoin fetching for normalized mappings Index: Foo.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Foo.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** Foo.java 28 Oct 2002 19:27:49 -0000 1.36 --- Foo.java 5 Nov 2002 03:44:02 -0000 1.37 *************** *** 380,383 **** --- 380,385 ---- this.versionTimestamp = versionTimestamp; } + + public void finalize() { } } Index: LessSimple.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/LessSimple.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LessSimple.java 4 Nov 2002 08:10:53 -0000 1.2 --- LessSimple.java 5 Nov 2002 03:44:02 -0000 1.3 *************** *** 8,11 **** --- 8,13 ---- private String foo; private Set set; + private Simple another; + private LessSimple yetanother; /** * Returns the intprop. *************** *** 54,57 **** --- 56,91 ---- public void setSet(Set set) { this.set = set; + } + + /** + * Returns the another. + * @return Simple + */ + public Simple getAnother() { + return another; + } + + /** + * Returns the yetanother. + * @return LessSimple + */ + public LessSimple getYetanother() { + return yetanother; + } + + /** + * Sets the another. + * @param another The another to set + */ + public void setAnother(Simple another) { + this.another = another; + } + + /** + * Sets the yetanother. + * @param yetanother The yetanother to set + */ + public void setYetanother(LessSimple yetanother) { + this.yetanother = yetanother; } Index: Multi.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Multi.hbm.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Multi.hbm.xml 4 Nov 2002 08:10:54 -0000 1.10 --- Multi.hbm.xml 5 Nov 2002 03:44:02 -0000 1.11 *************** *** 14,19 **** <joined-subclass name="cirrus.hibernate.test.LessSimple" table="subclass"> <superclass-key column="id_"/> ! <property name="intprop"/> <one-to-one name="other" class="cirrus.hibernate.test.LessSimple"/> <property name="foo"/> <set role="set" lazy="false"> --- 14,21 ---- <joined-subclass name="cirrus.hibernate.test.LessSimple" table="subclass"> <superclass-key column="id_"/> ! <property name="intprop" not-null="true"/> <one-to-one name="other" class="cirrus.hibernate.test.LessSimple"/> + <many-to-one name="another" column="other1" class="cirrus.hibernate.test.Simple"/> + <many-to-one name="yetanother" column="other3" class="cirrus.hibernate.test.LessSimple"/> <property name="foo"/> <set role="set" lazy="false"> *************** *** 26,30 **** <superclass-key column="sid"/> <property name="extraProp"/> ! <many-to-one name="other" class="cirrus.hibernate.test.Multi" /> <joined-subclass name="cirrus.hibernate.test.SubMulti" table="submulti"> --- 28,32 ---- <superclass-key column="sid"/> <property name="extraProp"/> ! <many-to-one name="other" column="other2" class="cirrus.hibernate.test.Multi" /> <joined-subclass name="cirrus.hibernate.test.SubMulti" table="submulti"> Index: MultiTableTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/MultiTableTest.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MultiTableTest.java 4 Nov 2002 08:10:54 -0000 1.8 --- MultiTableTest.java 5 Nov 2002 03:44:02 -0000 1.9 *************** *** 32,35 **** --- 32,38 ---- s.save( simp, new Long(1234) ); LessSimple ls = new LessSimple(); + ls.setOther(ls); + ls.setAnother(ls); + ls.setYetanother(ls); ls.setName("Less Simple"); Set set = new HashSet(); *************** *** 44,48 **** t = s.beginTransaction(); ls = (LessSimple) s.load( LessSimple.class, new Long(2) ); ! assertTrue( ls.getOther()==ls ); assertTrue( ls.getSet().size()==2 ); Iterator iter = ls.getSet().iterator(); --- 47,51 ---- t = s.beginTransaction(); ls = (LessSimple) s.load( LessSimple.class, new Long(2) ); ! assertTrue( ls.getOther()==ls && ls.getAnother()==ls && ls.getYetanother()==ls ); assertTrue( ls.getSet().size()==2 ); Iterator iter = ls.getSet().iterator(); Index: Qux.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Qux.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Qux.java 2 Nov 2002 14:32:13 -0000 1.12 --- Qux.java 5 Nov 2002 03:44:02 -0000 1.13 *************** *** 157,160 **** --- 157,162 ---- return NO_VETO; } + + protected void finalize() { } } |
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister In directory usw-pr-cvs1:/tmp/cvs-serv27523/hibernate/persister Modified Files: EntityPersister.java Loadable.java MultiTableEntityPersister.java Queryable.java Log Message: outerjoin fetching for normalized mappings Index: EntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister/EntityPersister.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** EntityPersister.java 4 Nov 2002 08:10:51 -0000 1.35 --- EntityPersister.java 5 Nov 2002 03:44:01 -0000 1.36 *************** *** 25,28 **** --- 25,29 ---- import java.util.ArrayList; import java.util.HashMap; + import java.util.HashSet; import java.util.Iterator; import java.util.Map; *************** *** 70,73 **** --- 71,75 ---- private transient final int[] propertyColumnSpans; + private transient final boolean[] definedOnSubclass; private transient final String[][] propertyColumnNames; private transient final String[][] subclassPropertyColumnNameClosure; *************** *** 159,162 **** --- 161,168 ---- } + public boolean isDefinedOnSubclass(int i) { + return definedOnSubclass[i]; + } + public String[] getIdentifierColumnNames() { return identifierColumnNames; *************** *** 773,777 **** if ( model.isPolymorphic() ) { ! discriminatorColumnName = ( (Column) model.getDiscriminator().getColumnIterator().next() ).getName(); try { discriminatorType = (DiscriminatorType) model.getDiscriminator().getType(); --- 779,785 ---- if ( model.isPolymorphic() ) { ! Value d = model.getDiscriminator(); ! if (d==null) throw new MappingException("discriminator mapping required for polymorphic persistence"); ! discriminatorColumnName = ( (Column) d.getColumnIterator().next() ).getName(); try { discriminatorType = (DiscriminatorType) model.getDiscriminator().getType(); *************** *** 798,801 **** --- 806,810 ---- propertyColumnSpans = new int[hydrateSpan]; ArrayList columns = new ArrayList(); + HashSet thisClassProperties = new HashSet(); iter = model.getPropertyClosureIterator(); *************** *** 805,808 **** --- 814,818 ---- Property prop = (Property) iter.next(); propertyColumnSpans[i] = prop.getColumnSpan(); + thisClassProperties.add(prop); String[] colNames = new String[ propertyColumnSpans[i] ]; *************** *** 831,838 **** --- 841,850 ---- ArrayList propColumns = new ArrayList(); ArrayList joinedFetchesList = new ArrayList(); + ArrayList definedBySubclass = new ArrayList(); iter = model.getSubclassPropertyClosureIterator(); while ( iter.hasNext() ) { Property prop = (Property) iter.next(); + definedBySubclass.add( new Boolean( !thisClassProperties.contains(prop) ) ); Iterator colIter = prop.getColumnIterator(); String[] cols = new String[ prop.getColumnSpan() ]; *************** *** 852,859 **** --- 864,876 ---- subclassPropertyTypeClosure = (Type[]) types.toArray(TYPE_ARRAY); subclassPropertyColumnNameClosure = (String[][]) propColumns.toArray( new String[ propColumns.size() ][] ); + joinedFetch = new int[ joinedFetchesList.size() ]; iter = joinedFetchesList.iterator(); int j=0; while ( iter.hasNext() ) joinedFetch[j++] = ( (Integer) iter.next() ).intValue(); + definedOnSubclass = new boolean[ definedBySubclass.size() ]; + iter = definedBySubclass.iterator(); + j=0; + while ( iter.hasNext() ) definedOnSubclass[j++] = ( (Boolean) iter.next() ).booleanValue(); deleteString = generateDeleteString(); *************** *** 952,955 **** --- 969,976 ---- } + public String fromClauseFragment(String name, String on) { + return fromClauseFragment(name) + ' ' + on; + } + public String getQueryWhereClause(String name) throws MappingException { *************** *** 994,997 **** --- 1015,1022 ---- return StringHelper.prefix(cols, name + '.'); + } + + public String[] toColumns(String name, int i) { + return StringHelper.prefix( subclassPropertyColumnNameClosure[i], name + '.' ); } Index: Loadable.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister/Loadable.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Loadable.java 4 Nov 2002 08:10:51 -0000 1.10 --- Loadable.java 5 Nov 2002 03:44:01 -0000 1.11 *************** *** 1,5 **** package cirrus.hibernate.persister; - import cirrus.hibernate.QueryException; import cirrus.hibernate.type.DiscriminatorType; import cirrus.hibernate.type.Type; --- 1,5 ---- + //$Id$ package cirrus.hibernate.persister; import cirrus.hibernate.type.DiscriminatorType; import cirrus.hibernate.type.Type; *************** *** 41,45 **** /** ! * Get the column names for the numbered property of this class */ public String[] getPropertyColumnNames(int i); --- 41,45 ---- /** ! * Get the column names for the numbered property of <em>this</em> class */ public String[] getPropertyColumnNames(int i); *************** *** 65,68 **** --- 65,73 ---- /** + * Is this property defined on a subclass of the mapped class? + */ + public boolean isDefinedOnSubclass(int i); + + /** * Get an array of the types of all properties of all subclasses * (optional operation) *************** *** 76,79 **** --- 81,89 ---- */ public String[] getSubclassPropertyColumnNames(int i); + /** + * Given the number of a property of a subclass, and a table alias, + * return the aliased column names + */ + public String[] toColumns(String name, int i); /** *************** *** 87,94 **** public String fromClauseFragment(String name); /** ! * Given a query alias and a property path, return the qualified ! * column name */ ! public String[] toColumns(String name, String property) throws QueryException; } --- 97,103 ---- public String fromClauseFragment(String name); /** ! * Get the from clause fragment, given a query alias and an ON clause */ ! public String fromClauseFragment(String name, String on); } Index: MultiTableEntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister/MultiTableEntityPersister.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** MultiTableEntityPersister.java 4 Nov 2002 08:10:51 -0000 1.25 --- MultiTableEntityPersister.java 5 Nov 2002 03:44:01 -0000 1.26 *************** *** 24,27 **** --- 24,28 ---- import java.util.ArrayList; import java.util.HashMap; + import java.util.HashSet; import java.util.Iterator; import java.util.Map; *************** *** 80,84 **** --- 81,87 ---- private transient final String[][] propertyColumnNames; private transient final String[][] propertyColumnNameAliases; + private transient final boolean[] definedOnSubclass; private transient final String[][] subclassPropertyColumnNameClosure; + private transient final int[] subclassPropertyTableNumberClosure; private transient final String discriminatorColumnName; *************** *** 176,179 **** --- 179,186 ---- + public boolean isDefinedOnSubclass(int i) { + return definedOnSubclass[i]; + } + public String[] getIdentifierColumnNames() { return identifierColumnNames; *************** *** 684,688 **** if ( isVersioned() ) getVersionType().nullSafeSet( statements[0], version, identifierColumnNames.length + 1, session ); ! for ( int i=0; i<tableNames.length; i++ ) { // Do the key. The key is immutable so we can use the _current_ object state - not necessarily --- 691,695 ---- if ( isVersioned() ) getVersionType().nullSafeSet( statements[0], version, identifierColumnNames.length + 1, session ); ! for ( int i=tableNames.length-1; i>=0; i-- ) { // Do the key. The key is immutable so we can use the _current_ object state - not necessarily *************** *** 921,924 **** --- 928,932 ---- ArrayList columns = new ArrayList(); + HashSet thisClassProperties = new HashSet(); iter = model.getPropertyClosureIterator(); *************** *** 927,930 **** --- 935,939 ---- while( iter.hasNext() ) { Property prop = (Property) iter.next(); + thisClassProperties.add(prop); String tabname = prop.getValue().getTable().getQualifiedName( factory.getDefaultSchema() ); propertyTables[i] = getTableId(tabname, tableNames); *************** *** 962,978 **** ArrayList joinedFetchesList = new ArrayList(); ArrayList aliases = new ArrayList(); iter = model.getSubclassPropertyClosureIterator(); while ( iter.hasNext() ) { Property prop = (Property) iter.next(); Iterator colIter = prop.getColumnIterator(); String tabname = prop.getValue().getTable().getQualifiedName( factory.getDefaultSchema() ); String[] cols = new String[ prop.getColumnSpan() ]; types.add( prop.getType() ); int l=0; while ( colIter.hasNext() ) { Column col = (Column) colIter.next(); columns.add( col.getName() ); ! coltables.add( new Integer( getTableId(tabname, subclassTableNameClosure) ) ); cols[l++]=col.getName(); aliases.add( columnAlias(col) ); --- 971,992 ---- ArrayList joinedFetchesList = new ArrayList(); ArrayList aliases = new ArrayList(); + ArrayList propTables = new ArrayList(); + ArrayList definedBySubclass = new ArrayList(); iter = model.getSubclassPropertyClosureIterator(); while ( iter.hasNext() ) { Property prop = (Property) iter.next(); + definedBySubclass.add( new Boolean( !thisClassProperties.contains(prop) ) ); Iterator colIter = prop.getColumnIterator(); String tabname = prop.getValue().getTable().getQualifiedName( factory.getDefaultSchema() ); String[] cols = new String[ prop.getColumnSpan() ]; types.add( prop.getType() ); + Integer tabnum = new Integer( getTableId(tabname, subclassTableNameClosure) ); + propTables.add(tabnum); int l=0; while ( colIter.hasNext() ) { Column col = (Column) colIter.next(); columns.add( col.getName() ); ! coltables.add(tabnum); cols[l++]=col.getName(); aliases.add( columnAlias(col) ); *************** *** 987,995 **** --- 1001,1016 ---- subclassColumnTableNumberClosure = ArrayHelper.toIntArray(coltables); subclassPropertyTypeClosure = (Type[]) types.toArray(TYPE_ARRAY); + subclassPropertyTableNumberClosure = ArrayHelper.toIntArray(propTables); + subclassPropertyColumnNameClosure = (String[][]) propColumns.toArray( new String[ propColumns.size() ][] ); + joinedFetch = new int[ joinedFetchesList.size() ]; iter = joinedFetchesList.iterator(); int j=0; while ( iter.hasNext() ) joinedFetch[j++] = ( (Integer) iter.next() ).intValue(); + definedOnSubclass = new boolean[ definedBySubclass.size() ]; + iter = definedBySubclass.iterator(); + j=0; + while ( iter.hasNext() ) definedOnSubclass[j++] = ( (Boolean) iter.next() ).booleanValue(); deleteStrings = generateDeleteStrings(); *************** *** 1109,1117 **** public String fromClauseFragment(String name) { String[] tables = subclassTableNameClosure; StringBuffer buf = new StringBuffer(100); buf.append( tables[0] ) .append(' ') ! .append(name); for ( int i=1; i<tables.length; i++ ) { buf.append(" left outer join ") --- 1130,1144 ---- public String fromClauseFragment(String name) { + return fromClauseFragment(name, ""); + } + + public String fromClauseFragment(String name, String on) { String[] tables = subclassTableNameClosure; StringBuffer buf = new StringBuffer(100); buf.append( tables[0] ) .append(' ') ! .append(name) ! .append(' ') ! .append(on); for ( int i=1; i<tables.length; i++ ) { buf.append(" left outer join ") *************** *** 1185,1188 **** --- 1212,1221 ---- return StringHelper.prefix( cols, name + ( (tab==0) ? "" : Integer.toString(tab) ) + '.' ); } + + public String[] toColumns(String name, int i) { + int tab = subclassPropertyTableNumberClosure[i]; + return StringHelper.prefix( subclassPropertyColumnNameClosure[i], name + ( (tab==0) ? "" : Integer.toString(tab) ) + '.' ); + } + public String propertySelectClauseFragment(String name, String suffix) { Index: Queryable.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister/Queryable.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Queryable.java 4 Nov 2002 08:10:52 -0000 1.5 --- Queryable.java 5 Nov 2002 03:44:02 -0000 1.6 *************** *** 3,6 **** --- 3,7 ---- import cirrus.hibernate.MappingException; + import cirrus.hibernate.QueryException; import cirrus.hibernate.type.Type; *************** *** 37,39 **** --- 38,45 ---- */ public String selectIdentifierString(String name, String suffix); + /** + * Given a query alias and a property path, return the qualified + * column name + */ + public String[] toColumns(String name, String property) throws QueryException; } |
From: <one...@us...> - 2002-11-04 08:11:26
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/query In directory usw-pr-cvs1:/tmp/cvs-serv5635/hibernate/query Modified Files: QueryTranslator.java Log Message: support for collections/associations with MultiTableEntityPersister Index: QueryTranslator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/query/QueryTranslator.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** QueryTranslator.java 3 Nov 2002 06:19:59 -0000 1.40 --- QueryTranslator.java 4 Nov 2002 08:10:52 -0000 1.41 *************** *** 499,503 **** String suffix = (size==1) ? "" : Integer.toString(k); String name = (String) returnTypes.get(k) ; ! buf.append( persisters[k].selectPropertiesString(name, suffix) ); } --- 499,503 ---- String suffix = (size==1) ? "" : Integer.toString(k); String name = (String) returnTypes.get(k) ; ! buf.append( persisters[k].propertySelectClauseFragment(name, suffix) ); } *************** *** 518,522 **** //render the " foo_table foo," bit buf.append(' ') ! .append( p.getQueryFromClause(name) ); if ( iter.hasNext() || collections.size()!=0 ) buf.append(','); --- 518,522 ---- //render the " foo_table foo," bit buf.append(' ') ! .append( p.fromClauseFragment(name) ); if ( iter.hasNext() || collections.size()!=0 ) buf.append(','); |
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister In directory usw-pr-cvs1:/tmp/cvs-serv5635/hibernate/persister Modified Files: EntityPersister.java Loadable.java MultiTableEntityPersister.java Queryable.java Log Message: support for collections/associations with MultiTableEntityPersister Index: EntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister/EntityPersister.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** EntityPersister.java 3 Nov 2002 06:19:59 -0000 1.34 --- EntityPersister.java 4 Nov 2002 08:10:51 -0000 1.35 *************** *** 175,178 **** --- 175,182 ---- } + /** + * Return an array of all column names used by all subclasses + * of the persistent class + */ public String[] getSubclassColumnClosure() { return subclassColumnClosure; *************** *** 944,948 **** } ! public String getQueryFromClause(String name) { return getTableName() + ' ' + name; } --- 948,952 ---- } ! public String fromClauseFragment(String name) { return getTableName() + ' ' + name; } *************** *** 992,996 **** } ! public String selectPropertiesString(String name, String suffix) { StringBuffer buf = new StringBuffer(30); --- 996,1000 ---- } ! public String propertySelectClauseFragment(String name, String suffix) { StringBuffer buf = new StringBuffer(30); Index: Loadable.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister/Loadable.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Loadable.java 22 Oct 2002 20:22:16 -0000 1.9 --- Loadable.java 4 Nov 2002 08:10:51 -0000 1.10 *************** *** 1,4 **** --- 1,5 ---- package cirrus.hibernate.persister; + import cirrus.hibernate.QueryException; import cirrus.hibernate.type.DiscriminatorType; import cirrus.hibernate.type.Type; *************** *** 49,54 **** * Get the fully-qualified tablename used to persist this class */ - // TODO: need to change this to String[] getTableNames() to support - // outerjoin loading for multi-table mapping public String getTableName(); --- 50,53 ---- *************** *** 79,86 **** /** ! * Return an array of all column names used by all subclasses ! * of the persistent class (optional operation) */ ! public String[] getSubclassColumnClosure() ; ! } --- 78,94 ---- /** ! * Given a query alias and an identifying suffix, render the ! * property select fragment */ ! public String propertySelectClauseFragment(String name, String suffix); ! /** ! * Get the from clause fragment, given a query alias ! */ ! public String fromClauseFragment(String name); ! /** ! * Given a query alias and a property path, return the qualified ! * column name ! */ ! public String[] toColumns(String name, String property) throws QueryException; ! } Index: MultiTableEntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister/MultiTableEntityPersister.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** MultiTableEntityPersister.java 3 Nov 2002 06:19:59 -0000 1.24 --- MultiTableEntityPersister.java 4 Nov 2002 08:10:51 -0000 1.25 *************** *** 5,8 **** --- 5,9 ---- import cirrus.hibernate.helpers.JDBCExceptionReporter; import cirrus.hibernate.helpers.StringHelper; + import cirrus.hibernate.loader.EntityLoader; import cirrus.hibernate.loader.SimpleEntityLoader; import cirrus.hibernate.loader.UniqueEntityLoader; *************** *** 148,152 **** ! UniqueEntityLoader loader = new SimpleEntityLoader(this, generateSelectString(), LockMode.READ); loaders.put( LockMode.NONE, loader ); --- 149,154 ---- ! UniqueEntityLoader loader = //new SimpleEntityLoader(this, generateSelectString(), LockMode.READ); ! new EntityLoader(this, factory); loaders.put( LockMode.NONE, loader ); *************** *** 329,333 **** int count = 0; StringBuffer setters = new StringBuffer(20); ! for (int i=0; i<columnNames.length; i++) { if ( propertyTables[i]==j ) { for ( int k=0; k<propertyColumnNames[i].length; k++ ) { --- 331,335 ---- int count = 0; StringBuffer setters = new StringBuffer(20); ! for (int i=0; i<getPropertyTypes().length; i++) { if ( propertyTables[i]==j ) { for ( int k=0; k<propertyColumnNames[i].length; k++ ) { *************** *** 929,934 **** propertyColumnSpans[i] = prop.getColumnSpan(); ! String[] colNames = new String[ propertyColumnSpans[i] ]; ! String[] aliases = new String[ propertyColumnSpans[i] ]; Iterator colIter = prop.getColumnIterator(); int j=0; --- 931,936 ---- propertyColumnSpans[i] = prop.getColumnSpan(); ! String[] propCols = new String[ propertyColumnSpans[i] ]; ! String[] propAliases = new String[ propertyColumnSpans[i] ]; Iterator colIter = prop.getColumnIterator(); int j=0; *************** *** 936,946 **** Column col = (Column) colIter.next(); String colname = col.getName(); ! colNames[j] = colname; ! aliases[j] = columnAlias(col); columns.add(colname); j++; } ! propertyColumnNames[i] = colNames; ! propertyColumnNameAliases[i] = aliases; initPropertyPaths(prop, ""); --- 938,948 ---- Column col = (Column) colIter.next(); String colname = col.getName(); ! propCols[j] = colname; ! propAliases[j] = columnAlias(col); columns.add(colname); j++; } ! propertyColumnNames[i] = propCols; ! propertyColumnNameAliases[i] = propAliases; initPropertyPaths(prop, ""); *************** *** 1012,1022 **** if ( model.isPolymorphic() ) { subclassesByDiscriminatorValue = new HashMap(); ! subclassesByDiscriminatorValue.put( discriminatorValue, mappedClass ); discriminators = new String[subclassSpan]; discriminators[subclassSpan-1] = discriminatorSQLString; tableNumbers = new int[subclassSpan]; ! tableNumbers[subclassSpan-1] = getTableId(qualifiedTableName, subclassTableNameClosure); notNullColumns = new String[subclassSpan]; ! notNullColumns[subclassSpan-1] = identifierColumnNames[0]; } else { --- 1014,1027 ---- if ( model.isPolymorphic() ) { subclassesByDiscriminatorValue = new HashMap(); ! subclassesByDiscriminatorValue.put(discriminatorValue, mappedClass); discriminators = new String[subclassSpan]; discriminators[subclassSpan-1] = discriminatorSQLString; tableNumbers = new int[subclassSpan]; ! tableNumbers[subclassSpan-1] = getTableId( ! model.getTable().getQualifiedName( factory.getDefaultSchema() ), ! subclassTableNameClosure ! ); notNullColumns = new String[subclassSpan]; ! notNullColumns[subclassSpan-1] = ( (Column) model.getTable().getPrimaryKey().getColumnIterator().next() ).getName(); } else { *************** *** 1103,1107 **** } ! public String getQueryFromClause(String name) { String[] tables = subclassTableNameClosure; StringBuffer buf = new StringBuffer(100); --- 1108,1112 ---- } ! public String fromClauseFragment(String name) { String[] tables = subclassTableNameClosure; StringBuffer buf = new StringBuffer(100); *************** *** 1181,1185 **** } ! public String selectPropertiesString(String name, String suffix) { StringBuffer buf = new StringBuffer(50); --- 1186,1190 ---- } ! public String propertySelectClauseFragment(String name, String suffix) { StringBuffer buf = new StringBuffer(50); *************** *** 1198,1203 **** } buf.append(" end as ") ! .append( getDiscriminatorColumnName() ) ! .append(suffix); } --- 1203,1207 ---- } buf.append(" end as ") ! .append( aliasColumn( getDiscriminatorColumnName(), suffix) ); } *************** *** 1212,1217 **** .append( cols[i] ) .append(" as ") ! .append(cols[i]) ! .append(suffix); } return buf.toString(); --- 1216,1220 ---- .append( cols[i] ) .append(" as ") ! .append( aliasColumn( subclassColumnClosureAliases[i], suffix) ); } return buf.toString(); Index: Queryable.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister/Queryable.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Queryable.java 26 Oct 2002 16:01:13 -0000 1.4 --- Queryable.java 4 Nov 2002 08:10:52 -0000 1.5 *************** *** 3,7 **** import cirrus.hibernate.MappingException; - import cirrus.hibernate.QueryException; import cirrus.hibernate.type.Type; --- 3,6 ---- *************** *** 29,51 **** /** - * Get the from clause fragment, given a query alias - */ - public String getQueryFromClause(String name); - /** * Get the where clause fragment, given a query alias */ public String getQueryWhereClause(String name) throws MappingException; - /** - * Given a query alias and a property path, return the qualified - * column name - */ - public String[] toColumns(String name, String property) throws QueryException; - - /** - * Given a query alias and an identifying suffix, render the - * property select fragment - */ - public String selectPropertiesString(String name, String suffix); /** * Given a query alias and an identifying suffix, render the --- 28,35 ---- |
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader In directory usw-pr-cvs1:/tmp/cvs-serv5635/hibernate/loader Modified Files: AnsiOuterJoinGenerator.java EntityLoader.java Loader.java OneToManyLoader.java OracleOuterJoinGenerator.java OuterJoinLoader.java Log Message: support for collections/associations with MultiTableEntityPersister Index: AnsiOuterJoinGenerator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/AnsiOuterJoinGenerator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AnsiOuterJoinGenerator.java 28 Sep 2002 00:57:24 -0000 1.2 --- AnsiOuterJoinGenerator.java 4 Nov 2002 08:10:48 -0000 1.3 *************** *** 27,33 **** String[] keyNames = assoc.subpersister.getIdentifierColumnNames(); for ( int j=0; j<assoc.foreignKeyColumns.length; j++) { ! buf.append( assoc.alias ) ! .append('.') ! .append( assoc.foreignKeyColumns[j] ) .append('=') .append(assoc.subalias) --- 27,31 ---- String[] keyNames = assoc.subpersister.getIdentifierColumnNames(); for ( int j=0; j<assoc.foreignKeyColumns.length; j++) { ! buf.append( assoc.foreignKeyColumns[j] ) .append('=') .append(assoc.subalias) Index: EntityLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/EntityLoader.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** EntityLoader.java 9 Oct 2002 09:14:23 -0000 1.7 --- EntityLoader.java 4 Nov 2002 08:10:49 -0000 1.8 *************** *** 40,44 **** selectString( persister, alias, suffixes[joins] ), // FROM CLAUSE ! persister.getTableName() + ' ' + alias, // OUTER JOINS (Insertion Point 1) outerJoinGenerator.outerJoinStringAfterFrom(associations), --- 40,44 ---- selectString( persister, alias, suffixes[joins] ), // FROM CLAUSE ! persister.fromClauseFragment(alias), // OUTER JOINS (Insertion Point 1) outerJoinGenerator.outerJoinStringAfterFrom(associations), Index: Loader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/Loader.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Loader.java 31 Oct 2002 14:00:26 -0000 1.23 --- Loader.java 4 Nov 2002 08:10:49 -0000 1.24 *************** *** 486,494 **** selectClause.length() + fromClause.length() + outerJoinsAfterFrom.length() + whereClause.length() + outerJoinsAfterWhere.length() + 20 ); ! buf.append("SELECT ").append(selectClause). ! append(" FROM ").append(fromClause). ! append(outerJoinsAfterFrom). ! append(" WHERE ").append(whereClause). ! append(outerJoinsAfterWhere) ; if (orderByClause!=null) buf.append(" ORDER BY ").append(orderByClause); return buf.toString(); --- 486,494 ---- selectClause.length() + fromClause.length() + outerJoinsAfterFrom.length() + whereClause.length() + outerJoinsAfterWhere.length() + 20 ); ! buf.append("SELECT ").append(selectClause) ! .append(" FROM ").append(fromClause) ! .append(outerJoinsAfterFrom) ! .append(" WHERE ").append(whereClause) ! .append(outerJoinsAfterWhere); if (orderByClause!=null) buf.append(" ORDER BY ").append(orderByClause); return buf.toString(); Index: OneToManyLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/OneToManyLoader.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** OneToManyLoader.java 21 Oct 2002 18:21:10 -0000 1.9 --- OneToManyLoader.java 4 Nov 2002 08:10:49 -0000 1.10 *************** *** 52,56 **** selectString( persister, alias, suffixes[joins] ), // FROM CLAUSE ! persister.getTableName() + ' ' + alias, // OUTER JOINS (Insertion Point 1) outerJoinGenerator.outerJoinStringAfterFrom(associations), --- 52,56 ---- selectString( persister, alias, suffixes[joins] ), // FROM CLAUSE ! persister.fromClauseFragment(alias), // OUTER JOINS (Insertion Point 1) outerJoinGenerator.outerJoinStringAfterFrom(associations), Index: OracleOuterJoinGenerator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/OracleOuterJoinGenerator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OracleOuterJoinGenerator.java 29 Sep 2002 02:42:05 -0000 1.3 --- OracleOuterJoinGenerator.java 4 Nov 2002 08:10:50 -0000 1.4 *************** *** 30,35 **** for ( int j=0; j<assoc.foreignKeyColumns.length; j++) { buf.append(" AND ") - .append( assoc.alias ) - .append('.') .append( assoc.foreignKeyColumns[j] ) .append('=') --- 30,33 ---- Index: OuterJoinLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/loader/OuterJoinLoader.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** OuterJoinLoader.java 31 Oct 2002 14:00:26 -0000 1.10 --- OuterJoinLoader.java 4 Nov 2002 08:10:50 -0000 1.11 *************** *** 46,50 **** Loadable subpersister; String[] foreignKeyColumns; // belong to persister - String alias; String subalias; } --- 46,49 ---- *************** *** 145,150 **** Loadable subpersister = (Loadable) session.getPersister( type.getPersistentClass() ); if ( !classPersisters.contains(subpersister) ) { // to avoid navigating back up bidirectional associations (and circularities) ! OuterJoinableAssociation assoc = new OuterJoinableAssociation(); associations.add(assoc); --- 144,152 ---- Loadable subpersister = (Loadable) session.getPersister( type.getPersistentClass() ); + //TODO: remove this: + if ( subpersister instanceof MultiTableEntityPersister ) return; + if ( !classPersisters.contains(subpersister) ) { // to avoid navigating back up bidirectional associations (and circularities) ! OuterJoinableAssociation assoc = new OuterJoinableAssociation(); associations.add(assoc); *************** *** 153,163 **** assoc.subpersister = subpersister; if ( type.isOneToOne() ) { ! assoc.foreignKeyColumns = ( (Loadable) persister ).getIdentifierColumnNames(); ! //The cast is safe because collections can't contain a 1-to-1 } else { ! assoc.foreignKeyColumns = columns; } - assoc.alias = alias; String subalias = alias( subpersister.getTableName(), associations.size() ); assoc.subalias = subalias; --- 155,170 ---- assoc.subpersister = subpersister; if ( type.isOneToOne() ) { ! assoc.foreignKeyColumns = StringHelper.prefix( ! ( (Loadable) persister ).getIdentifierColumnNames(), //The cast is safe because collections can't contain a 1-to-1 ! alias + '.' ! ); } + /*else if ( persister instanceof Loadable ) { + //TODO: deal with MultiTableEntityPersister HERE + }*/ else { ! // for a collection ! assoc.foreignKeyColumns = StringHelper.prefix(columns, alias + '.'); } String subalias = alias( subpersister.getTableName(), associations.size() ); assoc.subalias = subalias; *************** *** 202,205 **** --- 209,213 ---- private static final void appendSelectString(StringBuffer buf, Loadable persister, String alias, String suffix) { + //TODO: refactor this bit onto AbstractEntityPersister (its repeated in Query stuff) String[] keyCols = persister.getIdentifierColumnNames(); for ( int j=0; j<keyCols.length; j++) { *************** *** 208,230 **** .append( keyCols[j] ) .append(" AS ") ! .append( aliasColumn(keyCols[j], suffix )); if ( j != keyCols.length-1 ) buf.append(", "); } ! if ( persister.hasSubclasses() ) ! buf.append(", ") ! .append(alias) ! .append('.') ! .append( persister.getDiscriminatorColumnName() ) ! .append(" AS ") ! .append( aliasColumn(persister.getDiscriminatorColumnName(), suffix )); ! String[] cols = persister.getSubclassColumnClosure(); ! for ( int j=0; j<cols.length; j++ ) { ! buf.append(", ") ! .append( alias ) ! .append('.') ! .append( cols[j] ) ! .append(" AS ") ! .append( aliasColumn(cols[j], suffix )); ! } } --- 216,223 ---- .append( keyCols[j] ) .append(" AS ") ! .append( aliasColumn( keyCols[j], suffix ) ); if ( j != keyCols.length-1 ) buf.append(", "); } ! buf.append( persister.propertySelectClauseFragment(alias, suffix) ); } |
From: <one...@us...> - 2002-11-04 08:11:00
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/test In directory usw-pr-cvs1:/tmp/cvs-serv5635/hibernate/test Modified Files: LessSimple.java Multi.hbm.xml MultiTableTest.java Log Message: support for collections/associations with MultiTableEntityPersister Index: LessSimple.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/LessSimple.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LessSimple.java 10 Oct 2002 18:10:16 -0000 1.1 --- LessSimple.java 4 Nov 2002 08:10:53 -0000 1.2 *************** *** 2,8 **** --- 2,11 ---- package cirrus.hibernate.test; + import java.util.Set; + public class LessSimple extends Simple { private int intprop; private String foo; + private Set set; /** * Returns the intprop. *************** *** 35,38 **** --- 38,57 ---- public void setFoo(String foo) { this.foo = foo; + } + + /** + * Returns the set. + * @return Set + */ + public Set getSet() { + return set; + } + + /** + * Sets the set. + * @param set The set to set + */ + public void setSet(Set set) { + this.set = set; } Index: Multi.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/Multi.hbm.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Multi.hbm.xml 24 Oct 2002 05:20:33 -0000 1.9 --- Multi.hbm.xml 4 Nov 2002 08:10:54 -0000 1.10 *************** *** 16,20 **** <property name="intprop"/> <one-to-one name="other" class="cirrus.hibernate.test.LessSimple"/> ! <property name="foo" column="other"/> </joined-subclass> --- 16,24 ---- <property name="intprop"/> <one-to-one name="other" class="cirrus.hibernate.test.LessSimple"/> ! <property name="foo"/> ! <set role="set" lazy="false"> ! <key column="parent"/> ! <one-to-many class="cirrus.hibernate.test.Simple"/> ! </set> </joined-subclass> *************** *** 22,26 **** <superclass-key column="sid"/> <property name="extraProp"/> ! <many-to-one name="other" class="cirrus.hibernate.test.Multi"/> <joined-subclass name="cirrus.hibernate.test.SubMulti" table="submulti"> --- 26,30 ---- <superclass-key column="sid"/> <property name="extraProp"/> ! <many-to-one name="other" class="cirrus.hibernate.test.Multi" /> <joined-subclass name="cirrus.hibernate.test.SubMulti" table="submulti"> Index: MultiTableTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/test/MultiTableTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** MultiTableTest.java 11 Oct 2002 04:56:57 -0000 1.7 --- MultiTableTest.java 4 Nov 2002 08:10:54 -0000 1.8 *************** *** 3,7 **** --- 3,9 ---- import java.util.Date; + import java.util.HashSet; import java.util.Iterator; + import java.util.Set; import cirrus.hibernate.*; *************** *** 16,19 **** --- 18,62 ---- } + public void testMultiTableCollections() throws Exception { + Session s = sessions.openSession(); + Transaction t = s.beginTransaction(); + Multi multi = new Multi(); + multi.setExtraProp("extra"); + //multi.setCount(666); + multi.setName("name"); + Simple simp = new Simple(); + simp.setDate( new Date() ); + simp.setName("simp"); + //simp.setCount(132); + s.save( multi, new Long(123) ); + s.save( simp, new Long(1234) ); + LessSimple ls = new LessSimple(); + ls.setName("Less Simple"); + Set set = new HashSet(); + ls.setSet(set); + set.add(multi); + set.add(simp); + s.save( ls, new Long(2) ); + t.commit(); + s.close(); + + s = sessions.openSession(); + t = s.beginTransaction(); + ls = (LessSimple) s.load( LessSimple.class, new Long(2) ); + assertTrue( ls.getOther()==ls ); + assertTrue( ls.getSet().size()==2 ); + Iterator iter = ls.getSet().iterator(); + int foundMulti = 0; + int foundSimple = 0; + while ( iter.hasNext() ) { + Object o = iter.next(); + if ( o instanceof Simple ) foundSimple++; + if ( o instanceof Multi ) foundMulti++; + } + assertTrue( foundSimple==2 && foundMulti==1 ); + s.delete("from s in class Simple"); + t.commit(); + s.close(); + } public void testMultiTable() throws Exception { |
From: <cs...@us...> - 2002-11-04 00:55:34
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools In directory usw-pr-cvs1:/tmp/cvs-serv31063/cirrus/hibernate/tools Added Files: JdbcColumnInfo.java SchemaUpdater.java Log Message: dynamic schema update --- NEW FILE: JdbcColumnInfo.java --- package cirrus.hibernate.tools; /* * Created by IntelliJ IDEA. * User: Administrator * Date: 13.10.2002 * Time: 21:04:35 * (C) 2002 Christoph Sturm */ public class JdbcColumnInfo{ public String table; public String columnName; public String typeName; public int columnSize; public int decimalDigits; public String isNullable; } --- NEW FILE: SchemaUpdater.java --- package cirrus.hibernate.tools; import cirrus.hibernate.Datastore; import cirrus.hibernate.HibernateException; import cirrus.hibernate.sql.Dialect; import cirrus.hibernate.connection.ConnectionProvider; import cirrus.hibernate.connection.ConnectionProviderFactory; import cirrus.hibernate.tools.JdbcColumnInfo; import java.util.*; import java.sql.*; import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.Log; /* * Created by IntelliJ IDEA. * User: Administrator * Date: 13.10.2002 * Time: 19:52:56 * (C) 2002 Christoph Sturm */ public class SchemaUpdater{ Log log = LogFactory.getLog(getClass()); private ConnectionProvider cp; public SchemaUpdater(Datastore store) throws HibernateException, SQLException { this.store = store; cp = ConnectionProviderFactory.newConnectionProvider(); } public void doSchemaUpdate() throws SQLException, HibernateException { Connection connection = cp.getConnection(); Map columnInfo = getColumnInfo(connection); Statement stmt; stmt = connection.createStatement(); boolean export = true; boolean jdbc2 = false; String[] createSQL; createSQL = store.generateSchemaUpdateScript(Dialect.getDialect(), columnInfo); for(int j = 0; j < createSQL.length; j++) { final String sql = createSQL[j]; try { // if (script) System.out.println( createSQL[j] ); // if (outputFile != null) fileOutput.write( createSQL[j] + "\n" ); if (export) { if (jdbc2) { stmt.addBatch( sql ); } else { stmt.executeUpdate( sql ); } } } catch (SQLException e) { log.error( "Error while executing " + sql, e ); } } if (jdbc2) stmt.executeBatch(); stmt.close(); connection.close(); } // the next 2 functions are highly inspired by the ofbiz entity engine private Map getColumnInfo(Connection connection) { DatabaseMetaData dbData = null; try { dbData = connection.getMetaData(); } catch (SQLException sqle) { String message = "Unable to get database meta data... Error was:" + sqle.toString(); log.error(message); } log.info("Getting Column Info From Database"); Map colInfo = new HashMap(); try { String userName = dbData.supportsSchemasInTableDefinitions() ? dbData.getUserName() : null; ResultSet rsCols = dbData.getColumns(null, userName, null, null); while (rsCols.next()) { try { JdbcColumnInfo info = new JdbcColumnInfo(); info.table = rsCols.getString("TABLE_NAME"); info.table = (info.table == null) ? null : info.table.toUpperCase(); String columnName = rsCols.getString("COLUMN_NAME"); info.typeName = rsCols.getString("TYPE_NAME"); info.columnSize = rsCols.getInt("COLUMN_SIZE"); info.decimalDigits = rsCols.getInt("DECIMAL_DIGITS"); info.isNullable = rsCols.getString("IS_NULLABLE"); Map tableColInfo = (Map)colInfo.get(info.table.toLowerCase()); if (tableColInfo == null) { tableColInfo = new HashMap(); colInfo.put(info.table.toLowerCase(), tableColInfo); } tableColInfo.put(columnName.toLowerCase(), info); } catch (SQLException sqlex) { String messagex = "Error getting column info for column. Error was:" + sqlex.toString(); log.debug(messagex); continue; } } try { rsCols.close(); } catch (SQLException sqle) { String message = "Unable to close ResultSet for column list, continuing anyway... Error was:" + sqle.toString(); log.error(message); } } catch (SQLException sqle) { String message = "Error getting column meta data for Error was:" + sqle.toString() + ". Not checking columns."; log.error(message); } return colInfo; } private Set getTableNames(Connection connection) throws SQLException { DatabaseMetaData dbData = connection.getMetaData(); Set tableNames = new TreeSet(); ResultSet tableSet; try { String[] types = {"TABLE"}; String userName = dbData.supportsSchemasInTableDefinitions() ? dbData.getUserName() : null; tableSet = dbData.getTables(null, userName, null, types); } catch (SQLException sqle) { log.error("Unable to get list of table information, trying to create all tables.", sqle); // we are returning an empty set here because databases like SapDB throw an exception when there are no tables in the database return tableNames; } try { while (tableSet.next()) { try { String tableName = tableSet.getString("TABLE_NAME"); log.debug("Found Table:" + tableName); tableNames.add(tableName); } catch (SQLException sqle) { log.error("Error getting table information... Error was:", sqle); continue; } } } catch (SQLException sqle) { log.error("Error in tableSet.next(). Error was:" , sqle); } finally { try { tableSet.close(); } catch (SQLException sqle) { String message = "Unable to close ResultSet for table list, continuing anyway... Error was:" + sqle.toString(); log.error(message); } } return tableNames; } Datastore store; } |
From: <cs...@us...> - 2002-11-04 00:55:34
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl In directory usw-pr-cvs1:/tmp/cvs-serv31063/cirrus/hibernate/impl Modified Files: DatastoreImpl.java Log Message: dynamic schema update Index: DatastoreImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl/DatastoreImpl.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** DatastoreImpl.java 18 Oct 2002 11:02:20 -0000 1.19 --- DatastoreImpl.java 4 Nov 2002 00:55:30 -0000 1.20 *************** *** 201,205 **** return ArrayHelper.toStringArray(script); } ! public String[] generateSchemaCreationScript(Dialect dialect) throws HibernateException { secondPassCompile(); --- 201,205 ---- return ArrayHelper.toStringArray(script); } ! public String[] generateSchemaCreationScript(Dialect dialect) throws HibernateException { secondPassCompile(); *************** *** 233,237 **** return ArrayHelper.toStringArray(script); } ! // This method may be called many times!! private void secondPassCompile() throws MappingException { --- 233,294 ---- return ArrayHelper.toStringArray(script); } ! ! public String[] generateSchemaUpdateScript(Dialect dialect, java.util.Map tableColumnInfo) throws HibernateException { ! secondPassCompile(); ! ! ArrayList script = new ArrayList(50); ! ! Iterator iter = tables.iterator(); ! while ( iter.hasNext() ) { ! Table table = (Table) iter.next(); ! java.util.Map ci = (java.util.Map) tableColumnInfo.get(table.getName().toLowerCase()); ! if (ci == null) ! { ! script.add(table.sqlCreateString(dialect, this)); ! } ! else ! { ! final String sql = table.sqlAlterString(dialect, this, ci); ! if (sql != null) ! script.add(sql); ! } ! } ! ! iter = primaryKeys.iterator(); ! while ( iter.hasNext() ) ! { ! Constraint constraint = (Constraint) iter.next(); ! if (!tableColumnInfo.containsKey(constraint.getName())) ! script.add( constraint.sqlCreateString(dialect, this) ); ! } ! if( dialect.hasAlterTable() ) { ! iter = foreignKeys.iterator(); ! while ( iter.hasNext() ) ! { ! Constraint constraint = (Constraint) iter.next(); ! if (!tableColumnInfo.containsKey(constraint.getName())) ! script.add( constraint.sqlCreateString(dialect, this) ); ! } ! } ! ! iter = indexes.iterator(); ! while ( iter.hasNext() ) ! { ! Index constraint = (Index) iter.next(); ! if (!tableColumnInfo.containsKey(constraint.getName())) ! script.add( constraint.sqlCreateString(dialect, this) ); ! } ! ! /* ! iter = generators.values().iterator(); ! while ( iter.hasNext() ) ! { ! String[] lines = ( (PersistentIdentifierGenerator) iter.next() ).sqlCreateStrings(dialect); ! for ( int i=0; i<lines.length; i++ ) script.add( lines[i] ); ! } ! */ ! ! return ArrayHelper.toStringArray(script); ! } // This method may be called many times!! private void secondPassCompile() throws MappingException { *************** *** 265,269 **** public static final class EmptyInterceptor implements Interceptor, Serializable { /** ! * @see cirrus.hibernate.Interceptor#onDelete(Object, Object[], String[], Type[]) */ public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) { --- 322,326 ---- public static final class EmptyInterceptor implements Interceptor, Serializable { /** ! * @see cirrus.hibernate.Interceptor#onDelete(Object, Serializable id, Object[], String[], Type[]) */ public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) { |
From: <cs...@us...> - 2002-11-04 00:55:33
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/map In directory usw-pr-cvs1:/tmp/cvs-serv31063/cirrus/hibernate/map Modified Files: Table.java Log Message: dynamic schema update Index: Table.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/Table.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** Table.java 1 Oct 2002 01:25:30 -0000 1.26 --- Table.java 4 Nov 2002 00:55:30 -0000 1.27 *************** *** 9,15 **** import cirrus.hibernate.id.Assigned; import cirrus.hibernate.id.IdentifierGenerator; ! import cirrus.hibernate.id.NativeGenerator; import cirrus.hibernate.sql.Dialect; import cirrus.hibernate.sql.HSQLDialect; import cirrus.hibernate.HibernateException; public class Table implements RelationalModel { --- 9,17 ---- import cirrus.hibernate.id.Assigned; import cirrus.hibernate.id.IdentifierGenerator; ! import cirrus.hibernate.id.NativeGenerator; ! import cirrus.hibernate.sql.Dialect; import cirrus.hibernate.sql.HSQLDialect; import cirrus.hibernate.HibernateException; + import cirrus.hibernate.tools.JdbcColumnInfo; public class Table implements RelationalModel { *************** *** 20,33 **** private PrimaryKey primaryKey; private int counter=0; ! public Table() {} ! public String getQualifiedName() { return (schema==null) ? name : schema + '.' + name; } ! public String getQualifiedName(String defaultQualifier) { return ( schema==null ) ? ( (defaultQualifier==null) ? name : defaultQualifier + '.' + name ) : getQualifiedName(); } ! public String getName() { return name; --- 22,36 ---- private PrimaryKey primaryKey; private int counter=0; ! ! public Table() {} ! public String getQualifiedName() { return (schema==null) ? name : schema + '.' + name; } ! public String getQualifiedName(String defaultQualifier) { return ( schema==null ) ? ( (defaultQualifier==null) ? name : defaultQualifier + '.' + name ) : getQualifiedName(); } ! public String getName() { return name; *************** *** 52,55 **** --- 55,97 ---- } + public String sqlAlterString(Dialect dialect,Mapping p,java.util.Map columns) throws HibernateException { + + // String pkname = null; + // // Try to find out the name of the primary key to create it as identity if the NativeGenerator is used + // boolean createIdentity; + // if (primaryKey != null) { + // createIdentity = dialect.supportsIdentityColumns() && ( identifierGenerator instanceof NativeGenerator ); + // pkname = ( (Column) primaryKey.getColumnIterator().next() ).getName(); + // } + // else + // createIdentity = false; + + Iterator iter=columnIterator(); + StringBuffer buf=new StringBuffer(50); + while (iter.hasNext()) { + Column col=(Column) iter.next(); + + String name=col.getName().toLowerCase(); + JdbcColumnInfo ci=(JdbcColumnInfo) columns.get(name); + + if (ci==null) { + // the column doesnt exist at all. + if (buf.length()!=0) + buf.append(','); + buf.append("add ").append(name).append(' ').append(col.getSqlType(dialect,p)); + if (col.isUnique()&&dialect.supportsUnique()) { + buf.append(" unique"); + } + } + + } + + if (buf.length()==0) + return null; + + return new StringBuffer("alter table ").append(getQualifiedName()).append(" ").append(buf).toString(); + + } + public String sqlCreateString(Dialect dialect, Mapping p) throws HibernateException { StringBuffer buf = new StringBuffer("create table ") *************** *** 66,70 **** else createIdentity = false; ! Iterator iter = columnIterator(); while ( iter.hasNext() ) { --- 108,112 ---- else createIdentity = false; ! Iterator iter = columnIterator(); while ( iter.hasNext() ) { *************** *** 74,78 **** .append(' ') .append( col.getSqlType(dialect, p) ); ! if ( createIdentity && col.getName().equals(pkname) ) { buf.append(' ') --- 116,120 ---- .append(' ') .append( col.getSqlType(dialect, p) ); ! if ( createIdentity && col.getName().equals(pkname) ) { buf.append(' ') *************** *** 87,91 **** } } ! if ( col.isUnique() && dialect.supportsUnique() ) { buf.append(" unique"); --- 129,133 ---- } } ! if ( col.isUnique() && dialect.supportsUnique() ) { buf.append(" unique"); *************** *** 104,108 **** } buf.append(")"); ! return buf.toString(); } --- 146,150 ---- } buf.append(")"); ! return buf.toString(); } *************** *** 110,114 **** return "drop table " + getQualifiedName() + dialect.getCascadeConstraintsString(); } ! public IdentifierGenerator getIdentifierGenerator() { return identifierGenerator; } --- 152,157 ---- return "drop table " + getQualifiedName() + dialect.getCascadeConstraintsString(); } ! ! public IdentifierGenerator getIdentifierGenerator() { return identifierGenerator; } *************** *** 124,128 **** this.primaryKey = primaryKey; } ! public int generateConstraintID() { return counter++; } --- 167,172 ---- this.primaryKey = primaryKey; } ! ! public int generateConstraintID() { return counter++; } *************** *** 138,140 **** } ! --- 182,185 ---- } ! ! |
From: <cs...@us...> - 2002-11-04 00:55:33
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate In directory usw-pr-cvs1:/tmp/cvs-serv31063/cirrus/hibernate Modified Files: Datastore.java Log Message: dynamic schema update Index: Datastore.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/Datastore.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Datastore.java 18 Oct 2002 11:02:19 -0000 1.30 --- Datastore.java 4 Nov 2002 00:55:30 -0000 1.31 *************** *** 1 **** ! //$Id$ package cirrus.hibernate; import java.io.InputStream; import java.util.Properties; import org.w3c.dom.Document; import cirrus.hibernate.sql.Dialect; /** An instance of <tt>Datastore</tt> represents an entire mapping from a set of Java classes to a relational model. Usually an application will configure a single instance of <tt>Datastore</tt>, obtain a single instance of <tt>SessionFactory</tt> and then instantiate <tt>Session</tt>s in threads servicing client requests. The <tt>Datastore</tt> is meant as a configuration-time object.<br> <br> New instances are provided by the factory method <tt>Hibernate.createDatastore()</tt><br> <br> It is not intended that implementors be threadsafe. @see SessionFactory @see Hibernate#createDatastore() */ public interface Datastore { /** Obtain a factory for <tt>Session</tt>s. Connections may be provided by the application or according to System properties. @return SessionFactory @throws HibernateException */ public SessionFactory buildSessionFactory() throws HibernateException; /** Obtain a factory for <tt>Session</tt>s. Connections may be provided by the application or according to the given <tt>Properties</tt>. @param connectionProps connection properties @return SessionFactory @throws HibernateException */ public SessionFactory buildSessionFactory(Properties connectionProps) throws HibernateException; /** Obtain a factory for <tt>Session</tt>s, specifying an <tt>Interceptor</tt>. Connections may be provided by the application or according to System properties. @return SessionFactory @param interceptor a factory-scoped interceptor @throws HibernateException */ public SessionFactory buildSessionFactory(Interceptor interceptor) throws HibernateException; /** Obtain a factory for <tt>Session</tt>s, specifying an <tt>Interceptor</tt>. Connections may be provided by the application or according to the given <tt>Properties</tt>. @param connectionProps connection properties @param interceptor intercepts important session events @return SessionFactory @throws HibernateException */ public SessionFactory buildSessionFactory(Properties connectionProps, Interceptor interceptor) throws HibernateException; /** Load persistence mappings from an XML file. @param xmlFile the filename @return Datastore @throws MappingException */ public Datastore storeFile(String xmlFile) throws MappingException; /** Load persistence mappings from an XML file, using <tt>getResourceAsStream()</tt>. @param path the resource path @param classLoader the <tt>ClassLoader</tt> to use @return Datastore @throws MappingException */ public Datastore storeResource(String path, ClassLoader classLoader) throws MappingException; /** Load persistence mappings from an input stream containing XML. @param xmlInputStream an input stream containing XML data @return Datastore @throws MappingException */ public Datastore storeInputStream(InputStream xmlInputStream) throws MappingException; /** Load persistence mappings from a string containing XML. @param xml @return Datastore @throws MappingException */ public Datastore storeXML(String xml) throws MappingException; /** Load persistence mappings from a parsed XML document. @param doc @return Datastore @throws MappingException */ public Datastore storeDocument(Document doc) throws MappingException; /** Look for a mapping file for the given class using a naming convention. <tt>storeClass(eg.Foo.class)</tt> looks for <tt>eg/Foo.hbm.xml</tt> in the classpath. @param persistentClass the mapped persistent class @return Datastore @throws MappingException */ public Datastore storeClass(Class persistentClass) throws MappingException; /** Look for mapping files in a jar. Any files with names ending in <tt>.hbm.xml</tt> will be assumed to be mapping documents. @param resource the .jar file @return Datastore @throws MappingException */ public Datastore storeJar(String resource) throws MappingException; /** Generates a list of SQL statements that may be used to create the tables needed by this Datastore. @param dialect the script SQL dialect */ public String[] generateSchemaCreationScript(Dialect dialect) throws HibernateException; /** Generates a list of SQL statements that may be used to drop the tables needed by this Datastore. @param dialect the script SQL dialect */ public String[] generateDropSchemaScript(Dialect dialect) throws HibernateException; } \ No newline at end of file --- 1,157 ---- ! //$Id$ ! package cirrus.hibernate; ! ! import java.io.InputStream; ! import java.util.Properties; ! ! import org.w3c.dom.Document; ! import cirrus.hibernate.sql.Dialect; ! ! /** ! An instance of <tt>Datastore</tt> represents an entire mapping from a set of ! Java classes to a relational model. Usually an application will configure a ! single instance of <tt>Datastore</tt>, obtain a single instance of ! <tt>SessionFactory</tt> and then instantiate <tt>Session</tt>s in ! threads servicing client requests. The <tt>Datastore</tt> is meant as a ! configuration-time object.<br> ! <br> ! New instances are provided by the factory method ! <tt>Hibernate.createDatastore()</tt><br> ! <br> ! It is not intended that implementors be threadsafe. ! ! @see SessionFactory ! @see Hibernate#createDatastore() ! */ ! public interface Datastore { ! ! /** ! Obtain a factory for <tt>Session</tt>s. Connections may be provided by the application ! or according to System properties. ! ! @return SessionFactory ! @throws HibernateException ! */ ! public SessionFactory buildSessionFactory() throws HibernateException; ! ! /** ! Obtain a factory for <tt>Session</tt>s. Connections may be provided by the application ! or according to the given <tt>Properties</tt>. ! ! @param connectionProps connection properties ! @return SessionFactory ! @throws HibernateException ! */ ! public SessionFactory buildSessionFactory(Properties connectionProps) ! throws HibernateException; ! ! /** ! Obtain a factory for <tt>Session</tt>s, specifying an <tt>Interceptor</tt>. Connections ! may be provided by the application or according to System properties. ! ! @return SessionFactory ! @param interceptor a factory-scoped interceptor ! @throws HibernateException ! */ ! public SessionFactory buildSessionFactory(Interceptor interceptor) throws HibernateException; ! ! /** ! Obtain a factory for <tt>Session</tt>s, specifying an <tt>Interceptor</tt>. Connections ! may be provided by the application or according to the given <tt>Properties</tt>. ! ! @param connectionProps connection properties ! @param interceptor intercepts important session events ! @return SessionFactory ! @throws HibernateException ! */ ! public SessionFactory buildSessionFactory(Properties connectionProps, Interceptor interceptor) ! throws HibernateException; ! ! /** ! Load persistence mappings from an XML file. ! ! @param xmlFile the filename ! @return Datastore ! @throws MappingException ! */ ! public Datastore storeFile(String xmlFile) throws MappingException; ! ! /** ! Load persistence mappings from an XML file, using <tt>getResourceAsStream()</tt>. ! ! @param path the resource path ! @param classLoader the <tt>ClassLoader</tt> to use ! @return Datastore ! @throws MappingException ! */ ! public Datastore storeResource(String path, ClassLoader classLoader) ! throws MappingException; ! /** ! Load persistence mappings from an input stream containing XML. ! ! @param xmlInputStream an input stream containing XML data ! @return Datastore ! @throws MappingException ! */ ! public Datastore storeInputStream(InputStream xmlInputStream) ! throws MappingException; ! ! /** ! Load persistence mappings from a string containing XML. ! ! @param xml ! @return Datastore ! @throws MappingException ! */ ! public Datastore storeXML(String xml) throws MappingException; ! ! /** ! Load persistence mappings from a parsed XML document. ! ! @param doc ! @return Datastore ! @throws MappingException ! */ ! public Datastore storeDocument(Document doc) throws MappingException; ! ! /** ! Look for a mapping file for the given class using a naming convention. ! <tt>storeClass(eg.Foo.class)</tt> looks for <tt>eg/Foo.hbm.xml</tt> in ! the classpath. ! ! @param persistentClass the mapped persistent class ! @return Datastore ! @throws MappingException ! */ ! public Datastore storeClass(Class persistentClass) throws MappingException; ! ! /** ! Look for mapping files in a jar. Any files with names ending in <tt>.hbm.xml</tt> ! will be assumed to be mapping documents. ! ! @param resource the .jar file ! @return Datastore ! @throws MappingException ! */ ! public Datastore storeJar(String resource) throws MappingException; ! ! /** ! Generates a list of SQL statements that may be used to create the tables ! needed by this Datastore. ! ! @param dialect the script SQL dialect ! */ ! public String[] generateSchemaCreationScript(Dialect dialect) ! throws HibernateException; ! ! /** ! Generates a list of SQL statements that may be used to drop the tables ! needed by this Datastore. ! ! @param dialect the script SQL dialect ! */ ! public String[] generateDropSchemaScript(Dialect dialect) ! throws HibernateException; ! String[] generateSchemaUpdateScript(Dialect dialect, java.util.Map tableColumnInfo) throws HibernateException; ! ! } |
From: <one...@us...> - 2002-11-03 06:32:52
|
Update of /cvsroot/hibernate/Hibernate In directory usw-pr-cvs1:/tmp/cvs-serv18484 Modified Files: changelog.txt Log Message: changelog.txt Index: changelog.txt =================================================================== RCS file: /cvsroot/hibernate/Hibernate/changelog.txt,v retrieving revision 1.255 retrieving revision 1.256 diff -C2 -d -r1.255 -r1.256 *** changelog.txt 2 Nov 2002 14:32:11 -0000 1.255 --- changelog.txt 3 Nov 2002 06:32:49 -0000 1.256 *************** *** 7,10 **** --- 7,11 ---- * support for quoted SQL identifiers (patch by Jean-Francois Nadeau) * Hibernate.initialize() allows the user to force initialization of a proxy or persistent collection + * fix to minor bug in CodeGenerator by Max Andersen Changes in version 1.1.8 (30.10.2002) |
From: <one...@us...> - 2002-11-03 06:20:03
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister In directory usw-pr-cvs1:/tmp/cvs-serv16944/hibernate/persister Modified Files: EntityPersister.java MultiTableEntityPersister.java Log Message: removed reliance upon discriminator column in MultiTableEntityPersistser Index: EntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister/EntityPersister.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** EntityPersister.java 31 Oct 2002 14:00:25 -0000 1.33 --- EntityPersister.java 3 Nov 2002 06:19:59 -0000 1.34 *************** *** 413,417 **** * Marshall the fields of a persistent instance to a prepared statement */ ! protected void dehydrate(Serializable id, Object[] fields, PreparedStatement st, SessionImplementor session) throws SQLException, HibernateException { if ( log.isTraceEnabled() ) log.trace("Dehydrating entity: " + getClassName() + '#' + id); --- 413,417 ---- * Marshall the fields of a persistent instance to a prepared statement */ ! protected int dehydrate(Serializable id, Object[] fields, PreparedStatement st, SessionImplementor session) throws SQLException, HibernateException { if ( log.isTraceEnabled() ) log.trace("Dehydrating entity: " + getClassName() + '#' + id); *************** *** 423,427 **** } ! if ( id!=null ) getIdentifierType().nullSafeSet( st, id, index, session ); } --- 423,432 ---- } ! if ( id!=null ) { ! getIdentifierType().nullSafeSet( st, id, index, session ); ! index += identifierColumnNames.length; ! } ! ! return index; } *************** *** 639,646 **** //Now write the values of fields onto the prepared statement ! dehydrate(id, fields, statement, session); if ( isVersioned() ) { ! getVersionType().nullSafeSet( statement, oldVersion, columnNames.length + identifierColumnNames.length + 1, session ); check( statement.executeUpdate(), id ); } --- 644,651 ---- //Now write the values of fields onto the prepared statement ! int versionParam = dehydrate(id, fields, statement, session); if ( isVersioned() ) { ! getVersionType().nullSafeSet( statement, oldVersion, versionParam, session ); check( statement.executeUpdate(), id ); } *************** *** 745,752 **** } catch (ClassCastException cce) { ! throw new MappingException("Bad identifier type: " + model.getDiscriminator().getType().getClass().getName() ); } catch (Exception e) { ! throw new MappingException("Could not parse cascade-to-save value: " + cts); } } --- 750,757 ---- } catch (ClassCastException cce) { ! throw new MappingException("Bad identifier type: " + model.getIdentifier().getType().getClass().getName() ); } catch (Exception e) { ! throw new MappingException("Could not parse unsaved-value: " + cts); } } Index: MultiTableEntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/persister/MultiTableEntityPersister.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** MultiTableEntityPersister.java 27 Oct 2002 03:11:33 -0000 1.23 --- MultiTableEntityPersister.java 3 Nov 2002 06:19:59 -0000 1.24 *************** *** 30,33 **** --- 30,34 ---- import cirrus.hibernate.AssertionFailure; + import cirrus.hibernate.Hibernate; import cirrus.hibernate.HibernateException; import cirrus.hibernate.LockMode; *************** *** 82,86 **** private transient final String discriminatorColumnName; private transient final String versionColumnName; - private transient final int versionParam; private transient final String[] columnNames; --- 83,86 ---- *************** *** 95,98 **** --- 95,101 ---- private transient final HashMap subclassesByDiscriminatorValue; + private transient final String[] discriminators; + private transient final String[] notNullColumns; + private transient final int[] tableNumbers; private transient final HashMap columnNamesByPropertyPath = new HashMap(); *************** *** 341,355 **** .append( StringHelper.join( ", ", tableKeyColumns[j] ) ) - .append( j==0 && isPolymorphic() ? ", " + getDiscriminatorColumnName() : "" ) //to handle discriminator column .append(" ) values ( ") .append( StringHelper.repeat( "?, ", count ) ) .append( StringHelper.repeat( "?, ", identifierColumnNames.length-1 ) ) .append( identifierColumnNames.length > 0 ? "?" : "" ); ! ! if ( j==0 && isPolymorphic() ) { ! buf.append(", ") ! .append(discriminatorSQLString); //to handle discriminator column ! } ! result[j] = buf.append(" )").toString(); --- 344,352 ---- .append( StringHelper.join( ", ", tableKeyColumns[j] ) ) .append(" ) values ( ") .append( StringHelper.repeat( "?, ", count ) ) .append( StringHelper.repeat( "?, ", identifierColumnNames.length-1 ) ) .append( identifierColumnNames.length > 0 ? "?" : "" ); ! result[j] = buf.append(" )").toString(); *************** *** 382,388 **** .append("select ") .append(tables[0] + '.') ! .append( StringHelper.join( ", " + tables[0] + '.', identifierColumnNames ) ) ! .append( hasSubclasses() ? ", " + getDiscriminatorColumnName() : "" ) ! .append( subclassColumnClosure.length==0 ? "" : ", "); for ( int i=0; i<subclassColumnClosure.length; i++ ) { buf.append( subclassTableNameClosure[ subclassColumnTableNumberClosure[i] ] ) --- 379,399 ---- .append("select ") .append(tables[0] + '.') ! .append( StringHelper.join( ", " + tables[0] + '.', identifierColumnNames ) ); ! ! if ( hasSubclasses() ) { ! buf.append(", case"); ! for ( int i=0; i< discriminators.length; i++ ) { ! buf.append(" when ") ! .append( tables[ tableNumbers[i] ] ) ! .append('.') ! .append( notNullColumns[i] ) ! .append(" is not null then ") ! .append( discriminators[i] ); ! } ! buf.append(" end as ") ! .append( getDiscriminatorColumnName() ); ! } ! ! buf.append( subclassColumnClosure.length==0 ? "" : ", "); for ( int i=0; i<subclassColumnClosure.length; i++ ) { buf.append( subclassTableNameClosure[ subclassColumnTableNumberClosure[i] ] ) *************** *** 473,480 **** * Marshall the fields of a persistent instance to a prepared statement */ ! protected void dehydrate(Serializable id, Object[] fields, PreparedStatement[] sts, SessionImplementor session) throws SQLException, HibernateException { if ( log.isTraceEnabled() ) log.trace("Dehydrating entity: " + getClassName() + '#' + id); for ( int i=0; i<tableNames.length; i++ ) { --- 484,493 ---- * Marshall the fields of a persistent instance to a prepared statement */ ! protected int dehydrate(Serializable id, Object[] fields, PreparedStatement[] sts, SessionImplementor session) throws SQLException, HibernateException { if ( log.isTraceEnabled() ) log.trace("Dehydrating entity: " + getClassName() + '#' + id); + int versionParam = 0; + for ( int i=0; i<tableNames.length; i++ ) { *************** *** 489,495 **** } ! if ( id!=null ) getIdentifierType().nullSafeSet( sts[i], id, index, session ); } } --- 502,515 ---- } ! if ( id!=null ) { ! getIdentifierType().nullSafeSet( sts[i], id, index, session ); ! index+=identifierColumnNames.length; ! } ! ! if (i==0) versionParam = index; } + + return versionParam; } *************** *** 703,707 **** try { ! dehydrate(id, fields, statements, session); if ( isVersioned() ) getVersionType().nullSafeSet( statements[0], oldVersion, versionParam, session ); --- 723,727 ---- try { ! int versionParam = dehydrate(id, fields, statements, session); if ( isVersioned() ) getVersionType().nullSafeSet( statements[0], oldVersion, versionParam, session ); *************** *** 732,736 **** Table table = model.getRootTable(); qualifiedTableName = table.getQualifiedName( factory.getDefaultSchema() ); - versionParam = table.getColumnSpan(); // IDENTIFIER --- 752,755 ---- *************** *** 791,798 **** --- 810,822 ---- //MULTITABLES + //HashMap tableids = new HashMap(); + //int id = 0; + ArrayList tables = new ArrayList(); ArrayList keyColumns = new ArrayList(); tables.add(qualifiedTableName); keyColumns.add(identifierColumnNames); + //tableids.put( table, new Integer(id) ); + Iterator titer = model.getTableClosureIterator(); while ( titer.hasNext() ) { *************** *** 805,808 **** --- 829,834 ---- for ( int k=0; k<idColumnSpan; k++ ) key[k] = ( (Column) kiter.next() ).getName(); keyColumns.add(key); + + //tableids.put( tab, new Integer(++id) ); } } *************** *** 846,853 **** } catch (ClassCastException cce) { ! throw new MappingException("Bad identifier type: " + model.getDiscriminator().getType().getClass().getName() ); } catch (Exception e) { ! throw new MappingException("Could not parse cascade-to-save value: " + cts); } } --- 872,879 ---- } catch (ClassCastException cce) { ! throw new MappingException("Bad identifier type: " + model.getIdentifier().getType().getClass().getName() ); } catch (Exception e) { ! throw new MappingException("Could not parse unsaved-value: " + cts); } } *************** *** 865,873 **** if ( model.isPolymorphic() ) { ! discriminatorColumnName = ( (Column) model.getDiscriminator().getColumnIterator().next() ).getName(); try { ! discriminatorType = (DiscriminatorType) model.getDiscriminator().getType(); ! discriminatorValue = discriminatorType.stringToObject( model.getDiscriminatorValue() ); ! discriminatorSQLString = discriminatorType.objectToSQLString(discriminatorValue); } catch (ClassCastException cce) { --- 891,899 ---- if ( model.isPolymorphic() ) { ! discriminatorColumnName = "clazz_"; try { ! discriminatorType = (DiscriminatorType) Hibernate.INTEGER; ! discriminatorValue = new Integer(0); ! discriminatorSQLString = "0"; } catch (ClassCastException cce) { *************** *** 979,1005 **** Class mappedClass = model.getPersistentClass(); ! iter = model.getSubclassIterator(); int subclassSpan = model.getSubclassSpan() + 1; subclassClosure = new Class[subclassSpan]; ! subclassClosure[0] = mappedClass; if ( model.isPolymorphic() ) { subclassesByDiscriminatorValue = new HashMap(); subclassesByDiscriminatorValue.put( discriminatorValue, mappedClass ); } else { subclassesByDiscriminatorValue = null; } ! // SUBCLASSES ! ! int k=1; while ( iter.hasNext() ) { Subclass sc = (Subclass) iter.next(); subclassClosure[k] = sc.getPersistentClass(); try { ! if ( model.isPolymorphic() ) subclassesByDiscriminatorValue.put( ! discriminatorType.stringToObject( sc.getDiscriminatorValue() ), ! sc.getPersistentClass() ! ); } catch (Exception e) { --- 1005,1046 ---- Class mappedClass = model.getPersistentClass(); ! // SUBCLASSES ! int subclassSpan = model.getSubclassSpan() + 1; subclassClosure = new Class[subclassSpan]; ! subclassClosure[subclassSpan-1] = mappedClass; if ( model.isPolymorphic() ) { subclassesByDiscriminatorValue = new HashMap(); subclassesByDiscriminatorValue.put( discriminatorValue, mappedClass ); + discriminators = new String[subclassSpan]; + discriminators[subclassSpan-1] = discriminatorSQLString; + tableNumbers = new int[subclassSpan]; + tableNumbers[subclassSpan-1] = getTableId(qualifiedTableName, subclassTableNameClosure); + notNullColumns = new String[subclassSpan]; + notNullColumns[subclassSpan-1] = identifierColumnNames[0]; } else { subclassesByDiscriminatorValue = null; + discriminators = null; + tableNumbers = null; + notNullColumns = null; } ! iter = model.getSubclassIterator(); ! int k=0; while ( iter.hasNext() ) { Subclass sc = (Subclass) iter.next(); subclassClosure[k] = sc.getPersistentClass(); try { ! if ( model.isPolymorphic() ) { ! Object disc = new Integer(k+1); ! subclassesByDiscriminatorValue.put( disc, sc.getPersistentClass() ); ! discriminators[k] = disc.toString(); ! tableNumbers[k] = getTableId( ! sc.getTable().getQualifiedName( factory.getDefaultSchema() ), ! subclassTableNameClosure ! ); ! notNullColumns[k] = ( (Column) sc.getTable().getPrimaryKey().getColumnIterator().next() ).getName(); ! } } catch (Exception e) { *************** *** 1010,1013 **** --- 1051,1055 ---- hasColumns = columnNames.length!=0; + } *************** *** 1092,1111 **** public String getQueryWhereClause(String name) throws MappingException { if ( isInherited() ) { ! StringBuffer buf = new StringBuffer(40); ! buf.append(name) .append('.') ! .append( getDiscriminatorColumnName() ) ! .append(" in ("); ! Class[] subclasses = getSubclassClosure(); ! for ( int i=0; i<subclasses.length; i++ ) { ! buf.append( ! ( (Queryable) factory.getPersister( subclasses[i] ) ) ! .getDiscriminatorSQLString() ! ); ! if (i<subclasses.length-1) buf.append(", "); ! } ! buf.append(") "); ! return buf.toString(); } else { --- 1134,1149 ---- public String getQueryWhereClause(String name) throws MappingException { + //TODO: change to name3.id is not null + if ( isInherited() ) { ! int last = tableNumbers.length-1; ! int tab = tableNumbers[last]; ! return new StringBuffer(40) ! .append(name) ! .append( (tab==0) ? "" : Integer.toString(tab) ) .append('.') ! .append( notNullColumns[last] ) ! .append(" is not null ") ! .toString(); } else { *************** *** 1123,1127 **** ! public String[] toColumn(String name, String property) throws QueryException { String[] idcols = super.toColumns(name, property); --- 1161,1165 ---- ! public String[] toColumns(String name, String property) throws QueryException { String[] idcols = super.toColumns(name, property); *************** *** 1145,1158 **** public String selectPropertiesString(String name, String suffix) { ! StringBuffer buf = new StringBuffer(30); if ( hasSubclasses() ) { ! String discr = getDiscriminatorColumnName(); ! buf.append(", ") ! .append(name) ! .append('.') ! .append(discr) ! .append(" as ") ! .append(discr).append(suffix); } --- 1183,1203 ---- public String selectPropertiesString(String name, String suffix) { ! StringBuffer buf = new StringBuffer(50); if ( hasSubclasses() ) { ! buf.append(", case"); ! for ( int i=0; i< discriminators.length; i++ ) { ! buf.append(" when ") ! .append(name); ! int tab = tableNumbers[i]; ! if (tab!=0) buf.append(tab); ! buf.append('.') ! .append( notNullColumns[i] ) ! .append(" is not null then ") ! .append( discriminators[i] ); ! } ! buf.append(" end as ") ! .append( getDiscriminatorColumnName() ) ! .append(suffix); } |
From: <one...@us...> - 2002-11-03 06:20:03
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/map In directory usw-pr-cvs1:/tmp/cvs-serv16944/hibernate/map Modified Files: PersistentClass.java RootClass.java Log Message: removed reliance upon discriminator column in MultiTableEntityPersistser Index: PersistentClass.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/PersistentClass.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** PersistentClass.java 27 Oct 2002 03:11:33 -0000 1.38 --- PersistentClass.java 3 Nov 2002 06:19:59 -0000 1.39 *************** *** 114,127 **** return n; } public Iterator getSubclassIterator() { Iterator[] iters = new Iterator[ subclasses.size() + 1 ]; - iters[0] = subclasses.iterator(); Iterator iter = subclasses.iterator(); ! int i=1; while ( iter.hasNext() ) { iters[i++] = ( (Subclass) iter.next() ).getSubclassIterator(); } return new JoinedIterator(iters); } public void addProperty(Property p) { properties.add(p); --- 114,136 ---- return n; } + /** + * Iterate over subclasses in a special 'order', most derived subclasses + * first. + */ public Iterator getSubclassIterator() { Iterator[] iters = new Iterator[ subclasses.size() + 1 ]; Iterator iter = subclasses.iterator(); ! int i=0; while ( iter.hasNext() ) { iters[i++] = ( (Subclass) iter.next() ).getSubclassIterator(); } + iters[i] = subclasses.iterator(); return new JoinedIterator(iters); } + + public Iterator getDirectSubclasses() { + return subclasses.iterator(); + } + public void addProperty(Property p) { properties.add(p); Index: RootClass.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/map/RootClass.java,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** RootClass.java 31 Oct 2002 14:00:27 -0000 1.48 --- RootClass.java 3 Nov 2002 06:19:59 -0000 1.49 *************** *** 64,70 **** public void setPolymorphic(boolean polymorphic) { this.polymorphic = polymorphic; - if (polymorphic && discriminator == null ) { - discriminator = new Value( Hibernate.STRING, table, "class" ); - } } --- 64,67 ---- |
From: <one...@us...> - 2002-11-03 06:20:03
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/query In directory usw-pr-cvs1:/tmp/cvs-serv16944/hibernate/query Modified Files: QueryTranslator.java Log Message: removed reliance upon discriminator column in MultiTableEntityPersistser Index: QueryTranslator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/query/QueryTranslator.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** QueryTranslator.java 31 Oct 2002 14:06:00 -0000 1.39 --- QueryTranslator.java 3 Nov 2002 06:19:59 -0000 1.40 *************** *** 145,149 **** catch (Exception e) { log.debug("unexpected query compilation problem", e); ! QueryException qe = new QueryException("Incorrect query syntax"); qe.setQueryString(queryString); throw qe; --- 145,149 ---- catch (Exception e) { log.debug("unexpected query compilation problem", e); ! QueryException qe = new QueryException("Incorrect query syntax", e); qe.setQueryString(queryString); throw qe; |
From: <one...@us...> - 2002-11-02 22:55:32
|
Update of /cvsroot/hibernate/Hibernate/lib In directory usw-pr-cvs1:/tmp/cvs-serv25034 Added Files: cglib.jar Log Message: cglib rc2 fixed |
From: <one...@us...> - 2002-11-02 15:48:59
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen In directory usw-pr-cvs1:/tmp/cvs-serv28216 Modified Files: BasicRenderer.java Log Message: fixed another bug Index: BasicRenderer.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/tools/codegen/BasicRenderer.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** BasicRenderer.java 2 Nov 2002 15:33:42 -0000 1.11 --- BasicRenderer.java 2 Nov 2002 15:48:54 -0000 1.12 *************** *** 87,99 **** if(!field.isIdentifier() || (field.isIdentifier() && !field.isGenerated())) { fullCons = fullCons + field.getType() + " " + field.getName(); ! if(fields.hasNext()) { ! fullCons = fullCons + ", "; ! fullConsArgCount++; ! } } } ! if(fullConsArgCount>0) { // only remove the last , and space if there was an arg! ! fullCons = fullCons.substring(0, fullCons.length() - 2); ! } writer.println(fullCons + ") {"); for(Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { --- 87,96 ---- if(!field.isIdentifier() || (field.isIdentifier() && !field.isGenerated())) { fullCons = fullCons + field.getType() + " " + field.getName(); ! fullCons = fullCons + ", "; ! fullConsArgCount++; } } ! if ( fullCons.endsWith(", ") ) fullCons = fullCons.substring(0, fullCons.length()-2); ! writer.println(fullCons + ") {"); for(Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { *************** *** 126,130 **** } } ! minCons = minCons.substring(0, minCons.length() - 2); writer.println(minCons + ") {"); for(Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { --- 123,128 ---- } } ! if ( minCons.endsWith(", ") ) minCons = minCons.substring(0, minCons.length()-2); ! writer.println(minCons + ") {"); for(Iterator fields = classMapping.getFields().iterator(); fields.hasNext();) { |