You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(22) |
Nov
(308) |
Dec
(131) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(369) |
Feb
(171) |
Mar
(236) |
Apr
(187) |
May
(218) |
Jun
(217) |
Jul
(127) |
Aug
(448) |
Sep
(270) |
Oct
(231) |
Nov
(422) |
Dec
(255) |
2004 |
Jan
(111) |
Feb
(73) |
Mar
(338) |
Apr
(351) |
May
(349) |
Jun
(495) |
Jul
(394) |
Aug
(1048) |
Sep
(499) |
Oct
(142) |
Nov
(269) |
Dec
(638) |
2005 |
Jan
(825) |
Feb
(1272) |
Mar
(593) |
Apr
(690) |
May
(950) |
Jun
(958) |
Jul
(767) |
Aug
(839) |
Sep
(525) |
Oct
(449) |
Nov
(585) |
Dec
(455) |
2006 |
Jan
(603) |
Feb
(656) |
Mar
(195) |
Apr
(114) |
May
(136) |
Jun
(100) |
Jul
(128) |
Aug
(68) |
Sep
(7) |
Oct
(1) |
Nov
(1) |
Dec
(8) |
2007 |
Jan
(4) |
Feb
(3) |
Mar
(8) |
Apr
(16) |
May
(5) |
Jun
(4) |
Jul
(6) |
Aug
(23) |
Sep
(15) |
Oct
(5) |
Nov
(7) |
Dec
(5) |
2008 |
Jan
(5) |
Feb
(1) |
Mar
(1) |
Apr
(5) |
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
(1) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(3) |
Dec
(2) |
2013 |
Jan
(1) |
Feb
|
Mar
(2) |
Apr
(1) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(2) |
Jun
(1) |
Jul
|
Aug
(1) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <one...@us...> - 2003-05-07 15:09:09
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv18694/hibernate/test Modified Files: FooBarTest.java ParentChildTest.java Log Message: much better fix for problem with normalized mapping and querying associations Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** FooBarTest.java 3 May 2003 09:05:45 -0000 1.62 --- FooBarTest.java 7 May 2003 15:09:06 -0000 1.63 *************** *** 1149,1152 **** --- 1149,1154 ---- s.delete(baz2); s.flush(); + s.connection().commit(); + s.close(); } Index: ParentChildTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/ParentChildTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ParentChildTest.java 15 Apr 2003 04:19:17 -0000 1.10 --- ParentChildTest.java 7 May 2003 15:09:06 -0000 1.11 *************** *** 137,140 **** --- 137,144 ---- "1-1 query" ); + assertTrue( + ( (Object[]) s.find("from Parent p join p.child c where p.count=66").get(0) ).length==2, + "1-1 query" + ); s.find("select c, c.parent from c in class net.sf.hibernate.test.Child order by c.parent.count"); s.find("select c, c.parent from c in class net.sf.hibernate.test.Child where c.parent.count=66 order by c.parent.count"); |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql In directory sc8-pr-cvs1:/tmp/cvs-serv18694/hibernate/hql Modified Files: FromParser.java PathExpressionParser.java QueryTranslator.java SelectParser.java WhereParser.java Log Message: much better fix for problem with normalized mapping and querying associations Index: FromParser.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql/FromParser.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** FromParser.java 3 Mar 2003 09:30:57 -0000 1.11 --- FromParser.java 7 May 2003 15:09:04 -0000 1.12 *************** *** 6,10 **** import net.sf.hibernate.QueryException; ! import net.sf.hibernate.persister.Loadable; import net.sf.hibernate.sql.JoinFragment; import net.sf.hibernate.util.StringHelper; --- 6,10 ---- import net.sf.hibernate.QueryException; ! import net.sf.hibernate.persister.Queryable; import net.sf.hibernate.sql.JoinFragment; import net.sf.hibernate.util.StringHelper; *************** *** 27,31 **** private boolean expectingAs; private boolean afterJoinType; ! private Loadable classPersister; private int joinType; --- 27,31 ---- private boolean expectingAs; private boolean afterJoinType; ! private Queryable classPersister; private int joinType; *************** *** 129,133 **** if (afterClass) { // treat it as a classname ! Loadable p = q.getPersisterUsingImports(token); if (p==null) throw new QueryException("persister not found: " + token); q.addFromClass(alias, p); --- 129,133 ---- if (afterClass) { // treat it as a classname ! Queryable p = q.getPersisterUsingImports(token); if (p==null) throw new QueryException("persister not found: " + token); q.addFromClass(alias, p); *************** *** 153,157 **** // in the "old" HQL style ! Loadable p = q.getPersisterUsingImports(token); if (p!=null) { // starts with the name of a mapped class (new style) --- 153,157 ---- // in the "old" HQL style ! Queryable p = q.getPersisterUsingImports(token); if (p!=null) { // starts with the name of a mapped class (new style) Index: PathExpressionParser.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql/PathExpressionParser.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** PathExpressionParser.java 3 May 2003 06:58:30 -0000 1.18 --- PathExpressionParser.java 7 May 2003 15:09:04 -0000 1.19 *************** *** 8,12 **** import net.sf.hibernate.collection.CollectionPersister; import net.sf.hibernate.persister.ClassPersister; - import net.sf.hibernate.persister.Loadable; import net.sf.hibernate.persister.Queryable; import net.sf.hibernate.sql.JoinFragment; --- 8,11 ---- *************** *** 59,63 **** private boolean continuation; private int joinType = JoinFragment.INNER_JOIN; //default mode - private boolean endsWithCollectionProperty = false; void setJoinType(int joinType) { --- 58,61 ---- *************** *** 66,74 **** private void addJoin(String table, String name, String[] rhsCols, QueryTranslator q) throws QueryException { - addJoin(table, name, name, rhsCols, q); - } - private void addJoin(String table, String name, String concreteAlias, String[] rhsCols, QueryTranslator q) throws QueryException { String[] lhsCols = currentColumns(q); ! join.addJoin(table, name, concreteAlias, lhsCols, rhsCols, joinType); } --- 64,69 ---- private void addJoin(String table, String name, String[] rhsCols, QueryTranslator q) throws QueryException { String[] lhsCols = currentColumns(q); ! join.addJoin(table, name, lhsCols, rhsCols, joinType); } *************** *** 78,82 **** currentName = q.createNameFor(clazz); q.addType(currentName, clazz); ! Loadable p = q.getPersister(clazz); join.addJoin( p.getTableName(), currentName, joinColumns, p.getIdentifierColumnNames(), joinType ); return currentName; --- 73,77 ---- currentName = q.createNameFor(clazz); q.addType(currentName, clazz); ! Queryable p = q.getPersister(clazz); join.addJoin( p.getTableName(), currentName, joinColumns, p.getIdentifierColumnNames(), joinType ); return currentName; *************** *** 175,196 **** CollectionPersister collPersister = q.getCollectionPersister(collectionRole); String[] colNames = collPersister.getKeyColumnNames(); - String name= q.createNameForCollection(collectionRole); ! ! String tableName; ! String concreteAlias; ! if ( collPersister.isOneToMany() && !endsWithCollectionProperty ) { ! Queryable persister = q.getPersister( ( (EntityType) collPersister.getElementType() ).getPersistentClass() ); ! tableName = persister.getTableName(); ! concreteAlias = persister.getConcreteClassAlias(name); ! if ( joinType!=JoinFragment.INNER_JOIN && !name.equals(concreteAlias) ) ! throw new QueryException("outer and full join to collection of a subclass not currently supported by this mapping strategy: " +path); ! } ! else { ! tableName = collPersister.getQualifiedTableName(); ! concreteAlias=name; ! } ! ! addJoin(tableName, name, concreteAlias, colNames, q); if ( collPersister.hasWhere() ) join.addCondition( collPersister.getSQLWhereString(name) ); doCollectionProperty(token, collPersister, name); --- 170,176 ---- CollectionPersister collPersister = q.getCollectionPersister(collectionRole); String[] colNames = collPersister.getKeyColumnNames(); String name= q.createNameForCollection(collectionRole); ! String tableName = collPersister.getQualifiedTableName(); ! addJoin(tableName, name, colNames, q); if ( collPersister.hasWhere() ) join.addCondition( collPersister.getSQLWhereString(name) ); doCollectionProperty(token, collPersister, name); *************** *** 277,281 **** public void end(QueryTranslator q) throws QueryException { - endsWithCollectionProperty = false; ignoreInitialJoin = false; --- 257,260 ---- *************** *** 303,326 **** String[] keyCols = collPersister.getKeyColumnNames(); - String concreteAlias; JoinFragment ojf = q.createJoinFragment(); if ( collPersister.isOneToMany() ) { Queryable persister = q.getPersister( ( (EntityType) collPersister.getElementType() ).getPersistentClass() ); - ojf.addCrossJoin( persister.getTableName(), collectionName ); ojf.addJoins( persister.fromJoinFragment(collectionName, true, false), persister.whereJoinFragment(collectionName, true, false) ); - concreteAlias = persister.getConcreteClassAlias(collectionName); - } - else { - ojf.addCrossJoin( collPersister.getQualifiedTableName(), collectionName ); - concreteAlias = collectionName; } if (!continuation) { ! addJoin( collPersister.getQualifiedTableName(), concreteAlias, keyCols, q ); } ! join.addCondition(concreteAlias, indexCols, " = "); String[] eltCols = collPersister.getElementColumnNames(); --- 282,299 ---- String[] keyCols = collPersister.getKeyColumnNames(); JoinFragment ojf = q.createJoinFragment(); + ojf.addCrossJoin( collPersister.getQualifiedTableName(), collectionName ); if ( collPersister.isOneToMany() ) { Queryable persister = q.getPersister( ( (EntityType) collPersister.getElementType() ).getPersistentClass() ); ojf.addJoins( persister.fromJoinFragment(collectionName, true, false), persister.whereJoinFragment(collectionName, true, false) ); } if (!continuation) { ! addJoin( collPersister.getQualifiedTableName(), collectionName, keyCols, q ); } ! join.addCondition(collectionName, indexCols, " = "); String[] eltCols = collPersister.getElementColumnNames(); *************** *** 445,449 **** else { q.addCollection(collectionName, collectionRole); ! Loadable p = q.getPersister(clazz); elementName = q.createNameFor(clazz); String[] keyColumnNames = p.getIdentifierColumnNames(); --- 418,422 ---- else { q.addCollection(collectionName, collectionRole); ! Queryable p = q.getPersister(clazz); elementName = q.createNameFor(clazz); String[] keyColumnNames = p.getIdentifierColumnNames(); *************** *** 510,527 **** throw new QueryException("expecting 'elements' or 'indices' after: " + path); } - } - - /** - * Very ugly hack to allow collection paths to be processed correctly - * for normalized mappings - */ - public final void setPath(String path) { - endsWithCollectionProperty = path.endsWith(COLLECTION_ELEMENTS) || - path.endsWith(COLLECTION_INDICES) || - path.endsWith(COLLECTION_SIZE) || - path.endsWith(COLLECTION_MAX_INDEX) || - path.endsWith(COLLECTION_MAX_ELEMENT) || - path.endsWith(COLLECTION_MIN_INDEX) || - path.endsWith(COLLECTION_MIN_ELEMENT); } --- 483,486 ---- Index: QueryTranslator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql/QueryTranslator.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** QueryTranslator.java 3 May 2003 06:58:30 -0000 1.26 --- QueryTranslator.java 7 May 2003 15:09:04 -0000 1.27 *************** *** 308,312 **** } ! void addFromClass(String name, Loadable classPersister) { JoinFragment ojf = createJoinFragment(); ojf.addCrossJoin( classPersister.getTableName(), name ); --- 308,312 ---- } ! void addFromClass(String name, Queryable classPersister) { JoinFragment ojf = createJoinFragment(); ojf.addCrossJoin( classPersister.getTableName(), name ); *************** *** 486,490 **** for ( int k=0; k<size; k++ ) { String name = (String) returnTypes.get(k); ! String suffix = size==1 ? StringHelper.EMPTY_STRING : Integer.toString(k) + StringHelper.UNDERSCORE; sql.addSelectFragmentString( persisters[k].identifierSelectFragment(name, suffix) ); } --- 486,492 ---- for ( int k=0; k<size; k++ ) { String name = (String) returnTypes.get(k); ! String suffix = size==1 ? ! StringHelper.EMPTY_STRING : ! Integer.toString(k) + StringHelper.UNDERSCORE; sql.addSelectFragmentString( persisters[k].identifierSelectFragment(name, suffix) ); } *************** *** 511,515 **** int size = returnTypes.size(); for ( int k=0; k<size; k++ ) { ! String suffix = (size==1) ? StringHelper.EMPTY_STRING : Integer.toString(k) + StringHelper.UNDERSCORE; String name = (String) returnTypes.get(k) ; sql.addSelectFragmentString( persisters[k].propertySelectFragment(name, suffix) ); --- 513,519 ---- int size = returnTypes.size(); for ( int k=0; k<size; k++ ) { ! String suffix = (size==1) ? ! StringHelper.EMPTY_STRING : ! Integer.toString(k) + StringHelper.UNDERSCORE; String name = (String) returnTypes.get(k) ; sql.addSelectFragmentString( persisters[k].propertySelectFragment(name, suffix) ); *************** *** 657,673 **** //if (keyColumnNames.length!=1) throw new QueryException("composite-key collection in filter: " + collectionRole); JoinFragment join = createJoinFragment(); if ( persister.isOneToMany() ) { ! Queryable classPersister = getPersister( ( (EntityType) persister.getElementType() ).getPersistentClass() ); ! String concreteAlias = classPersister.getConcreteClassAlias(elementName); ! join.addCrossJoin( classPersister.getTableName(), elementName ); ! join.addCondition(concreteAlias, keyColumnNames, " = ?"); ! if ( persister.hasWhere() ) join.addCondition( persister.getSQLWhereString(concreteAlias) ); } else { //many-to-many ! String collectionName = createNameForCollection(collectionRole); addCollection(collectionName, collectionRole); - join.addCrossJoin( persister.getQualifiedTableName(), collectionName ); - join.addCondition(collectionName, keyColumnNames, " = ?"); Queryable p = getPersister( elemType.getPersistentClass() ); --- 661,672 ---- //if (keyColumnNames.length!=1) throw new QueryException("composite-key collection in filter: " + collectionRole); + String collectionName; JoinFragment join = createJoinFragment(); if ( persister.isOneToMany() ) { ! collectionName = elementName; } else { //many-to-many ! collectionName = createNameForCollection(collectionRole); addCollection(collectionName, collectionRole); Queryable p = getPersister( elemType.getPersistentClass() ); *************** *** 681,686 **** JoinFragment.INNER_JOIN ); - if ( persister.hasWhere() ) join.addCondition( persister.getSQLWhereString(collectionName) ); } addFrom(elementName, elemType.getPersistentClass(), join); --- 680,687 ---- JoinFragment.INNER_JOIN ); } + join.addCrossJoin( persister.getQualifiedTableName(), collectionName ); + join.addCondition(collectionName, keyColumnNames, " = ?"); + if ( persister.hasWhere() ) join.addCondition( persister.getSQLWhereString(collectionName) ); addFrom(elementName, elemType.getPersistentClass(), join); Index: SelectParser.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql/SelectParser.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** SelectParser.java 3 May 2003 06:58:30 -0000 1.11 --- SelectParser.java 7 May 2003 15:09:05 -0000 1.12 *************** *** 121,125 **** else if (aggregate) { if (!ready) throw new QueryException("( expected after aggregate function in SELECT"); - aggregatePathExpressionParser.setPath(token); ParserHelper.parse(aggregatePathExpressionParser, q.unalias(token), ParserHelper.PATH_SEPARATORS, q); --- 121,124 ---- *************** *** 136,140 **** else { if (!ready) throw new QueryException(", expected in SELECT"); - pathExpressionParser.setPath(token); ParserHelper.parse(pathExpressionParser, q.unalias(token), ParserHelper.PATH_SEPARATORS, q); if ( pathExpressionParser.isCollectionValued() ) { --- 135,138 ---- Index: WhereParser.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql/WhereParser.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** WhereParser.java 3 May 2003 06:58:30 -0000 1.13 --- WhereParser.java 7 May 2003 15:09:05 -0000 1.14 *************** *** 357,362 **** preprocess(token, q); - pathExpressionParser.setPath(token); - StringTokenizer tokens = new StringTokenizer(token, ".", true); pathExpressionParser.start(q); --- 357,360 ---- |
From: <one...@us...> - 2003-05-07 15:09:09
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv18694/hibernate/impl Modified Files: SessionImpl.java Log Message: much better fix for problem with normalized mapping and querying associations Index: SessionImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionImpl.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** SessionImpl.java 25 Apr 2003 05:56:33 -0000 1.39 --- SessionImpl.java 7 May 2003 15:09:05 -0000 1.40 *************** *** 429,434 **** public Batcher getBatcher() { if (batcher==null) batcher = factory.useJdbcBatch() ? ! (Batcher) new BatchingBatcher(this) : ! (Batcher) new NonBatchingBatcher(this); return batcher; --- 429,434 ---- public Batcher getBatcher() { if (batcher==null) batcher = factory.useJdbcBatch() ? ! (Batcher) new BatchingBatcher(this) : ! (Batcher) new NonBatchingBatcher(this); return batcher; |
From: <one...@us...> - 2003-05-07 15:09:09
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader In directory sc8-pr-cvs1:/tmp/cvs-serv18694/hibernate/loader Modified Files: EntityLoader.java Loader.java OneToManyLoader.java OuterJoinLoader.java Log Message: much better fix for problem with normalized mapping and querying associations Index: EntityLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/EntityLoader.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** EntityLoader.java 25 Apr 2003 03:40:34 -0000 1.14 --- EntityLoader.java 7 May 2003 15:09:05 -0000 1.15 *************** *** 11,14 **** --- 11,15 ---- import net.sf.hibernate.engine.SessionImplementor; import net.sf.hibernate.persister.Loadable; + import net.sf.hibernate.persister.Queryable; import net.sf.hibernate.sql.ConditionFragment; import net.sf.hibernate.type.Type; *************** *** 29,33 **** String condition = new ConditionFragment() .setTableAlias(alias) ! .setCondition( persister.getIdentifierColumnNames(), "?" ) .toFragmentString(); --- 30,34 ---- String condition = new ConditionFragment() .setTableAlias(alias) ! .setCondition( ( (Queryable) persister ).getIdentifierColumnNames(), "?" ) .toFragmentString(); Index: Loader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/Loader.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Loader.java 4 May 2003 06:09:39 -0000 1.23 --- Loader.java 7 May 2003 15:09:05 -0000 1.24 *************** *** 96,101 **** int maxRows = (selection==null || selection.getMaxRows()==null) ? ! Integer.MAX_VALUE : ! selection.getMaxRows().intValue(); final Loadable[] persisters = getPersisters(); --- 96,101 ---- int maxRows = (selection==null || selection.getMaxRows()==null) ? ! Integer.MAX_VALUE : ! selection.getMaxRows().intValue(); final Loadable[] persisters = getPersisters(); Index: OneToManyLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/OneToManyLoader.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** OneToManyLoader.java 25 Apr 2003 03:40:35 -0000 1.13 --- OneToManyLoader.java 7 May 2003 15:09:05 -0000 1.14 *************** *** 42,49 **** String alias = alias( collectionPersister.getQualifiedTableName(), 0 ); - String collAlias = persister.getConcreteClassAlias(alias); String whereString=""; ! if ( collPersister.hasWhere() ) whereString = " and " + collPersister.getSQLWhereString(collAlias); List associations = walkTree(persister, alias, session); --- 42,48 ---- String alias = alias( collectionPersister.getQualifiedTableName(), 0 ); String whereString=""; ! if ( collPersister.hasWhere() ) whereString = " and " + collPersister.getSQLWhereString(alias); List associations = walkTree(persister, alias, session); *************** *** 56,60 **** Select select = new Select() .setSelectClause( ! collPersister.selectClauseFragment(collAlias) + ( joins==0 ? StringHelper.EMPTY_STRING : ", " + selectString(associations) ) + ", " + --- 55,59 ---- Select select = new Select() .setSelectClause( ! collPersister.selectClauseFragment(alias) + ( joins==0 ? StringHelper.EMPTY_STRING : ", " + selectString(associations) ) + ", " + *************** *** 66,70 **** ) .setWhereClause( ! new ConditionFragment().setTableAlias(collAlias) .setCondition( collPersister.getKeyColumnNames(), "?" ) .toFragmentString() --- 65,69 ---- ) .setWhereClause( ! new ConditionFragment().setTableAlias(alias) .setCondition( collPersister.getKeyColumnNames(), "?" ) .toFragmentString() *************** *** 76,80 **** persister.whereJoinFragment(alias, true, true) ); ! if ( collPersister.hasOrdering() ) select.setOrderByClause( collPersister.getSQLOrderByString(collAlias) ); sql = select.toStatementString(); --- 75,79 ---- persister.whereJoinFragment(alias, true, true) ); ! if ( collPersister.hasOrdering() ) select.setOrderByClause( collPersister.getSQLOrderByString(alias) ); sql = select.toStatementString(); Index: OuterJoinLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/OuterJoinLoader.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** OuterJoinLoader.java 3 May 2003 07:14:30 -0000 1.17 --- OuterJoinLoader.java 7 May 2003 15:09:05 -0000 1.18 *************** *** 50,55 **** public static final class OuterJoinableAssociation { public Loadable subpersister; ! public String[] foreignKeyColumns; // belong to persister public String subalias; } --- 50,57 ---- public static final class OuterJoinableAssociation { public Loadable subpersister; ! public String[] foreignKeyColumns; // belong to other persister public String subalias; + public String foreignKeyalias; + public boolean isOneToOne; } *************** *** 78,82 **** // fetch many-to-many by outerjoin depending value of outer-join in mapping String[] columns = StringHelper.prefix( persister.getElementColumnNames(), alias + StringHelper.DOT ); ! walkTree(etype, columns, persister, associations, new HashSet(), session); } } --- 80,84 ---- // fetch many-to-many by outerjoin depending value of outer-join in mapping String[] columns = StringHelper.prefix( persister.getElementColumnNames(), alias + StringHelper.DOT ); ! walkTree(etype, columns, persister, alias, associations, new HashSet(), session); } } *************** *** 109,121 **** columns = StringHelper.prefix( ! ( (Loadable) persister ).getIdentifierColumnNames(), //The cast is safe because collections can't contain a 1-to-1 alias + StringHelper.DOT ); } else { ! columns= persister.toColumns(alias, i); } ! walkTree(etype, columns, persister, associations, classPersisters, session); } } --- 111,123 ---- columns = StringHelper.prefix( ! persister.getIdentifierColumnNames(), //The cast is safe because collections can't contain a 1-to-1 alias + StringHelper.DOT ); } else { ! columns = persister.toColumns(alias, i); } ! walkTree(etype, columns, persister, alias, associations, classPersisters, session); } } *************** *** 142,146 **** if ( autoEager( act.enableJoinedFetch(i), etype, session ) ) { String[] columns = StringHelper.prefix( range, alias + StringHelper.DOT ); ! walkTree(etype, columns, persister, associations, classPersisters, session); } } --- 144,148 ---- if ( autoEager( act.enableJoinedFetch(i), etype, session ) ) { String[] columns = StringHelper.prefix( range, alias + StringHelper.DOT ); ! walkTree(etype, columns, persister, alias, associations, classPersisters, session); } } *************** *** 150,153 **** --- 152,156 ---- begin+=length; } + } *************** *** 162,172 **** * Add on association (one-to-one or many-to-one) to a list of associations be fetched by outerjoin (if necessary) */ ! private void walkTree(EntityType type, String[] columns, Object persister, List associations, Set classPersisters, SessionFactoryImplementor session) throws MappingException { Loadable subpersister = (Loadable) session.getPersister( type.getPersistentClass() ); - //TODO: remove this: - //if ( subpersister instanceof NormalizedEntityPersister ) return; - if ( !classPersisters.contains(subpersister) ) { // to avoid navigating back up bidirectional associations (and circularities) --- 165,172 ---- * Add on association (one-to-one or many-to-one) to a list of associations be fetched by outerjoin (if necessary) */ ! private void walkTree(EntityType type, String[] columns, Object persister, String alias, List associations, Set classPersisters, SessionFactoryImplementor session) throws MappingException { Loadable subpersister = (Loadable) session.getPersister( type.getPersistentClass() ); if ( !classPersisters.contains(subpersister) ) { // to avoid navigating back up bidirectional associations (and circularities) *************** *** 174,182 **** associations.add(assoc); classPersisters.add(persister); - //assoc.persister = persister; assoc.subpersister = subpersister; assoc.foreignKeyColumns = columns; String subalias = alias( subpersister.getClassName(), associations.size() ); assoc.subalias = subalias; walkTree(subpersister, subalias, associations, classPersisters, session); } --- 174,189 ---- associations.add(assoc); classPersisters.add(persister); assoc.subpersister = subpersister; assoc.foreignKeyColumns = columns; String subalias = alias( subpersister.getClassName(), associations.size() ); assoc.subalias = subalias; + + if ( type.isOneToOne() ) { + // only needed for oneToOne associations + // because we need to avoid unnecessary lookups + assoc.foreignKeyalias = alias; + assoc.isOneToOne = true; + } + walkTree(subpersister, subalias, associations, classPersisters, session); } *************** *** 261,268 **** oj.subpersister.whereJoinFragment(oj.subalias, false, true) ); - - //TODO: add the persister's outerjoins } return outerjoin; } --- 268,299 ---- oj.subpersister.whereJoinFragment(oj.subalias, false, true) ); } return outerjoin; + } + + protected static int[] getOneToOneOwners(String alias, List associations) { + int size = associations.size(); + int[] result = new int[size]; + for (int i=0; i<size; i++) { + OuterJoinableAssociation assoc = (OuterJoinableAssociation) associations.get(i); + if (assoc.isOneToOne) { + if ( assoc.foreignKeyalias.equals(alias) ) { + result[i] = i+1; //TODO: very dodgy, since this is actually defined by subclasses.... + } + else { + for (int j=0; j<size; j++) { + OuterJoinableAssociation possibleOwner = (OuterJoinableAssociation) associations.get(j); + if ( assoc.foreignKeyalias.equals(possibleOwner.subalias) ) { + result[i] = j; //TODO: again, quite dodgy.... + break; + } + } + } + } + else { + result[i] = -1; + } + } + return result; } |
From: Vic C. <vic...@ba...> - 2003-05-06 23:15:24
|
I have added a new mail list =93JDO=94 at=20 http://www.basebeans.net:8080/mailman/listinfo/jdo aimed at talking about DAO, such as JDO by KODO, DB Layer by iBatis,=20 Commons-SQL by Jakarta, JDBC RowSet, Hibernate, JDOSQL, Connection=20 Pooling, JDBC Realms, ADO.net, SQL, Stored Porcedures, sql.Date, Blob,=20 Clob, Connection Pooling, Data source, Castor, Cayene, Scaffolding, etc.=20 and related, in general Model Component (of MVC) and =85 DAO! Both SQL=20 based DAO and O/R based DAO how to. This list is also available via news=20 form server, for those that find mail lists messy, as most do at: news.basebeans.com, just user your Outlook or Mozilla. Please join this new JDO mail list, I found not other JDO/DAO mail lists=20 out there. This is 1st new list a long time (other one is=20 http://www.basebeans.net:8080/mailman/listinfo/mvc-programmers ) for=20 experienced project and tech leads, basicPortal.sf.net and Struts=20 training. Other mail lists that you can easily read there without=20 getting any mail traffic are: Struts, JDOM, Hibernate, SOAP Axis, JSP,=20 AspectJ, Eclipse, Flash Action Script, Resin, pgSQL, mySQL, etc. If you=20 already use news.basebeans.com, you will have to hit refresh to get the=20 new groups (JDO and Flash actionscript) Flash is the other new one only one the news.basebeans, I started=20 sending XML from my formBeans to Flash Fire Fly with good results. Thanks, Vic Cekvenich, 1-800-917-JAVA or 800-314-3295 Advanced <a href =3D"baseBeans.com">Struts Training</a> and project=20 recovery in North East. <p> Open Source <a href =3D"baseBeans.com">Content Management</a> basic=20 Portal sofware<p> Best practice<a href =3D"baseBeans.com">Supported Struts v.1.1</a>=20 framework ScafflodingXPress<p> |
From: <max...@us...> - 2003-05-04 10:52:22
|
Update of /cvsroot/hibernate/Hibernate2 In directory sc8-pr-cvs1:/tmp/cvs-serv10974 Modified Files: changelog.txt Log Message: updated changelog for <meta inherit> Index: changelog.txt =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/changelog.txt,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** changelog.txt 21 Apr 2003 15:57:38 -0000 1.17 --- changelog.txt 4 May 2003 10:52:18 -0000 1.18 *************** *** 1,4 **** --- 1,8 ---- Hibernate Changelog =================== + Changes in version 2.x (xx.x.2003) + ---------------------------------- + * <meta> tags can now be set to not be inheritable. + Changes in version 2.0 beta 5 (21.4.2003) ----------------------------------------- |
From: <max...@us...> - 2003-05-04 10:39:48
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv5411/src/net/sf/hibernate Modified Files: hibernate-mapping-2.0.dtd Log Message: implemented the inherit keyword for <meta> Index: hibernate-mapping-2.0.dtd =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hibernate-mapping-2.0.dtd,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** hibernate-mapping-2.0.dtd 2 May 2003 09:21:57 -0000 1.24 --- hibernate-mapping-2.0.dtd 4 May 2003 10:39:45 -0000 1.25 *************** *** 435,441 **** <!-- The meta element is used to assign meta-level attributes to a class or property. Is currently used by codegenerator as a placeholder for values that is not directly ! related to OR mappings. --> <!ELEMENT meta (#PCDATA)> <!ATTLIST meta attribute CDATA #REQUIRED> --- 435,443 ---- <!-- The meta element is used to assign meta-level attributes to a class or property. Is currently used by codegenerator as a placeholder for values that is not directly ! related to OR mappings. ! --> <!ELEMENT meta (#PCDATA)> <!ATTLIST meta attribute CDATA #REQUIRED> + <!ATTLIST meta inherit (true|false) "true"> |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java In directory sc8-pr-cvs1:/tmp/cvs-serv1918/src/net/sf/hibernate/tool/hbm2java Modified Files: BasicRenderer.java MetaAttributeHelper.java ClassMapping.java CodeGenerator.java Field.java Log Message: Fixed bug regarding "abstract" class generation. small refactorings of metaattributehelper (unified access to them) implemented the inherit keyword for <meta> Index: BasicRenderer.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java/BasicRenderer.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** BasicRenderer.java 12 Apr 2003 14:47:36 -0000 1.15 --- BasicRenderer.java 4 May 2003 10:32:02 -0000 1.16 *************** *** 51,55 **** classScope = classMapping.getMetaAsString("scope-class").trim(); } ! if(classMapping.shouldBeAbstract()) { writer.print( "abstract " + classScope + " class " + savedToClass ); } else { --- 51,55 ---- classScope = classMapping.getMetaAsString("scope-class").trim(); } ! if(classMapping.shouldBeAbstract() && (classScope.indexOf("abstract")==-1)) { writer.print( "abstract " + classScope + " class " + savedToClass ); } else { *************** *** 77,86 **** if(classMapping.getMeta("implements")!=null) { ! Collection implementz = classMapping.getMeta("implements"); ! for (Iterator iter = implementz.iterator(); iter.hasNext();) { ! String iface = (String) iter.next(); ! writer.print(StringHelper.COMMA_SPACE); ! writer.print(iface); ! } } --- 77,81 ---- if(classMapping.getMeta("implements")!=null) { ! writer.print(MetaAttributeHelper.getMetaAsString(classMapping.getMeta("implements"),", ")); } Index: MetaAttributeHelper.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java/MetaAttributeHelper.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MetaAttributeHelper.java 16 Jan 2003 20:54:55 -0000 1.1 --- MetaAttributeHelper.java 4 May 2003 10:32:02 -0000 1.2 *************** *** 2,8 **** --- 2,11 ---- import java.util.ArrayList; + import java.util.Collection; import java.util.Iterator; import java.util.List; + import net.sf.hibernate.util.StringHelper; + import org.apache.commons.collections.MultiHashMap; import org.apache.commons.collections.MultiMap; *************** *** 20,83 **** public class MetaAttributeHelper { ! static private Log log = LogFactory.getLog(MetaAttributeHelper.class); ! ! /** ! * Load meta attributes from jdom element into a MultiMap. ! * ! * @param element ! * @return MultiMap ! */ ! static protected MultiMap loadMetaMap(Element element) { ! MultiMap result = new MultiHashMap(); ! List metaAttributeList = new ArrayList(); ! metaAttributeList.addAll(element.getChildren("meta")); ! for (Iterator iter = metaAttributeList.iterator(); iter.hasNext();) { ! Element metaAttrib = (Element) iter.next(); ! // does not use getTextNormalize() or getTextTrim() as that would remove the formatting in new lines in items like description for javadocs. ! result.put(metaAttrib.getAttribute("attribute").getValue(), metaAttrib.getText()); ! } ! return result; ! } ! /** ! * Merges a Multimap with inherited maps. ! * Values specified always overrules/replaces the inherited values. ! * ! * @param local ! * @param inherited ! * @return a MultiMap with all values from local and extra values ! * from inherited ! */ ! static public MultiMap mergeMetaMaps(MultiMap local, MultiMap inherited) { ! MultiHashMap result = new MultiHashMap(); ! ! if (inherited != null) { ! result.putAll(local); ! for (Iterator iter = inherited.keySet().iterator(); iter.hasNext();) { ! String key = (String) iter.next(); ! if (!local.containsKey(key)) { ! // inheriting a meta attribute ! result.put(key, inherited.get(key)); ! } ! } ! } ! ! ! return result; ! ! } ! /** ! * Method loadAndMergeMetaMap. ! * @param classElement ! * @param inheritedMeta ! * @return MultiMap ! */ ! public static MultiMap loadAndMergeMetaMap(Element classElement, MultiMap inheritedMeta) { ! return mergeMetaMaps(loadMetaMap(classElement), inheritedMeta); ! } } --- 23,151 ---- public class MetaAttributeHelper { ! static private Log log = LogFactory.getLog(MetaAttributeHelper.class); ! static class MetaAttribute { ! String value; ! boolean inheritable = true; ! MetaAttribute(String value, boolean inherit) { ! this.value = value; ! this.inheritable = inherit; ! } ! public String toString() { ! return value; ! } ! } ! /** ! * Load meta attributes from jdom element into a MultiMap. ! * ! * @param element ! * @return MultiMap ! */ ! static protected MultiMap loadMetaMap(Element element) { ! MultiMap result = new MultiHashMap(); ! List metaAttributeList = new ArrayList(); ! metaAttributeList.addAll(element.getChildren("meta")); ! for (Iterator iter = metaAttributeList.iterator(); iter.hasNext();) { ! Element metaAttrib = (Element) iter.next(); ! // does not use getTextNormalize() or getTextTrim() as that would remove the formatting in new lines in items like description for javadocs. ! String attribute = metaAttrib.getAttribute("attribute").getValue(); ! String value = metaAttrib.getText(); ! boolean inherit = ! Boolean ! .valueOf(metaAttrib.getAttributeValue("inherit")) ! .booleanValue(); ! MetaAttribute ma = new MetaAttribute(value, inherit); ! result.put(attribute, ma); ! } ! return result; ! ! } ! ! /** ! * Merges a Multimap with inherited maps. ! * Values specified always overrules/replaces the inherited values. ! * ! * @param local ! * @param inherited ! * @return a MultiMap with all values from local and extra values ! * from inherited ! */ ! static public MultiMap mergeMetaMaps(MultiMap local, MultiMap inherited) { ! MultiHashMap result = new MultiHashMap(); ! ! if (inherited != null) { ! result.putAll(local); ! for (Iterator iter = inherited.keySet().iterator(); ! iter.hasNext(); ! ) { ! String key = (String) iter.next(); ! ! if (!local.containsKey(key)) { ! // inheriting a meta attribute only if it is inheritable ! ArrayList ml = (ArrayList) inherited.get(key); ! for (Iterator iterator = ml.iterator(); ! iterator.hasNext(); ! ) { ! MetaAttribute element = (MetaAttribute) iterator.next(); ! if (element.inheritable) { ! result.put(key, element); ! } ! } ! } ! } ! } ! ! return result; ! ! } ! /** ! * Method loadAndMergeMetaMap. ! * @param classElement ! * @param inheritedMeta ! * @return MultiMap ! */ ! public static MultiMap loadAndMergeMetaMap( ! Element classElement, ! MultiMap inheritedMeta) { ! return mergeMetaMaps(loadMetaMap(classElement), inheritedMeta); ! } ! ! /** ! * @param collection ! * @param string ! */ ! public static String getMetaAsString(Collection meta, String seperator) { ! StringBuffer buf = new StringBuffer(); ! for (Iterator iter = meta.iterator(); iter.hasNext();) { ! buf.append(seperator); ! buf.append(iter.next()); ! } ! return buf.toString(); ! } ! ! static boolean getMetaAsBool(Collection c, boolean defaultValue) { ! if(c==null || c.isEmpty()) { ! return defaultValue; ! } else { ! return Boolean.valueOf(c.iterator().next().toString()).booleanValue(); ! } ! } ! ! static String getMetaAsString(Collection c) { ! if(c==null || c.isEmpty()) { ! return StringHelper.EMPTY_STRING; ! } else { ! StringBuffer sb = new StringBuffer(); ! for (Iterator iter = c.iterator(); iter.hasNext();) { ! Object element = (Object) iter.next(); ! sb.append(element.toString()); ! } ! return sb.toString(); ! } ! } } Index: ClassMapping.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java/ClassMapping.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ClassMapping.java 20 Apr 2003 11:52:47 -0000 1.15 --- ClassMapping.java 4 May 2003 10:32:02 -0000 1.16 *************** *** 515,522 **** ClassName foreignClass = null; Set foreignKeys = null; ! if(collection.getChildren("one-to-many").size()!=0) { // Collect bidirectional data foreignClass = new ClassName(); foreignClass.setFullyQualifiedName(collection.getChild("one-to-many").getAttributeValue("class")); // Collect the keys foreignKeys = new HashSet(); --- 515,530 ---- ClassName foreignClass = null; Set foreignKeys = null; ! // Collect bidirectional data ! if(collection.getChildren("one-to-many").size()!=0) { foreignClass = new ClassName(); foreignClass.setFullyQualifiedName(collection.getChild("one-to-many").getAttributeValue("class")); + } else if (collection.getChildren("many-to-many").size()!=0) { + foreignClass = new ClassName(); + foreignClass.setFullyQualifiedName(collection.getChild("many-to-many").getAttributeValue("class")); + } + + // Do the foreign keys and import + if (foreignClass != null) { // Collect the keys foreignKeys = new HashSet(); *************** *** 681,695 **** Collection c= getMeta(attribute); ! if(c==null) { ! return StringHelper.EMPTY_STRING; ! } ! else { ! StringBuffer sb = new StringBuffer(); ! for (Iterator iter = c.iterator(); iter.hasNext();) { ! Object element = (Object) iter.next(); ! sb.append(element.toString()); ! } ! return sb.toString(); ! } } /** --- 689,693 ---- Collection c= getMeta(attribute); ! return MetaAttributeHelper.getMetaAsString(c); } /** *************** *** 707,712 **** log.warn("Warning: meta attribute extends='" + getMetaAsString("extends") + "' will be ignored for subclass " + name); } ! ! } --- 705,709 ---- log.warn("Warning: meta attribute extends='" + getMetaAsString("extends") + "' will be ignored for subclass " + name); } ! } Index: CodeGenerator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java/CodeGenerator.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CodeGenerator.java 16 Jan 2003 20:52:38 -0000 1.4 --- CodeGenerator.java 4 May 2003 10:32:02 -0000 1.5 *************** *** 89,94 **** // parse the mapping file Document document = builder.build( new File( (String) iter.next() ) ); ! Iterator classElements = document.getRootElement().getChildren("class").iterator(); ! MultiMap mm = MetaAttributeHelper.loadAndMergeMetaMap(document.getRootElement(), globalMetas); while ( classElements.hasNext() ) { ClassMapping cmap = new ClassMapping( (Element) classElements.next(), mm); --- 89,96 ---- // parse the mapping file Document document = builder.build( new File( (String) iter.next() ) ); ! ! Element rootElement = document.getRootElement(); ! Iterator classElements = rootElement.getChildren("class").iterator(); ! MultiMap mm = MetaAttributeHelper.loadAndMergeMetaMap(rootElement, globalMetas); while ( classElements.hasNext() ) { ClassMapping cmap = new ClassMapping( (Element) classElements.next(), mm); Index: Field.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/tool/hbm2java/Field.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Field.java 17 Feb 2003 18:22:42 -0000 1.7 --- Field.java 4 May 2003 10:32:02 -0000 1.8 *************** *** 3,10 **** import java.util.Collection; - import java.util.Iterator; import java.util.Set; - import net.sf.hibernate.util.StringHelper; import org.apache.commons.collections.MultiMap; --- 3,8 ---- *************** *** 125,140 **** Collection c= getMeta(attribute); ! if(c==null || c.isEmpty()) { ! return StringHelper.EMPTY_STRING; ! } else { ! StringBuffer sb = new StringBuffer(); ! for (Iterator iter = c.iterator(); iter.hasNext();) { ! Object element = (Object) iter.next(); ! sb.append(element.toString()); ! } ! return sb.toString(); ! } } ! public boolean getMetaAsBool(String attribute) { return getMetaAsBool(attribute,false); --- 123,129 ---- Collection c= getMeta(attribute); ! return MetaAttributeHelper.getMetaAsString(c); } ! public boolean getMetaAsBool(String attribute) { return getMetaAsBool(attribute,false); *************** *** 144,154 **** Collection c= getMeta(attribute); ! if(c==null || c.isEmpty()) { ! return defaultValue; ! } else { ! return Boolean.valueOf(c.iterator().next().toString()).booleanValue(); ! } } ! /** * Returns the foreignClass. --- 133,139 ---- Collection c= getMeta(attribute); ! return MetaAttributeHelper.getMetaAsBool(c,defaultValue); } ! /** * Returns the foreignClass. |
From: <one...@us...> - 2003-05-04 06:09:42
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader In directory sc8-pr-cvs1:/tmp/cvs-serv11014/loader Modified Files: Loader.java Log Message: improved Limit clause stuff Index: Loader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/Loader.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Loader.java 3 May 2003 09:05:45 -0000 1.22 --- Loader.java 4 May 2003 06:09:39 -0000 1.23 *************** *** 17,20 **** --- 17,21 ---- import net.sf.hibernate.collection.CollectionPersister; import net.sf.hibernate.collection.PersistentCollection; + import net.sf.hibernate.dialect.Dialect; import net.sf.hibernate.engine.Key; import net.sf.hibernate.engine.RowSelection; *************** *** 383,391 **** } ! private boolean usePagingSelect(RowSelection selection, SessionImplementor session) { ! return session.getFactory().getDialect().supportsPagingSelect() && ( ! selection!=null && ! selection.getMaxRows()!=null ! ); } --- 384,392 ---- } ! private boolean useLimit(RowSelection selection, SessionImplementor session) { ! Dialect d = session.getFactory().getDialect(); ! return d.supportsLimit() && ! ( selection!=null && selection.getMaxRows()!=null ) && //there is a max rows ! ( d.preferLimit() || getFirstRow(selection)!=0 ); } *************** *** 404,415 **** ) throws SQLException, HibernateException { ! boolean usePagingSelect = usePagingSelect(selection, session); boolean scrollable = session.getFactory().useScrollableResultSets() && ( scroll || ! ( !usePagingSelect && getFirstRow(selection)!=0 ) ); ! if (usePagingSelect) sql = session.getFactory().getDialect().getPagingSelect(sql); PreparedStatement st = session.getBatcher().prepareQueryStatement(sql, scrollable); --- 405,416 ---- ) throws SQLException, HibernateException { ! boolean useLimit = useLimit(selection, session); boolean scrollable = session.getFactory().useScrollableResultSets() && ( scroll || ! ( !useLimit && getFirstRow(selection)!=0 ) ); ! if (useLimit) sql = session.getFactory().getDialect().getLimitString(sql); PreparedStatement st = session.getBatcher().prepareQueryStatement(sql, scrollable); *************** *** 427,431 **** col += bindNamedParameters(st, namedParams, col, session); ! if (usePagingSelect) bindPagingSelectParameters(st, col, selection, session); } catch (SQLException sqle) { --- 428,432 ---- col += bindNamedParameters(st, namedParams, col, session); ! if (useLimit) bindPagingSelectParameters(st, col, selection, session); } catch (SQLException sqle) { *************** *** 445,449 **** int firstRow = (selection==null || selection.getFirstRow()==null ) ? 0 : selection.getFirstRow().intValue(); int lastRow = firstRow + selection.getMaxRows().intValue(); ! boolean reverse = session.getFactory().getDialect().reversePagingSelectOrder(); st.setInt( index + (reverse?1:0), firstRow ); st.setInt( index + (reverse?0:1), lastRow ); --- 446,450 ---- int firstRow = (selection==null || selection.getFirstRow()==null ) ? 0 : selection.getFirstRow().intValue(); int lastRow = firstRow + selection.getMaxRows().intValue(); ! boolean reverse = session.getFactory().getDialect().reverseLimitParameterOrder(); st.setInt( index + (reverse?1:0), firstRow ); st.setInt( index + (reverse?0:1), lastRow ); *************** *** 467,476 **** throws SQLException, HibernateException { ! boolean usePagingSelect = usePagingSelect(selection, session); try { ! if (!usePagingSelect) setMaxRows(st, selection); ResultSet rs = st.executeQuery(); ! if (!usePagingSelect) advance(rs, selection, session); return rs; } --- 468,477 ---- throws SQLException, HibernateException { ! boolean useLimit = useLimit(selection, session); try { ! if (!useLimit) setMaxRows(st, selection); ResultSet rs = st.executeQuery(); ! if (!useLimit) advance(rs, selection, session); return rs; } |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/dialect In directory sc8-pr-cvs1:/tmp/cvs-serv11014/dialect Modified Files: Dialect.java HSQLDialect.java MySQLDialect.java Oracle9Dialect.java PostgreSQLDialect.java Log Message: improved Limit clause stuff Index: Dialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/dialect/Dialect.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Dialect.java 3 May 2003 09:05:44 -0000 1.14 --- Dialect.java 4 May 2003 06:09:40 -0000 1.15 *************** *** 350,354 **** * Does this <tt>Dialect</tt> have some kind of <tt>LIMIT</tt> syntax? */ ! public boolean supportsPagingSelect() { return false; } --- 350,354 ---- * Does this <tt>Dialect</tt> have some kind of <tt>LIMIT</tt> syntax? */ ! public boolean supportsLimit() { return false; } *************** *** 358,362 **** * @return the modified SQL */ ! public String getPagingSelect(String querySelect) { throw new UnsupportedOperationException("paged queries not supported"); } --- 358,362 ---- * @return the modified SQL */ ! public String getLimitString(String querySelect) { throw new UnsupportedOperationException("paged queries not supported"); } *************** *** 367,371 **** * @return true if the correct order is limit, offset */ ! public boolean reversePagingSelectOrder() { return false; } --- 367,379 ---- * @return true if the correct order is limit, offset */ ! public boolean reverseLimitParameterOrder() { ! return false; ! } ! ! /** ! * Should we use a <tt>LIMIT</tt> clause when there is no first result ! * specified? ! */ ! public boolean preferLimit() { return false; } Index: HSQLDialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/dialect/HSQLDialect.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** HSQLDialect.java 3 May 2003 09:05:44 -0000 1.8 --- HSQLDialect.java 4 May 2003 06:09:40 -0000 1.9 *************** *** 72,80 **** } ! public boolean supportsPagingSelect() { return true; } ! public String getPagingSelect(String sql) { StringBuffer pagingSelect = new StringBuffer(100); pagingSelect.append(sql); --- 72,80 ---- } ! public boolean supportsLimit() { return true; } ! public String getLimitString(String sql) { StringBuffer pagingSelect = new StringBuffer(100); pagingSelect.append(sql); Index: MySQLDialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/dialect/MySQLDialect.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** MySQLDialect.java 3 May 2003 09:05:44 -0000 1.9 --- MySQLDialect.java 4 May 2003 06:09:40 -0000 1.10 *************** *** 83,95 **** } ! public boolean supportsPagingSelect() { return true; } ! public String getPagingSelect(String sql) { StringBuffer pagingSelect = new StringBuffer(100); pagingSelect.append(sql); pagingSelect.append(" limit ?, ?"); return pagingSelect.toString(); } --- 83,99 ---- } ! public boolean supportsLimit() { return true; } ! public String getLimitString(String sql) { StringBuffer pagingSelect = new StringBuffer(100); pagingSelect.append(sql); pagingSelect.append(" limit ?, ?"); return pagingSelect.toString(); + } + + public boolean preferLimit() { + return true; } Index: Oracle9Dialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/dialect/Oracle9Dialect.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Oracle9Dialect.java 3 May 2003 09:05:44 -0000 1.5 --- Oracle9Dialect.java 4 May 2003 06:09:40 -0000 1.6 *************** *** 62,74 **** } ! public boolean supportsPagingSelect() { return true; } ! public String getPagingSelect(String sql) { StringBuffer pagingSelect = new StringBuffer(100); ! pagingSelect.append("select * from ( select a.*, rownum rnum from ( "); pagingSelect.append(sql); ! pagingSelect.append(" ) a where rownum <= ?) where rnum >= ?"); return pagingSelect.toString(); } --- 62,74 ---- } ! public boolean supportsLimit() { return true; } ! public String getLimitString(String sql) { StringBuffer pagingSelect = new StringBuffer(100); ! pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( "); pagingSelect.append(sql); ! pagingSelect.append(" ) row_ where rownum <= ?) where rownum_ >= ?"); return pagingSelect.toString(); } Index: PostgreSQLDialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/dialect/PostgreSQLDialect.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PostgreSQLDialect.java 3 May 2003 09:05:45 -0000 1.11 --- PostgreSQLDialect.java 4 May 2003 06:09:40 -0000 1.12 *************** *** 59,67 **** } ! public boolean supportsPagingSelect() { return true; } ! public String getPagingSelect(String sql) { StringBuffer pagingSelect = new StringBuffer(100); pagingSelect.append(sql); --- 59,67 ---- } ! public boolean supportsLimit() { return true; } ! public String getLimitString(String sql) { StringBuffer pagingSelect = new StringBuffer(100); pagingSelect.append(sql); *************** *** 70,74 **** } ! public boolean reversePagingSelectOrder() { return true; } --- 70,78 ---- } ! public boolean reverseLimitParameterOrder() { ! return true; ! } ! ! public boolean preferLimit() { return true; } |
From: <one...@us...> - 2003-05-03 09:05:53
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv15675/test Modified Files: FooBarTest.java Log Message: code cleanups for paged queries + paged queries for HSQL Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** FooBarTest.java 3 May 2003 07:06:26 -0000 1.61 --- FooBarTest.java 3 May 2003 09:05:45 -0000 1.62 *************** *** 19,22 **** --- 19,23 ---- import junit.framework.Test; import junit.framework.TestSuite; + import net.sf.hibernate.engine.SessionFactoryImplementor; import net.sf.hibernate.expression.Expression; import net.sf.hibernate.expression.Order; *************** *** 108,111 **** --- 109,115 ---- public void testForceOuterJoin() throws Exception { + + if ( !( (SessionFactoryImplementor) sessions ).enableJoinedFetch() ) return; + Session s = sessions.openSession(); Glarch g = new Glarch(); *************** *** 245,249 **** s.save(bar2); ! List list = s.find("from Bar bar left join bar.baz baz left join baz.cascadingBars b where bar.name like 'Bar%'"); Object row = list.iterator().next(); assertTrue( row instanceof Object[] && ( (Object[]) row ).length==3 ); --- 249,253 ---- s.save(bar2); ! List list = s.find("from Bar bar left join bar.baz baz left join baz.cascadingBars b where bar.name like 'Bar %'"); Object row = list.iterator().next(); assertTrue( row instanceof Object[] && ( (Object[]) row ).length==3 ); *************** *** 267,271 **** assertTrue( list.size()==1 ); q = s.createQuery("select bar, b from Bar bar left join bar.baz baz left join baz.cascadingBars b where bar.name like :name and b.name like :name"); ! q.setString("name", "Bar%"); list = q.list(); assertTrue( list.size()==1 ); --- 271,280 ---- assertTrue( list.size()==1 ); q = s.createQuery("select bar, b from Bar bar left join bar.baz baz left join baz.cascadingBars b where bar.name like :name and b.name like :name"); ! if ( dialect instanceof HSQLDialect ) { ! q.setString("name", "Bar %"); ! } ! else { ! q.setString("name", "Bar%"); ! } list = q.list(); assertTrue( list.size()==1 ); *************** *** 323,327 **** .add( Expression.in( "boolean", new Boolean[] { f.getBoolean(), f.getBoolean() } ) ) .list(); ! assertTrue( list.size()==1 && list.get(0)==f ); list = s.createCriteria(Foo.class).add( --- 332,336 ---- .add( Expression.in( "boolean", new Boolean[] { f.getBoolean(), f.getBoolean() } ) ) .list(); ! if ( ! (dialect instanceof HSQLDialect) ) assertTrue( list.size()==1 && list.get(0)==f ); list = s.createCriteria(Foo.class).add( *************** *** 1255,1259 **** s.find("select foo.foo.foo.foo.string from foo in class Foo where foo.foo.foo = 'bar'"); s.find("select foo.foo.foo.string from foo in class Foo where foo.foo.foo.foo.string = 'bar'"); ! s.find("select foo.string from foo in class Foo where foo.foo.foo.foo = foo.foo.foo"); s.find("select foo.string from foo in class Foo where foo.foo.foo = 'bar' and foo.foo.foo.foo = 'baz'"); s.find("select foo.string from foo in class Foo where foo.foo.foo.foo.string = 'a' and foo.foo.string = 'b'"); --- 1264,1268 ---- s.find("select foo.foo.foo.foo.string from foo in class Foo where foo.foo.foo = 'bar'"); s.find("select foo.foo.foo.string from foo in class Foo where foo.foo.foo.foo.string = 'bar'"); ! if ( ! (dialect instanceof HSQLDialect) ) s.find("select foo.string from foo in class Foo where foo.foo.foo.foo = foo.foo.foo"); s.find("select foo.string from foo in class Foo where foo.foo.foo = 'bar' and foo.foo.foo.foo = 'baz'"); s.find("select foo.string from foo in class Foo where foo.foo.foo.foo.string = 'a' and foo.foo.string = 'b'"); *************** *** 1463,1468 **** if ( row[0]!=row[1] ) cnt++; } ! assertTrue(cnt==2); ! assertTrue( s.find("from n0 in class Named, n1 in class Named where n0.name = n1.name").size()==7 ); Query qu = s.createQuery("from n in class Named where n.name = :name"); --- 1472,1479 ---- if ( row[0]!=row[1] ) cnt++; } ! if ( !(dialect instanceof HSQLDialect) ) { ! assertTrue(cnt==2); ! assertTrue( s.find("from n0 in class Named, n1 in class Named where n0.name = n1.name").size()==7 ); ! } Query qu = s.createQuery("from n in class Named where n.name = :name"); *************** *** 3145,3149 **** assertTrue( baz.getFooArray()[0] instanceof HibernateProxy ); //many-to-many assertTrue( baz.getFooArray()[1]==bar2prox ); ! assertTrue( !(baz.getFooBag().iterator().next() instanceof HibernateProxy) ); //many-to-many outer-join="true" assertTrue( !(baz.getFooSet().iterator().next() instanceof HibernateProxy) ); //one-to-many s.delete("from o in class Baz"); --- 3156,3160 ---- assertTrue( baz.getFooArray()[0] instanceof HibernateProxy ); //many-to-many assertTrue( baz.getFooArray()[1]==bar2prox ); ! if ( ( (SessionFactoryImplementor) sessions ).enableJoinedFetch() ) assertTrue( !(baz.getFooBag().iterator().next() instanceof HibernateProxy) ); //many-to-many outer-join="true" assertTrue( !(baz.getFooSet().iterator().next() instanceof HibernateProxy) ); //one-to-many s.delete("from o in class Baz"); |
From: <one...@us...> - 2003-05-03 09:05:53
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader In directory sc8-pr-cvs1:/tmp/cvs-serv15675/loader Modified Files: Loader.java Log Message: code cleanups for paged queries + paged queries for HSQL Index: Loader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/Loader.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Loader.java 3 May 2003 07:20:50 -0000 1.21 --- Loader.java 3 May 2003 09:05:45 -0000 1.22 *************** *** 361,380 **** */ protected final void advance(ResultSet rs, RowSelection selection, SessionImplementor session) throws SQLException { ! if (selection==null) { ! // we need the whole ResultSet from the beginning ! return; } else { ! Integer first = selection.getFirstRow(); ! if (first!=null && first.intValue()!=0 ) { ! if ( session.getFactory().useScrollableResultSets() ) { ! // we can go straight to the first required row ! rs.absolute( first.intValue() ); ! } ! else { ! // we need to step through the rows one row at a time (slow) ! for ( int m=0; m<first.intValue(); m++ ) rs.next(); ! } ! } } } --- 361,383 ---- */ protected final void advance(ResultSet rs, RowSelection selection, SessionImplementor session) throws SQLException { ! int firstRow = getFirstRow(selection); ! if ( firstRow!=0 ) { ! if ( session.getFactory().useScrollableResultSets() ) { ! // we can go straight to the first required row ! rs.absolute(firstRow); ! } ! else { ! // we need to step through the rows one row at a time (slow) ! for ( int m=0; m<firstRow; m++ ) rs.next(); ! } ! } ! } ! ! private int getFirstRow(RowSelection selection) { ! if ( selection==null || selection.getFirstRow()==null ) { ! return 0; } else { ! return selection.getFirstRow().intValue(); } } *************** *** 404,413 **** boolean scrollable = session.getFactory().useScrollableResultSets() && ( ! scroll || ( ! !usePagingSelect && ! selection!=null && ! selection.getFirstRow()!=null && ! selection.getFirstRow().intValue()!=0 ! ) ); --- 407,412 ---- boolean scrollable = session.getFactory().useScrollableResultSets() && ( ! scroll || ! ( !usePagingSelect && getFirstRow(selection)!=0 ) ); *************** *** 428,438 **** col += bindNamedParameters(st, namedParams, col, session); ! if (usePagingSelect) { ! int firstRow = (selection==null || selection.getFirstRow()==null ) ? 0 : selection.getFirstRow().intValue(); ! int lastRow = firstRow + selection.getMaxRows().intValue(); ! boolean reverse = session.getFactory().getDialect().reversePagingSelectOrder(); ! st.setInt( col + (reverse?1:0), firstRow ); ! st.setInt( col + (reverse?0:1), lastRow ); ! } } catch (SQLException sqle) { --- 427,431 ---- col += bindNamedParameters(st, namedParams, col, session); ! if (usePagingSelect) bindPagingSelectParameters(st, col, selection, session); } catch (SQLException sqle) { *************** *** 447,450 **** --- 440,452 ---- return st; + } + + private void bindPagingSelectParameters(PreparedStatement st, int index, RowSelection selection, SessionImplementor session) throws SQLException { + int firstRow = (selection==null || selection.getFirstRow()==null ) ? 0 : selection.getFirstRow().intValue(); + int lastRow = firstRow + selection.getMaxRows().intValue(); + boolean reverse = session.getFactory().getDialect().reversePagingSelectOrder(); + st.setInt( index + (reverse?1:0), firstRow ); + st.setInt( index + (reverse?0:1), lastRow ); + } |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/dialect In directory sc8-pr-cvs1:/tmp/cvs-serv15675/dialect Modified Files: Dialect.java HSQLDialect.java MySQLDialect.java Oracle9Dialect.java PostgreSQLDialect.java TypeNames.java Log Message: code cleanups for paged queries + paged queries for HSQL Index: Dialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/dialect/Dialect.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Dialect.java 3 May 2003 07:20:49 -0000 1.13 --- Dialect.java 3 May 2003 09:05:44 -0000 1.14 *************** *** 347,358 **** } public boolean supportsPagingSelect() { return false; } ! public String getPagingSelect(String querySelect) { throw new UnsupportedOperationException("paged queries not supported"); } public boolean reversePagingSelectOrder() { return false; --- 347,370 ---- } + /** + * Does this <tt>Dialect</tt> have some kind of <tt>LIMIT</tt> syntax? + */ public boolean supportsPagingSelect() { return false; } ! ! /** ! * Add a <tt>LIMIT</tt> clause to the given SQL <tt>SELECT</tt> ! * @return the modified SQL ! */ public String getPagingSelect(String querySelect) { throw new UnsupportedOperationException("paged queries not supported"); } + /** + * Does the <tt>LIMIT</tt> clause specify arguments in the "reverse" order + * limit, offset instead of offset, limit? + * @return true if the correct order is limit, offset + */ public boolean reversePagingSelectOrder() { return false; Index: HSQLDialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/dialect/HSQLDialect.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** HSQLDialect.java 25 Apr 2003 03:40:32 -0000 1.7 --- HSQLDialect.java 3 May 2003 09:05:44 -0000 1.8 *************** *** 35,39 **** register( Types.NUMERIC, "NUMERIC" ); ! getDefaultProperties().setProperty(Environment.USE_OUTER_JOIN, "false"); getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH); } --- 35,39 ---- register( Types.NUMERIC, "NUMERIC" ); ! getDefaultProperties().setProperty(Environment.USE_OUTER_JOIN, "false"); //HSQL has outer joins but not for composite keys! getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH); } *************** *** 72,75 **** --- 72,85 ---- } + public boolean supportsPagingSelect() { + return true; + } + + public String getPagingSelect(String sql) { + StringBuffer pagingSelect = new StringBuffer(100); + pagingSelect.append(sql); + pagingSelect.insert(6, " limit ? ?"); + return pagingSelect.toString(); + } } Index: MySQLDialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/dialect/MySQLDialect.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MySQLDialect.java 3 May 2003 07:20:49 -0000 1.8 --- MySQLDialect.java 3 May 2003 09:05:44 -0000 1.9 *************** *** 88,99 **** public String getPagingSelect(String sql) { ! StringBuffer pagingSelect = new StringBuffer(); pagingSelect.append(sql); pagingSelect.append(" limit ?, ?"); return pagingSelect.toString(); - } - - public boolean reversePagingSelectOrder() { - return false; } --- 88,95 ---- public String getPagingSelect(String sql) { ! StringBuffer pagingSelect = new StringBuffer(100); pagingSelect.append(sql); pagingSelect.append(" limit ?, ?"); return pagingSelect.toString(); } Index: Oracle9Dialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/dialect/Oracle9Dialect.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Oracle9Dialect.java 3 May 2003 07:20:49 -0000 1.4 --- Oracle9Dialect.java 3 May 2003 09:05:44 -0000 1.5 *************** *** 67,71 **** public String getPagingSelect(String sql) { ! StringBuffer pagingSelect = new StringBuffer(); pagingSelect.append("select * from ( select a.*, rownum rnum from ( "); pagingSelect.append(sql); --- 67,71 ---- public String getPagingSelect(String sql) { ! StringBuffer pagingSelect = new StringBuffer(100); pagingSelect.append("select * from ( select a.*, rownum rnum from ( "); pagingSelect.append(sql); Index: PostgreSQLDialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/dialect/PostgreSQLDialect.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PostgreSQLDialect.java 3 May 2003 07:20:49 -0000 1.10 --- PostgreSQLDialect.java 3 May 2003 09:05:45 -0000 1.11 *************** *** 64,68 **** public String getPagingSelect(String sql) { ! StringBuffer pagingSelect = new StringBuffer(); pagingSelect.append(sql); pagingSelect.append(" limit ?, ?"); --- 64,68 ---- public String getPagingSelect(String sql) { ! StringBuffer pagingSelect = new StringBuffer(100); pagingSelect.append(sql); pagingSelect.append(" limit ?, ?"); Index: TypeNames.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/dialect/TypeNames.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TypeNames.java 5 Jan 2003 02:11:20 -0000 1.3 --- TypeNames.java 3 May 2003 09:05:45 -0000 1.4 *************** *** 7,10 **** --- 7,11 ---- import java.util.Iterator; + import net.sf.hibernate.MappingException; import net.sf.hibernate.util.StringHelper; *************** *** 61,66 **** * @return the default type name associated with specified key */ ! public String get(int typecode) { ! return (String) defaults.get( new Integer(typecode) ); } --- 62,69 ---- * @return the default type name associated with specified key */ ! public String get(int typecode) throws MappingException { ! String result = (String) defaults.get( new Integer(typecode) ); ! if (result==null) throw new MappingException("No Dialect mapping for JDBC type: " + typecode); ! return result; } *************** *** 72,76 **** * if available and the default type name otherwise */ ! public String get(int typecode, int size) { Map map = (Map) weighted.get( new Integer(typecode) ); if (map != null && map.size() > 0) { --- 75,79 ---- * if available and the default type name otherwise */ ! public String get(int typecode, int size) throws MappingException { Map map = (Map) weighted.get( new Integer(typecode) ); if (map != null && map.size() > 0) { |
From: <one...@us...> - 2003-05-03 07:20:54
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader In directory sc8-pr-cvs1:/tmp/cvs-serv15927/loader Modified Files: Loader.java Log Message: applied paged SQL SELECT patch by David White Index: Loader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/Loader.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Loader.java 25 Apr 2003 05:56:33 -0000 1.20 --- Loader.java 3 May 2003 07:20:50 -0000 1.21 *************** *** 11,17 **** import java.util.Map; - import org.apache.commons.logging.Log; - import org.apache.commons.logging.LogFactory; - import net.sf.hibernate.HibernateException; import net.sf.hibernate.LockMode; --- 11,14 ---- *************** *** 23,31 **** import net.sf.hibernate.engine.RowSelection; import net.sf.hibernate.engine.SessionImplementor; - import net.sf.hibernate.util.JDBCExceptionReporter; - import net.sf.hibernate.util.StringHelper; import net.sf.hibernate.persister.Loadable; import net.sf.hibernate.sql.Alias; import net.sf.hibernate.type.Type; /** --- 20,30 ---- import net.sf.hibernate.engine.RowSelection; import net.sf.hibernate.engine.SessionImplementor; import net.sf.hibernate.persister.Loadable; import net.sf.hibernate.sql.Alias; import net.sf.hibernate.type.Type; + import net.sf.hibernate.util.JDBCExceptionReporter; + import net.sf.hibernate.util.StringHelper; + import org.apache.commons.logging.Log; + import org.apache.commons.logging.LogFactory; /** *************** *** 161,164 **** --- 160,164 ---- } + results.add( getResultColumnOrRow(row, rs, session) ); *************** *** 193,197 **** } ! protected Object getResultColumnOrRow(Object[] row, ResultSet rs, SessionImplementor session) throws SQLException, HibernateException { return row; } --- 193,198 ---- } ! protected Object getResultColumnOrRow(Object[] row, ResultSet rs, SessionImplementor session) ! throws SQLException, HibernateException { return row; } *************** *** 204,208 **** throws HibernateException, SQLException { - if (id==null) { //TODO: we can cache these on this object, from the constructor --- 205,208 ---- *************** *** 257,261 **** if ( !persisters[i].getMappedClass().isAssignableFrom( object.getClass() ) ) ! throw new WrongClassException( "loaded object was of wrong class", key.getIdentifier(), persisters[i].getMappedClass() ); } --- 257,261 ---- if ( !persisters[i].getMappedClass().isAssignableFrom( object.getClass() ) ) ! throw new WrongClassException( "loaded object was of wrong class", key.getIdentifier(), persisters[i].getMappedClass() ); } *************** *** 294,298 **** * Hydrate an object from the SQL <tt>ResultSet</tt> */ ! private void loadFromResultSet(ResultSet rs, Object object, Serializable id, String suffix, SessionImplementor session) throws SQLException, HibernateException { if ( log.isTraceEnabled() ) log.trace("Initializing object from ResultSet: " + id); --- 294,299 ---- * Hydrate an object from the SQL <tt>ResultSet</tt> */ ! private void loadFromResultSet(ResultSet rs, Object object, Serializable id, String suffix, SessionImplementor session) ! throws SQLException, HibernateException { if ( log.isTraceEnabled() ) log.trace("Initializing object from ResultSet: " + id); *************** *** 310,314 **** * Determine the concrete class of an instance in the <tt>ResultSet</tt> */ ! private Class getInstanceClass(ResultSet rs, Loadable persister, String suffix, Serializable id, SessionImplementor session) throws HibernateException, SQLException { Class topClass = persister.getMappedClass(); --- 311,316 ---- * Determine the concrete class of an instance in the <tt>ResultSet</tt> */ ! private Class getInstanceClass(ResultSet rs, Loadable persister, String suffix, Serializable id, SessionImplementor session) ! throws HibernateException, SQLException { Class topClass = persister.getMappedClass(); *************** *** 337,341 **** * Unmarshall the fields of a persistent instance from a result set */ ! private Object[] hydrate(ResultSet rs, Serializable id, Object object, Loadable persister, SessionImplementor session, String suffix) throws SQLException, HibernateException { if ( log.isTraceEnabled() ) log.trace("Hydrating entity: " + persister.getClassName() + '#' + id); --- 339,344 ---- * Unmarshall the fields of a persistent instance from a result set */ ! private Object[] hydrate(ResultSet rs, Serializable id, Object object, Loadable persister, SessionImplementor session, String suffix) ! throws SQLException, HibernateException { if ( log.isTraceEnabled() ) log.trace("Hydrating entity: " + persister.getClassName() + '#' + id); *************** *** 377,380 **** --- 380,391 ---- } + private boolean usePagingSelect(RowSelection selection, SessionImplementor session) { + return session.getFactory().getDialect().supportsPagingSelect() && ( + selection!=null && + selection.getMaxRows()!=null + ); + } + + /** * Obtain a <tt>PreparedStatement</tt> and bind JDBC-style <tt>?</tt> and named parameters *************** *** 382,397 **** protected final PreparedStatement prepareQueryStatement( String sql, ! Object[] ! values, Type[] types, Map namedParams, RowSelection selection, ! boolean scroll, SessionImplementor session ) throws SQLException, HibernateException { ! boolean scrollable = selection!=null && ! ( ( selection.getFirstRow()!=null && selection.getFirstRow().intValue()!=0 ) || scroll ) && ! session.getFactory().useScrollableResultSets(); PreparedStatement st = session.getBatcher().prepareQueryStatement(sql, scrollable); --- 393,416 ---- protected final PreparedStatement prepareQueryStatement( String sql, ! Object[] values, Type[] types, Map namedParams, RowSelection selection, ! boolean scroll, SessionImplementor session ) throws SQLException, HibernateException { + + boolean usePagingSelect = usePagingSelect(selection, session); ! boolean scrollable = session.getFactory().useScrollableResultSets() && ( ! scroll || ( ! !usePagingSelect && ! selection!=null && ! selection.getFirstRow()!=null && ! selection.getFirstRow().intValue()!=0 ! ) ! ); ! ! if (usePagingSelect) sql = session.getFactory().getDialect().getPagingSelect(sql); PreparedStatement st = session.getBatcher().prepareQueryStatement(sql, scrollable); *************** *** 407,412 **** } ! if (namedParams!=null) bindNamedParameters(st, namedParams, col, session); ! } catch (SQLException sqle) { --- 426,438 ---- } ! col += bindNamedParameters(st, namedParams, col, session); ! ! if (usePagingSelect) { ! int firstRow = (selection==null || selection.getFirstRow()==null ) ? 0 : selection.getFirstRow().intValue(); ! int lastRow = firstRow + selection.getMaxRows().intValue(); ! boolean reverse = session.getFactory().getDialect().reversePagingSelectOrder(); ! st.setInt( col + (reverse?1:0), firstRow ); ! st.setInt( col + (reverse?0:1), lastRow ); ! } } catch (SQLException sqle) { *************** *** 436,444 **** * advance to the first result and return an SQL <tt>ResultSet</tt> */ ! private final ResultSet getResultSet(PreparedStatement st, RowSelection selection, SessionImplementor session) throws SQLException, HibernateException { try { ! setMaxRows(st, selection); ResultSet rs = st.executeQuery(); ! advance(rs, selection, session); return rs; } --- 462,474 ---- * advance to the first result and return an SQL <tt>ResultSet</tt> */ ! protected final ResultSet getResultSet(PreparedStatement st, RowSelection selection, SessionImplementor session) ! throws SQLException, HibernateException { ! ! boolean usePagingSelect = usePagingSelect(selection, session); ! try { ! if (!usePagingSelect) setMaxRows(st, selection); ResultSet rs = st.executeQuery(); ! if (!usePagingSelect) advance(rs, selection, session); return rs; } *************** *** 450,454 **** } ! protected final void closePreparedStatement(PreparedStatement st, RowSelection selection, SessionImplementor session) throws SQLException, HibernateException { try { if (selection!=null) { --- 480,485 ---- } ! protected final void closePreparedStatement(PreparedStatement st, RowSelection selection, SessionImplementor session) ! throws SQLException, HibernateException { try { if (selection!=null) { *************** *** 466,470 **** * superclass and should be implemented by subclasses (queries) which allow named parameters. */ ! protected void bindNamedParameters(PreparedStatement st, Map namedParams, int start, SessionImplementor session) throws SQLException, HibernateException {} /** --- 497,502 ---- * superclass and should be implemented by subclasses (queries) which allow named parameters. */ ! protected int bindNamedParameters(PreparedStatement st, Map namedParams, int start, SessionImplementor session) ! throws SQLException, HibernateException { return 0; } /** |
From: <one...@us...> - 2003-05-03 07:20:54
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister In directory sc8-pr-cvs1:/tmp/cvs-serv15927/persister Modified Files: Queryable.java Log Message: applied paged SQL SELECT patch by David White Index: Queryable.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister/Queryable.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Queryable.java 25 Apr 2003 03:40:35 -0000 1.8 --- Queryable.java 3 May 2003 07:20:51 -0000 1.9 *************** *** 48,51 **** --- 48,52 ---- */ public String[] toColumns(String alias, String property) throws QueryException; + } |
From: <one...@us...> - 2003-05-03 07:20:53
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv15927/impl Modified Files: ScrollableResultsImpl.java Log Message: applied paged SQL SELECT patch by David White Index: ScrollableResultsImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/ScrollableResultsImpl.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ScrollableResultsImpl.java 25 Apr 2003 05:56:33 -0000 1.6 --- ScrollableResultsImpl.java 3 May 2003 07:20:50 -0000 1.7 *************** *** 14,17 **** --- 14,18 ---- import net.sf.hibernate.HibernateException; import net.sf.hibernate.JDBCException; + import net.sf.hibernate.MappingException; import net.sf.hibernate.ScrollableResults; import net.sf.hibernate.engine.SessionImplementor; *************** *** 119,124 **** } ! public ScrollableResultsImpl(ResultSet rs, SessionImplementor sess, Type[] types) ! throws HibernateException, SQLException { this.rs=rs; --- 120,124 ---- } ! public ScrollableResultsImpl(ResultSet rs, SessionImplementor sess, Type[] types) throws MappingException { this.rs=rs; |
From: <one...@us...> - 2003-05-03 07:20:53
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/engine In directory sc8-pr-cvs1:/tmp/cvs-serv15927/engine Modified Files: RowSelection.java Log Message: applied paged SQL SELECT patch by David White Index: RowSelection.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/engine/RowSelection.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RowSelection.java 25 Apr 2003 03:40:32 -0000 1.4 --- RowSelection.java 3 May 2003 07:20:49 -0000 1.5 *************** *** 3,7 **** /** ! * Represents a selection or rows in a JDBC <tt>ResultSet</tt> * @author Gavin King */ --- 3,7 ---- /** ! * Represents a selection of rows in a JDBC <tt>ResultSet</tt> * @author Gavin King */ |
From: <one...@us...> - 2003-05-03 07:20:52
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/dialect In directory sc8-pr-cvs1:/tmp/cvs-serv15927/dialect Modified Files: Dialect.java MySQLDialect.java Oracle9Dialect.java PostgreSQLDialect.java Log Message: applied paged SQL SELECT patch by David White Index: Dialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/dialect/Dialect.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Dialect.java 25 Apr 2003 03:40:31 -0000 1.12 --- Dialect.java 3 May 2003 07:20:49 -0000 1.13 *************** *** 347,350 **** --- 347,362 ---- } + public boolean supportsPagingSelect() { + return false; + } + + public String getPagingSelect(String querySelect) { + throw new UnsupportedOperationException("paged queries not supported"); + } + + public boolean reversePagingSelectOrder() { + return false; + } + } Index: MySQLDialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/dialect/MySQLDialect.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** MySQLDialect.java 25 Apr 2003 03:40:32 -0000 1.7 --- MySQLDialect.java 3 May 2003 07:20:49 -0000 1.8 *************** *** 83,86 **** --- 83,101 ---- } + public boolean supportsPagingSelect() { + return true; + } + + public String getPagingSelect(String sql) { + StringBuffer pagingSelect = new StringBuffer(); + pagingSelect.append(sql); + pagingSelect.append(" limit ?, ?"); + return pagingSelect.toString(); + } + + public boolean reversePagingSelectOrder() { + return false; + } + } Index: Oracle9Dialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/dialect/Oracle9Dialect.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Oracle9Dialect.java 25 Apr 2003 03:40:32 -0000 1.3 --- Oracle9Dialect.java 3 May 2003 07:20:49 -0000 1.4 *************** *** 41,45 **** public String getSequenceNextValString(String sequenceName) { ! return "select " + sequenceName + ".nextval from dual"; } public String getCreateSequenceString(String sequenceName) { --- 41,45 ---- public String getSequenceNextValString(String sequenceName) { ! return "select " + sequenceName + ".nextval from dual"; } public String getCreateSequenceString(String sequenceName) { *************** *** 60,63 **** --- 60,75 ---- public boolean supportsSequences() { return true; + } + + public boolean supportsPagingSelect() { + return true; + } + + public String getPagingSelect(String sql) { + StringBuffer pagingSelect = new StringBuffer(); + pagingSelect.append("select * from ( select a.*, rownum rnum from ( "); + pagingSelect.append(sql); + pagingSelect.append(" ) a where rownum <= ?) where rnum >= ?"); + return pagingSelect.toString(); } Index: PostgreSQLDialect.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/dialect/PostgreSQLDialect.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PostgreSQLDialect.java 25 Apr 2003 03:40:32 -0000 1.9 --- PostgreSQLDialect.java 3 May 2003 07:20:49 -0000 1.10 *************** *** 59,62 **** --- 59,76 ---- } + public boolean supportsPagingSelect() { + return true; + } + + public String getPagingSelect(String sql) { + StringBuffer pagingSelect = new StringBuffer(); + pagingSelect.append(sql); + pagingSelect.append(" limit ?, ?"); + return pagingSelect.toString(); + } + + public boolean reversePagingSelectOrder() { + return true; + } } |
From: <one...@us...> - 2003-05-03 07:14:33
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader In directory sc8-pr-cvs1:/tmp/cvs-serv12525 Modified Files: OuterJoinLoader.java Log Message: reenabled outerjoin loading for components of joined-subclasses Index: OuterJoinLoader.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/loader/OuterJoinLoader.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** OuterJoinLoader.java 25 Apr 2003 03:40:35 -0000 1.16 --- OuterJoinLoader.java 3 May 2003 07:14:30 -0000 1.17 *************** *** 14,18 **** import net.sf.hibernate.persister.ClassPersister; import net.sf.hibernate.persister.Loadable; - import net.sf.hibernate.persister.NormalizedEntityPersister; import net.sf.hibernate.sql.Alias; import net.sf.hibernate.sql.JoinFragment; --- 14,17 ---- *************** *** 132,139 **** */ private void walkTree(AbstractComponentType act, String[] cols, Object persister, String alias, List associations, Set classPersisters, SessionFactoryImplementor session) throws MappingException { ! if ( ! !session.enableJoinedFetch() || ! persister instanceof NormalizedEntityPersister //TODO: remove this + enable outerjoin fetching ! ) return; Type[] types = act.getSubtypes(); --- 131,135 ---- */ 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(); |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv7114/test Modified Files: FooBar.hbm.xml FooBarTest.java MasterDetailTest.java Multi.hbm.xml MultiTableTest.java SubMulti.java Log Message: fixed bugs querying a many-to-one association to a <joined-subclass> Index: FooBar.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBar.hbm.xml,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** FooBar.hbm.xml 10 Apr 2003 09:49:17 -0000 1.14 --- FooBar.hbm.xml 3 May 2003 07:06:26 -0000 1.15 *************** *** 13,17 **** dynamic-update="true"> ! <jcs-cache usage="read-write"/> <id name="key" type="string"> --- 13,17 ---- dynamic-update="true"> ! <jcs-cache usage="nonstrict-read-write"/> <id name="key" type="string"> Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** FooBarTest.java 2 May 2003 09:21:59 -0000 1.60 --- FooBarTest.java 3 May 2003 07:06:26 -0000 1.61 *************** *** 321,325 **** .add( Expression.eq( "integer", f.getInteger() ) ) .add( Expression.like( "string", f.getString() ) ) ! .add( Expression.eq( "boolean", f.getBoolean() ) ) .list(); assertTrue( list.size()==1 && list.get(0)==f ); --- 321,325 ---- .add( Expression.eq( "integer", f.getInteger() ) ) .add( Expression.like( "string", f.getString() ) ) ! .add( Expression.in( "boolean", new Boolean[] { f.getBoolean(), f.getBoolean() } ) ) .list(); assertTrue( list.size()==1 && list.get(0)==f ); Index: MasterDetailTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/MasterDetailTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** MasterDetailTest.java 16 Apr 2003 06:20:43 -0000 1.9 --- MasterDetailTest.java 3 May 2003 07:06:26 -0000 1.10 *************** *** 138,141 **** --- 138,147 ---- s = sessions.openSession(); t = s.beginTransaction(); + assertTrue( s.find("select elements(master.details) from Master master").size()==2 ); + t.commit(); + s.close(); + + s = sessions.openSession(); + t = s.beginTransaction(); Detail dd = (Detail) s.load(Detail.class, did); master = dd.getMaster(); Index: Multi.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Multi.hbm.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Multi.hbm.xml 2 Apr 2003 13:10:39 -0000 1.9 --- Multi.hbm.xml 3 May 2003 07:06:26 -0000 1.10 *************** *** 38,42 **** <bag name="bag" lazy="true" table="simple_simple"> <key column="simple1"/> ! <many-to-many column="simple2" class="net.sf.hibernate.test.Simple" not-null="true"/> </bag> <one-to-one name="mypo"/> --- 38,42 ---- <bag name="bag" lazy="true" table="simple_simple"> <key column="simple1"/> ! <many-to-many column="simple2" class="net.sf.hibernate.test.Simple"/> </bag> <one-to-one name="mypo"/> *************** *** 62,65 **** --- 62,70 ---- </bag> <many-to-one name="parent"/> + <list name="moreChildren" lazy="true"> + <key column="another_parent"/> + <index column="list_ind"/> + <one-to-many class="net.sf.hibernate.test.SubMulti"/> + </list> </joined-subclass> Index: MultiTableTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/MultiTableTest.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** MultiTableTest.java 16 Apr 2003 01:13:28 -0000 1.14 --- MultiTableTest.java 3 May 2003 07:06:26 -0000 1.15 *************** *** 25,28 **** --- 25,29 ---- public void testJoins() throws Exception { Session s = sessions.openSession(); + s.find("from SubMulti sm join sm.children smc where smc.name > 'a'"); s.find("select s, ya from LessSimple s join s.yetanother ya"); s.find("from LessSimple s1 join s1.bag s2"); *************** *** 31,35 **** --- 32,84 ---- s.find("select s, a from LessSimple s left join s.another a"); s.find("from Simple s, LessSimple ls"); + s.find("from LessSimple ls join ls.set s where s.name > 'a'"); + s.find("from Po po join po.list sm where sm.name > 'a'"); + s.close(); + } + + public void testSubclassCollection() throws Exception { + Session s = sessions.openSession(); + SubMulti sm = new SubMulti(); + SubMulti sm1 = new SubMulti(); + SubMulti sm2 = new SubMulti(); + ArrayList list = new ArrayList(); + ArrayList anotherList = new ArrayList(); + sm.setChildren(list); + sm.setMoreChildren(anotherList); + list.add(sm1); + list.add(sm2); + anotherList.add(sm1); + anotherList.add(sm2); + sm1.setParent(sm); + sm2.setParent(sm); + Serializable id = s.save(sm); + s.save(sm1); + s.save(sm2); + s.flush(); + s.connection().commit(); + s.close(); + + s = sessions.openSession(); + assertTrue( s.find("select s from SubMulti as sm join sm.children as s where s.amount>-1 and s.name is null").size()==2 ); + assertTrue( s.find("select elements(sm.children) from SubMulti as sm").size()==2 ); + assertTrue( s.find("select distinct sm from SubMulti as sm join sm.children as s where s.amount>-1 and s.name is null").size()==1 ); + sm = (SubMulti) s.load(SubMulti.class, id); + assertTrue( sm.getChildren().size()==2 ); + assertEquals( + s.filter( sm.getMoreChildren(), "select count(*) where this.amount>-1 and this.name is null" ).iterator().next(), + new Integer(2) + ); + assertSame( + s.iterate("select distinct s from s in class SubMulti where s.moreChildren[1].amount < 1.0").next(), + sm + ); + assertTrue( sm.getMoreChildren().size()==2 ); + s.delete(sm); + Iterator iter = sm.getChildren().iterator(); + while ( iter.hasNext() ) s.delete( iter.next() ); + s.flush(); + s.connection().commit(); s.close(); + } *************** *** 49,53 **** s.delete(m); t.commit(); ! s.close(); } --- 98,102 ---- s.delete(m); t.commit(); ! s.close(); } *************** *** 221,225 **** s.find("from ls in class LessSimple, s in ls.bag.elements where s.id is not null"); s.find("from ls in class LessSimple, s in ls.set.elements where s.id is not null"); ! s.find("from sm in class SubMulti where exists sm.children.elements"); t.commit(); --- 270,274 ---- s.find("from ls in class LessSimple, s in ls.bag.elements where s.id is not null"); s.find("from ls in class LessSimple, s in ls.set.elements where s.id is not null"); ! s.find("from sm in class SubMulti where exists sm.children.elements"); t.commit(); *************** *** 573,581 **** } } - - - - - - - --- 622,623 ---- Index: SubMulti.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/SubMulti.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SubMulti.java 5 Jan 2003 02:11:23 -0000 1.3 --- SubMulti.java 3 May 2003 07:06:27 -0000 1.4 *************** *** 8,11 **** --- 8,12 ---- private SubMulti parent; private List children; + private List moreChildren; /** * Returns the amount. *************** *** 56,59 **** --- 57,76 ---- } + /** + * Returns the moreChildren. + * @return List + */ + public List getMoreChildren() { + return moreChildren; + } + + /** + * Sets the moreChildren. + * @param moreChildren The moreChildren to set + */ + public void setMoreChildren(List moreChildren) { + this.moreChildren = moreChildren; + } + } |
From: <one...@us...> - 2003-05-03 07:06:30
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/sql In directory sc8-pr-cvs1:/tmp/cvs-serv7114/sql Modified Files: QueryJoinFragment.java Log Message: fixed bugs querying a many-to-one association to a <joined-subclass> Index: QueryJoinFragment.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/sql/QueryJoinFragment.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** QueryJoinFragment.java 9 Mar 2003 04:04:09 -0000 1.3 --- QueryJoinFragment.java 3 May 2003 07:06:27 -0000 1.4 *************** *** 16,19 **** --- 16,23 ---- public void addJoin(String tableName, String alias, String[] fkColumns, String[] pkColumns, int joinType) { + addJoin(tableName, alias, alias, fkColumns, pkColumns, joinType); + } + + public void addJoin(String tableName, String alias, String concreteAlias, String[] fkColumns, String[] pkColumns, int joinType) { if (joinType!=INNER_JOIN) { //TODO: get right impl for dialect *************** *** 24,28 **** else { addCrossJoin(tableName, alias); ! addCondition(alias, fkColumns, pkColumns); } } --- 28,32 ---- else { addCrossJoin(tableName, alias); ! addCondition(concreteAlias, fkColumns, pkColumns); } } |
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql In directory sc8-pr-cvs1:/tmp/cvs-serv3046 Modified Files: PathExpressionParser.java QueryTranslator.java SelectParser.java WhereParser.java Log Message: fixed bugs querying a many-to-one association to a <joined-subclass> Index: PathExpressionParser.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql/PathExpressionParser.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** PathExpressionParser.java 6 Apr 2003 02:28:57 -0000 1.17 --- PathExpressionParser.java 3 May 2003 06:58:30 -0000 1.18 *************** *** 11,14 **** --- 11,15 ---- import net.sf.hibernate.persister.Queryable; import net.sf.hibernate.sql.JoinFragment; + import net.sf.hibernate.sql.QueryJoinFragment; import net.sf.hibernate.type.EntityType; import net.sf.hibernate.type.PersistentCollectionType; *************** *** 26,29 **** --- 27,35 ---- //ways in which path expressions can occur + //We should actually rework this class to not implement Parser + //and just process path expressions in the most convenient way. + + //The class is now way to complex! + public static final String ENTITY_ID = "id"; public static final String ENTITY_CLASS = "class"; *************** *** 39,43 **** protected String currentName; protected String currentProperty; ! protected JoinFragment join; protected String[] columns; protected String[] collectionElementColumns; --- 45,49 ---- protected String currentName; protected String currentProperty; ! protected QueryJoinFragment join; protected String[] columns; protected String[] collectionElementColumns; *************** *** 53,56 **** --- 59,63 ---- private boolean continuation; private int joinType = JoinFragment.INNER_JOIN; //default mode + private boolean endsWithCollectionProperty = false; void setJoinType(int joinType) { *************** *** 59,64 **** private void addJoin(String table, String name, String[] rhsCols, QueryTranslator q) throws QueryException { String[] lhsCols = currentColumns(q); ! join.addJoin(table, name, lhsCols, rhsCols, joinType); } --- 66,74 ---- private void addJoin(String table, String name, String[] rhsCols, QueryTranslator q) throws QueryException { + addJoin(table, name, name, rhsCols, q); + } + private void addJoin(String table, String name, String concreteAlias, String[] rhsCols, QueryTranslator q) throws QueryException { String[] lhsCols = currentColumns(q); ! join.addJoin(table, name, concreteAlias, lhsCols, rhsCols, joinType); } *************** *** 163,176 **** collectionRole = ( (PersistentCollectionType) propertyType ).getRole(); ! CollectionPersister p = q.getCollectionPersister(collectionRole); ! String[] colNames = p.getKeyColumnNames(); String name= q.createNameForCollection(collectionRole); ! addJoin( p.getQualifiedTableName(), name, colNames, q ); ! if ( p.hasWhere() ) join.addCondition( p.getSQLWhereString(name) ); ! doCollectionProperty(token, p, name); collectionName = name; ! collectionTable = p.getQualifiedTableName(); currentName=null; currentProperty=null; --- 173,200 ---- collectionRole = ( (PersistentCollectionType) propertyType ).getRole(); ! CollectionPersister collPersister = q.getCollectionPersister(collectionRole); ! String[] colNames = collPersister.getKeyColumnNames(); String name= q.createNameForCollection(collectionRole); ! String tableName; ! String concreteAlias; ! if ( collPersister.isOneToMany() && !endsWithCollectionProperty ) { ! Queryable persister = q.getPersister( ( (EntityType) collPersister.getElementType() ).getPersistentClass() ); ! tableName = persister.getTableName(); ! concreteAlias = persister.getConcreteClassAlias(name); ! if ( joinType!=JoinFragment.INNER_JOIN && !name.equals(concreteAlias) ) ! throw new QueryException("outer and full join to collection of a subclass not currently supported by this mapping strategy: " +path); ! } ! else { ! tableName = collPersister.getQualifiedTableName(); ! concreteAlias=name; ! } ! ! addJoin(tableName, name, concreteAlias, colNames, q); ! if ( collPersister.hasWhere() ) join.addCondition( collPersister.getSQLWhereString(name) ); ! doCollectionProperty(token, collPersister, name); collectionName = name; ! collectionTable = collPersister.getQualifiedTableName(); currentName=null; currentProperty=null; *************** *** 253,257 **** --- 277,283 ---- public void end(QueryTranslator q) throws QueryException { + endsWithCollectionProperty = false; ignoreInitialJoin = false; + if ( isCollectionValued() ) { columns = collectionElementColumns; *************** *** 270,292 **** //special case; expecting: [index] ! CollectionPersister memberPersister = q.getCollectionPersister(collectionRole); ! if ( !memberPersister.hasIndex() ) throw new QueryException("unindexed collection before []: " + path); ! String[] indexCols = memberPersister.getIndexColumnNames(); if ( indexCols.length!=1 ) throw new QueryException("composite-index appears in []: " + path); ! String[] keyCols = memberPersister.getKeyColumnNames(); if (!continuation) { ! addJoin( memberPersister.getQualifiedTableName(), collectionName, keyCols, q ); } ! join.addCondition(collectionName, indexCols, " = "); ! String[] eltCols = memberPersister.getElementColumnNames(); //if ( eltCols.length!=1 ) throw new QueryException("composite-id collection element []"); CollectionElement elem = new CollectionElement(); elem.elementColumns = StringHelper.prefix( eltCols, collectionName + StringHelper.DOT ); ! elem.type = memberPersister.getElementType(); ! elem.isOneToMany = memberPersister.isOneToMany(); elem.alias = collectionName; elem.join = join; --- 296,334 ---- //special case; expecting: [index] ! CollectionPersister collPersister = q.getCollectionPersister(collectionRole); ! if ( !collPersister.hasIndex() ) throw new QueryException("unindexed collection before []: " + path); ! String[] indexCols = collPersister.getIndexColumnNames(); if ( indexCols.length!=1 ) throw new QueryException("composite-index appears in []: " + path); ! String[] keyCols = collPersister.getKeyColumnNames(); + String concreteAlias; + JoinFragment ojf = q.createJoinFragment(); + if ( collPersister.isOneToMany() ) { + Queryable persister = q.getPersister( ( (EntityType) collPersister.getElementType() ).getPersistentClass() ); + ojf.addCrossJoin( persister.getTableName(), collectionName ); + ojf.addJoins( + persister.fromJoinFragment(collectionName, true, false), + persister.whereJoinFragment(collectionName, true, false) + ); + concreteAlias = persister.getConcreteClassAlias(collectionName); + } + else { + ojf.addCrossJoin( collPersister.getQualifiedTableName(), collectionName ); + concreteAlias = collectionName; + } + if (!continuation) { ! addJoin( collPersister.getQualifiedTableName(), concreteAlias, keyCols, q ); } ! join.addCondition(concreteAlias, indexCols, " = "); ! String[] eltCols = collPersister.getElementColumnNames(); //if ( eltCols.length!=1 ) throw new QueryException("composite-id collection element []"); CollectionElement elem = new CollectionElement(); elem.elementColumns = StringHelper.prefix( eltCols, collectionName + StringHelper.DOT ); ! elem.type = collPersister.getElementType(); ! elem.isOneToMany = collPersister.isOneToMany(); elem.alias = collectionName; elem.join = join; *************** *** 295,300 **** q.addCollection(collectionName, collectionRole); - JoinFragment ojf = q.createJoinFragment(); - ojf.addCrossJoin( memberPersister.getQualifiedTableName(), collectionName ); q.addJoin(collectionName, ojf); } --- 337,340 ---- *************** *** 308,311 **** --- 348,352 ---- //important!! continuation=false; + } *************** *** 469,472 **** --- 510,527 ---- throw new QueryException("expecting 'elements' or 'indices' after: " + path); } + } + + /** + * Very ugly hack to allow collection paths to be processed correctly + * for normalized mappings + */ + public final void setPath(String path) { + endsWithCollectionProperty = path.endsWith(COLLECTION_ELEMENTS) || + path.endsWith(COLLECTION_INDICES) || + path.endsWith(COLLECTION_SIZE) || + path.endsWith(COLLECTION_MAX_INDEX) || + path.endsWith(COLLECTION_MAX_ELEMENT) || + path.endsWith(COLLECTION_MIN_INDEX) || + path.endsWith(COLLECTION_MIN_ELEMENT); } Index: QueryTranslator.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql/QueryTranslator.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** QueryTranslator.java 25 Apr 2003 05:56:33 -0000 1.25 --- QueryTranslator.java 3 May 2003 06:58:30 -0000 1.26 *************** *** 38,42 **** import net.sf.hibernate.type.Type; import net.sf.hibernate.util.ArrayHelper; - import net.sf.hibernate.util.JDBCExceptionReporter; import net.sf.hibernate.util.ReflectHelper; import net.sf.hibernate.util.StringHelper; --- 38,41 ---- *************** *** 112,116 **** * times. Subsequent invocations are no-ops. */ ! public synchronized void compile(SessionFactoryImplementor factory, String queryString, Map replacements, boolean scalar) throws QueryException, MappingException { if (!compiled) { this.factory = factory; --- 111,116 ---- * times. Subsequent invocations are no-ops. */ ! public synchronized void compile(SessionFactoryImplementor factory, String queryString, Map replacements, boolean scalar) ! throws QueryException, MappingException { if (!compiled) { this.factory = factory; *************** *** 659,665 **** JoinFragment join = createJoinFragment(); if ( persister.isOneToMany() ) { ! join.addCrossJoin( persister.getQualifiedTableName(), elementName ); ! join.addCondition(elementName, keyColumnNames, " = ?"); ! if ( persister.hasWhere() ) join.addCondition( persister.getSQLWhereString(elementName) ); } else { //many-to-many --- 659,667 ---- JoinFragment join = createJoinFragment(); if ( persister.isOneToMany() ) { ! Queryable classPersister = getPersister( ( (EntityType) persister.getElementType() ).getPersistentClass() ); ! String concreteAlias = classPersister.getConcreteClassAlias(elementName); ! join.addCrossJoin( classPersister.getTableName(), elementName ); ! join.addCondition(concreteAlias, keyColumnNames, " = ?"); ! if ( persister.hasWhere() ) join.addCondition( persister.getSQLWhereString(concreteAlias) ); } else { //many-to-many *************** *** 701,705 **** } ! protected void bindNamedParameters(PreparedStatement ps, Map namedParams, int start, SessionImplementor session) throws SQLException, HibernateException { if (namedParams!=null) { Iterator iter = namedParams.entrySet().iterator(); --- 703,707 ---- } ! protected int bindNamedParameters(PreparedStatement ps, Map namedParams, int start, SessionImplementor session) throws SQLException, HibernateException { if (namedParams!=null) { Iterator iter = namedParams.entrySet().iterator(); *************** *** 713,716 **** --- 715,722 ---- } } + return namedParams.size(); + } + else { + return 0; } } *************** *** 719,733 **** PreparedStatement st = prepareQueryStatement( getSQLString(), values, types, namedParams, selection, false, session ); ! try { ! setMaxRows(st, selection); ! ResultSet rs = st.executeQuery(); ! advance(rs, selection, session); ! return new IteratorImpl( rs, session, getReturnTypes(), getScalarColumnNames() ); ! } ! catch (SQLException sqle) { ! JDBCExceptionReporter.logExceptions(sqle); ! closePreparedStatement(st, selection, session); ! throw sqle; ! } } --- 725,731 ---- PreparedStatement st = prepareQueryStatement( getSQLString(), values, types, namedParams, selection, false, session ); ! ResultSet rs = getResultSet(st, selection, session); ! return new IteratorImpl( rs, session, getReturnTypes(), getScalarColumnNames() ); ! } *************** *** 735,749 **** PreparedStatement st = prepareQueryStatement( getSQLString(), values, types, namedParams, selection, true, session ); ! try { ! setMaxRows(st, selection); ! ResultSet rs = st.executeQuery(); ! advance(rs, selection, session); ! return new ScrollableResultsImpl( rs, session, getReturnTypes() ); ! } ! catch (SQLException sqle) { ! JDBCExceptionReporter.logExceptions(sqle); ! closePreparedStatement(st, selection, session); ! throw sqle; ! } } --- 733,739 ---- PreparedStatement st = prepareQueryStatement( getSQLString(), values, types, namedParams, selection, true, session ); ! ResultSet rs = getResultSet(st, selection, session); ! return new ScrollableResultsImpl( rs, session, getReturnTypes() ); ! } Index: SelectParser.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql/SelectParser.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SelectParser.java 8 Apr 2003 09:49:29 -0000 1.10 --- SelectParser.java 3 May 2003 06:58:30 -0000 1.11 *************** *** 121,124 **** --- 121,125 ---- else if (aggregate) { if (!ready) throw new QueryException("( expected after aggregate function in SELECT"); + aggregatePathExpressionParser.setPath(token); ParserHelper.parse(aggregatePathExpressionParser, q.unalias(token), ParserHelper.PATH_SEPARATORS, q); *************** *** 135,139 **** else { if (!ready) throw new QueryException(", expected in SELECT"); ! ParserHelper.parse(pathExpressionParser, q.unalias(token), ParserHelper.PATH_SEPARATORS, q); if ( pathExpressionParser.isCollectionValued() ) { --- 136,140 ---- else { if (!ready) throw new QueryException(", expected in SELECT"); ! pathExpressionParser.setPath(token); ParserHelper.parse(pathExpressionParser, q.unalias(token), ParserHelper.PATH_SEPARATORS, q); if ( pathExpressionParser.isCollectionValued() ) { Index: WhereParser.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql/WhereParser.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** WhereParser.java 3 Apr 2003 12:34:25 -0000 1.12 --- WhereParser.java 3 May 2003 06:58:30 -0000 1.13 *************** *** 357,360 **** --- 357,362 ---- preprocess(token, q); + pathExpressionParser.setPath(token); + StringTokenizer tokens = new StringTokenizer(token, ".", true); pathExpressionParser.start(q); |
From: <one...@us...> - 2003-05-03 01:54:33
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/expression In directory sc8-pr-cvs1:/tmp/cvs-serv18396 Modified Files: InExpression.java Log Message: fixed a bug in SQL rendering Index: InExpression.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/expression/InExpression.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** InExpression.java 25 Apr 2003 03:40:33 -0000 1.2 --- InExpression.java 3 May 2003 01:54:25 -0000 1.3 *************** *** 23,27 **** String params = StringHelper.repeat( "?, ", values.length-1 ); if ( values.length>0 ) params+="?"; ! return getColumns(sessionFactory, persistentClass, propertyName, alias) + " in (" + params + ')'; //TODO: get SQL rendering out of this package! --- 23,34 ---- String params = StringHelper.repeat( "?, ", values.length-1 ); if ( values.length>0 ) params+="?"; ! String condition = " in (" + params + ')'; ! return StringHelper.join( ! " and ", ! StringHelper.suffix( ! getColumns(sessionFactory, persistentClass, propertyName, alias), ! condition ! ) ! ); //TODO: get SQL rendering out of this package! |
From: <one...@us...> - 2003-05-02 09:22:03
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test In directory sc8-pr-cvs1:/tmp/cvs-serv20532/test Modified Files: Baz.hbm.xml Baz.java FooBarTest.java Log Message: added idbag and made some cleanups to collection fwk Index: Baz.hbm.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Baz.hbm.xml,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Baz.hbm.xml 18 Apr 2003 05:09:51 -0000 1.18 --- Baz.hbm.xml 2 May 2003 09:21:59 -0000 1.19 *************** *** 89,98 **** <set name="stringSet" lazy="true" sort="natural"> <!--<jcs-cache usage="read-write"/>--> ! <key column="id_" /> <element column="element" type="string" not-null="true" length="32"/> </set> <map name="stringDateMap" lazy="true" sort="net.sf.hibernate.test.ReverseComparator"> ! <key column="id_" /> <index column="map_key" type="string" length="32"/> <element column="map_value" type="date"/> --- 89,98 ---- <set name="stringSet" lazy="true" sort="natural"> <!--<jcs-cache usage="read-write"/>--> ! <key column="id_"/> <element column="element" type="string" not-null="true" length="32"/> </set> <map name="stringDateMap" lazy="true" sort="net.sf.hibernate.test.ReverseComparator"> ! <key column="id_"/> <index column="map_key" type="string" length="32"/> <element column="map_value" type="date"/> *************** *** 101,105 **** <array name="fooArray" element-class="net.sf.hibernate.test.FooProxy" where="i<8"> <jcs-cache usage="read-write"/> ! <key column="id_" /> <index column="i"/> <many-to-many class="net.sf.hibernate.test.Foo"> --- 101,105 ---- <array name="fooArray" element-class="net.sf.hibernate.test.FooProxy" where="i<8"> <jcs-cache usage="read-write"/> ! <key column="id_"/> <index column="i"/> <many-to-many class="net.sf.hibernate.test.Foo"> *************** *** 109,118 **** <bag name="fooBag" lazy="true" table="baz_foo" cascade="all"> ! <key column="baz" /> <many-to-many class="net.sf.hibernate.test.Foo" column="foo" outer-join="true"/> </bag> <array name="stringArray"> ! <key column="id_" /> <index column="i"/> <element column="name" type="string"/> --- 109,134 ---- <bag name="fooBag" lazy="true" table="baz_foo" cascade="all"> ! <key column="baz"/> <many-to-many class="net.sf.hibernate.test.Foo" column="foo" outer-join="true"/> </bag> + <idbag name="idFooBag" lazy="true" table="baz_id_foo" cascade="all"> + <collection-id column="pkid" type="long"> + <generator class="hilo"/> + </collection-id> + <key column="baz"/> + <many-to-many class="net.sf.hibernate.test.Foo" column="foo" outer-join="true"/> + </idbag> + + <idbag name="byteBag" lazy="true" table="baz_byte_bag" cascade="all"> + <collection-id column="pkid" type="long"> + <generator class="hilo"/> + </collection-id> + <key column="baz"/> + <element type="binary" column="bytez" not-null="true"/> + </idbag> + <array name="stringArray"> ! <key column="id_"/> <index column="i"/> <element column="name" type="string"/> Index: Baz.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/Baz.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Baz.java 5 Apr 2003 07:13:38 -0000 1.9 --- Baz.java 2 May 2003 09:21:59 -0000 1.10 *************** *** 42,45 **** --- 42,47 ---- private Map stringGlarchMap; private Map anyToAny; + private Collection idFooBag; + private Collection byteBag; Baz() {} *************** *** 339,342 **** --- 341,360 ---- public void setAnyToAny(Map anyToAny) { this.anyToAny = anyToAny; + } + + public Collection getIdFooBag() { + return idFooBag; + } + + public void setIdFooBag(Collection collection) { + idFooBag = collection; + } + + public Collection getByteBag() { + return byteBag; + } + + public void setByteBag(Collection list) { + byteBag = list; } Index: FooBarTest.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/test/FooBarTest.java,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** FooBarTest.java 25 Apr 2003 03:40:36 -0000 1.59 --- FooBarTest.java 2 May 2003 09:21:59 -0000 1.60 *************** *** 59,62 **** --- 59,110 ---- } + public void testIdBag() throws Exception { + Session s = sessions.openSession(); + Baz baz = new Baz(); + s.save(baz); + List l = new ArrayList(); + List l2 = new ArrayList(); + baz.setIdFooBag(l); + baz.setByteBag(l2); + l.add( new Foo() ); + l.add( new Bar() ); + byte[] bytes = "ffo".getBytes(); + l2.add(bytes); + l2.add( "foo".getBytes() ); + s.flush(); + l.add( new Foo() ); + l.add( new Bar() ); + l2.add( "bar".getBytes() ); + s.flush(); + s.delete( l.remove(3) ); + bytes[1]='o'; + s.flush(); + s.connection().commit(); + s.close(); + + s = sessions.openSession(); + baz = (Baz) s.load(Baz.class, baz.getCode()); + assertTrue( baz.getIdFooBag().size()==3 ); + assertTrue( baz.getByteBag().size()==3 ); + bytes = "foobar".getBytes(); + Iterator iter = baz.getIdFooBag().iterator(); + while ( iter.hasNext() ) s.delete( iter.next() ); + baz.setIdFooBag(null); + baz.getByteBag().add(bytes); + baz.getByteBag().add(bytes); + s.flush(); + s.connection().commit(); + s.close(); + + s = sessions.openSession(); + baz = (Baz) s.load(Baz.class, baz.getCode()); + assertTrue( baz.getIdFooBag().size()==0 ); + assertTrue( baz.getByteBag().size()==5 ); + s.delete(baz); + s.flush(); + s.connection().commit(); + s.close(); + } + public void testForceOuterJoin() throws Exception { Session s = sessions.openSession(); |
From: <one...@us...> - 2003-05-02 09:22:02
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate In directory sc8-pr-cvs1:/tmp/cvs-serv20532 Modified Files: hibernate-mapping-2.0.dtd Log Message: added idbag and made some cleanups to collection fwk Index: hibernate-mapping-2.0.dtd =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hibernate-mapping-2.0.dtd,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** hibernate-mapping-2.0.dtd 11 Apr 2003 07:15:51 -0000 1.23 --- hibernate-mapping-2.0.dtd 2 May 2003 09:21:57 -0000 1.24 *************** *** 38,42 **** discriminator?, (version|timestamp)?, ! (property|many-to-one|one-to-one|component|dynabean|any|map|set|list|bag|array|primitive-array)*, ((subclass*)|(joined-subclass*)) )> --- 38,42 ---- discriminator?, (version|timestamp)?, ! (property|many-to-one|one-to-one|component|dynabean|any|map|set|list|bag|idbag|array|primitive-array)*, ((subclass*)|(joined-subclass*)) )> *************** *** 99,103 **** <!ELEMENT subclass ( meta*, ! (property|many-to-one|one-to-one|component|any|map|set|list|bag|array|primitive-array)*, subclass* )> --- 99,103 ---- <!ELEMENT subclass ( meta*, ! (property|many-to-one|one-to-one|component|any|map|set|list|bag|idbag|array|primitive-array)*, subclass* )> *************** *** 113,117 **** meta*, key, ! (property|many-to-one|one-to-one|component|any|map|set|list|bag|array|primitive-array)*, joined-subclass* )> --- 113,117 ---- meta*, key, ! (property|many-to-one|one-to-one|component|any|map|set|list|bag|idbag|array|primitive-array)*, joined-subclass* )> *************** *** 266,269 **** --- 266,284 ---- <!ATTLIST bag where CDATA #IMPLIED> <!-- default: none --> + <!ELEMENT idbag ( + meta*, + jcs-cache?, + collection-id, + key, + (element|many-to-many|composite-element|many-to-any) + )> + <!ATTLIST idbag name CDATA #REQUIRED> + <!ATTLIST idbag table CDATA #IMPLIED> <!-- default: name --> + <!ATTLIST idbag schema CDATA #IMPLIED> <!-- default: none --> + <!ATTLIST idbag lazy (true|false) "false"> + <!ATTLIST idbag cascade (none|all|save-update|delete) #IMPLIED> <!-- default: none --> + <!ATTLIST idbag order-by CDATA #IMPLIED> <!-- default: none --> + <!ATTLIST idbag where CDATA #IMPLIED> <!-- default: none --> + <!ELEMENT list ( meta*, *************** *** 324,328 **** <!ATTLIST many-to-many class CDATA #REQUIRED> <!ATTLIST many-to-many column CDATA #IMPLIED> - <!ATTLIST many-to-many not-null (true|false) "false"> <!ATTLIST many-to-many outer-join (true|false|auto) "auto"> <!-- unique makes no sense here since it would make the association one-to-many --> --- 339,342 ---- *************** *** 385,388 **** --- 399,407 ---- <!ATTLIST index-many-to-any meta-type CDATA #IMPLIED> <!--- default: Hibernate.CLASS --> + <!ELEMENT collection-id (meta*, column*, generator)> + <!ATTLIST collection-id column CDATA #REQUIRED> + <!ATTLIST collection-id type CDATA #REQUIRED> + <!ATTLIST collection-id length CDATA #IMPLIED> + <!-- Generators generate unique identifiers. The class attribute specifies a Java class implementing an id generation algorithm. --> |