⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hqltest.java

📁 hibernate 开源框架的代码 jar包希望大家能喜欢
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	}	// TESTS THAT FAIL ONLY ON DIALECTS WITH THETA-STYLE OUTERJOINS:	public void testIndexWithExplicitJoin() throws Exception {		//TODO: broken on dialects with theta-style outerjoins:		//      steve (2005.10.06) - this works perfectly for me on Oracle8i		assertTranslation( "from Zoo zoo join zoo.animals an where zoo.mammals[ index(an) ] = an" );		assertTranslation( "from Zoo zoo join zoo.mammals dog where zoo.mammals[ index(dog) ] = dog" );		assertTranslation( "from Zoo zoo join zoo.mammals dog where dog = zoo.mammals[ index(dog) ]" );	}	public void testOneToManyMapIndex() throws Exception {		//TODO: this breaks on dialects with theta-style outerjoins:		//      steve (2005.10.06) - this works perfectly for me on Oracle8i		assertTranslation( "from Zoo zoo where zoo.mammals['dog'].description like '%black%'" );		assertTranslation( "from Zoo zoo where zoo.mammals['dog'].father.description like '%black%'" );		assertTranslation( "from Zoo zoo where zoo.mammals['dog'].father.id = 1234" );		assertTranslation( "from Zoo zoo where zoo.animals['1234'].description like '%black%'" );	}	public void testExplicitJoinMapIndex() throws Exception {		//TODO: this breaks on dialects with theta-style outerjoins:		//      steve (2005.10.06) - this works perfectly for me on Oracle8i		assertTranslation( "from Zoo zoo, Dog dog where zoo.mammals['dog'] = dog" );		assertTranslation( "from Zoo zoo join zoo.mammals dog where zoo.mammals['dog'] = dog" );	}	public void testIndexFunction() throws Exception {		// Instead of doing the pre-processor trick like the existing QueryTranslator, this		// is handled by MethodNode.		//      steve (2005.10.06) - this works perfectly for me on Oracle8i		//TODO: broken on dialects with theta-style outerjoins:		assertTranslation( "from Zoo zoo join zoo.mammals dog where index(dog) = 'dog'" );		assertTranslation( "from Zoo zoo join zoo.animals an where index(an) = '1234'" );	}	public void testSelectCollectionOfValues() throws Exception {		//TODO: broken on dialects with theta-style joins		///old parser had a bug where the collection element was not included in return types!		//      steve (2005.10.06) - this works perfectly for me on Oracle8i		assertTranslation( "select baz, date from Baz baz join baz.stringDateMap date where index(date) = 'foo'" );	}	public void testCollectionOfValues() throws Exception {		//old parser had a bug where the collection element was not returned!		//TODO: broken on dialects with theta-style joins		//      steve (2005.10.06) - this works perfectly for me on Oracle8i		assertTranslation( "from Baz baz join baz.stringDateMap date where index(date) = 'foo'" );	}    public void testHHH719() throws Exception {        assertTranslation("from Baz b order by org.bazco.SpecialFunction(b.id)");        assertTranslation("from Baz b order by anypackage.anyFunction(b.id)");    }	//PASSING TESTS:	public void testParameterListExpansion() {		assertTranslation( "from Animal as animal where animal.id in (:idList_1, :idList_2)" );	}	public void testComponentManyToOneDereferenceShortcut() {		assertTranslation( "from Zoo z where z.address.stateProvince.id is null" );	}	public void testNestedCollectionImplicitJoins() {		// HHH-770		assertTranslation( "select h.friends.offspring from Human h" );	}	public void testExplicitJoinsInSubquery() {		// test for HHH-557,		// TODO : this passes regardless because the only difference between the two sqls is one extra comma		// (commas are eaten by the tokenizer during asserTranslation when building the token maps).		assertTranslation(		        "from org.hibernate.test.hql.Animal as animal " +		        "where animal.id in (" +		        "        select a.id " +		        "        from org.hibernate.test.hql.Animal as a " +		        "               left join a.mother as mo" +		        ")"		);	}	public void testImplicitJoinsInGroupBy() {		assertTranslation(		        "select o.mother.bodyWeight, count(distinct o) " +		        "from Animal an " +		        "   join an.offspring as o " +		        "group by o.mother.bodyWeight"		);	}	public void testCrazyIdFieldNames() {		DotNode.useThetaStyleImplicitJoins = true;		// only regress against non-scalar forms as there appears to be a bug in the classic translator		// in regards to this issue also.  Specifically, it interprets the wrong return type, though it gets		// the sql "correct" :/		String hql = "select e.heresAnotherCrazyIdFieldName from MoreCrazyIdFieldNameStuffEntity e where e.heresAnotherCrazyIdFieldName is not null";		assertTranslation( hql, new HashMap(), false, ( String ) null );	    hql = "select e.heresAnotherCrazyIdFieldName.heresAnotherCrazyIdFieldName from MoreCrazyIdFieldNameStuffEntity e where e.heresAnotherCrazyIdFieldName is not null";		assertTranslation( hql, new HashMap(), false, ( String ) null );		DotNode.useThetaStyleImplicitJoins = false;	}	public void testSizeFunctionAndProperty() {		assertTranslation("from Animal a where a.offspring.size > 0");		assertTranslation("from Animal a join a.offspring where a.offspring.size > 1");		assertTranslation("from Animal a where size(a.offspring) > 0");		assertTranslation("from Animal a join a.offspring o where size(a.offspring) > 1");		assertTranslation("from Animal a where size(a.offspring) > 1 and size(a.offspring) < 100");		assertTranslation("from Human a where a.family.size > 0");		assertTranslation("from Human a join a.family where a.family.size > 1");		assertTranslation("from Human a where size(a.family) > 0");		assertTranslation("from Human a join a.family o where size(a.family) > 1");		assertTranslation("from Human a where a.family.size > 0 and a.family.size < 100");}	// Do the simplest test first!	public void testFromOnly() throws Exception {		// 2004-06-21 [jsd] This test now works with the new AST based QueryTranslatorImpl.		assertTranslation( "from Animal" );		assertTranslation( "from Model" );	}	public void testJoinPathEndingInValueCollection() {		assertTranslation( "select h from Human as h join h.nickNames as nn where h.nickName=:nn1 and (nn=:nn2 or nn=:nn3)" );	}	public void testSerialJoinPathEndingInValueCollection() {		// HHH-242		assertTranslation( "select h from Human as h join h.friends as f join f.nickNames as nn where h.nickName=:nn1 and (nn=:nn2 or nn=:nn3)" );	}	public void testImplicitJoinContainedByCollectionFunction() {		// HHH-281 : Implied joins in a collection function (i.e., indices or elements)		assertTranslation( "from Human as h where 'shipping' in indices(h.father.addresses)" );		assertTranslation( "from Human as h where 'shipping' in indices(h.father.father.addresses)" );		assertTranslation( "from Human as h where 'sparky' in elements(h.father.nickNames)" );		assertTranslation( "from Human as h where 'sparky' in elements(h.father.father.nickNames)" );	}	public void testImpliedJoinInSubselectFrom() {		// HHH-276 : Implied joins in a from in a subselect.		assertTranslation( "from Animal a where exists( from a.mother.offspring )" );	}	public void testSubselectImplicitJoins() {		// HHH-276 : Implied joins in a from in a subselect.		assertTranslation( "from Simple s where s = some( select sim from Simple sim where sim.other.count=s.other.count )" );	}	public void testCollectionOfValuesSize() throws Exception {		//SQL *was* missing a comma		assertTranslation( "select size(baz.stringDateMap) from org.hibernate.test.legacy.Baz baz" );	}	public void testCollectionFunctions() throws Exception {		//these are both broken, a join that belongs in the subselect finds its way into the main query		assertTranslation( "from Zoo zoo where size(zoo.animals) > 100" );		assertTranslation( "from Zoo zoo where maxindex(zoo.mammals) = 'dog'" );	}	public void testImplicitJoinInExplicitJoin() throws Exception {		assertTranslation( "from Animal an inner join an.mother.mother gm" );		assertTranslation( "from Animal an inner join an.mother.mother.mother ggm" );		assertTranslation( "from Animal an inner join an.mother.mother.mother.mother gggm" );	}	public void testImpliedManyToManyProperty() throws Exception {		//missing a table join (SQL correct for a one-to-many, not for a many-to-many)		assertTranslation( "select c from ContainerX c where c.manyToMany[0].name = 's'" );	}	public void testCollectionSize() throws Exception {		//SQL is correct, query spaces *was* missing a table		assertTranslation( "select size(zoo.animals) from Zoo zoo" );	}	/*public void testCollectionIndexFunctionsInSelect() throws Exception {		assertTranslation("select maxindex(zoo.animals) from Zoo zoo");		assertTranslation("select minindex(zoo.animals) from Zoo zoo");		assertTranslation("select indices(zoo.animals) from Zoo zoo");	}	public void testCollectionElementFunctionsInSelect() throws Exception {		assertTranslation("select maxelement(zoo.animals) from Zoo zoo");		assertTranslation("select minelement(zoo.animals) from Zoo zoo");		assertTranslation("select elements(zoo.animals) from Zoo zoo");	}*/	public void testFetchCollectionOfValues() throws Exception {		assertTranslation( "from Baz baz left join fetch baz.stringSet" );	}	public void testFetchList() throws Exception {		assertTranslation( "from User u join fetch u.permissions" );	}	public void testCollectionFetchWithExplicitThetaJoin() {		assertTranslation( "select m from Master m1, Master m left join fetch m.details where m.name=m1.name" );	}	/*public void testListElementFunctionInSelect() throws Exception {		//wrong pk column in select clause! (easy fix?)		assertTranslation("select maxelement(u.permissions) from User u");		assertTranslation("select elements(u.permissions) from User u");	}*/	public void testListElementFunctionInWhere() throws Exception {		assertTranslation( "from User u where 'read' in elements(u.permissions)" );		assertTranslation( "from User u where 'write' <> all elements(u.permissions)" );	}	/*public void testManyToManyElementFunctionInSelect() throws Exception {		assertTranslation("select maxelement(human.friends) from Human human");		assertTranslation("select elements(human.friends) from Human human");	}*/	public void testManyToManyMaxElementFunctionInWhere() throws Exception {		//completely broken!!		assertTranslation( "from Human human where 5 = maxelement(human.friends)" );	}	public void testCollectionIndexFunctionsInWhere() throws Exception {		assertTranslation( "from Zoo zoo where 4 = maxindex(zoo.animals)" );		assertTranslation( "from Zoo zoo where 2 = minindex(zoo.animals)" );	}	public void testCollectionIndicesInWhere() throws Exception {		assertTranslation( "from Zoo zoo where 4 > some indices(zoo.animals)" );		assertTranslation( "from Zoo zoo where 4 > all indices(zoo.animals)" );	}	public void testIndicesInWhere() throws Exception {		assertTranslation( "from Zoo zoo where 4 in indices(zoo.animals)" );		assertTranslation( "from Zoo zoo where exists indices(zoo.animals)" );	}	public void testCollectionElementInWhere() throws Exception {		assertTranslation( "from Zoo zoo where 4 > some elements(zoo.animals)" );		assertTranslation( "from Zoo zoo where 4 > all elements(zoo.animals)" );	}	public void testElementsInWhere() throws Exception {		assertTranslation( "from Zoo zoo where 4 in elements(zoo.animals)" );		assertTranslation( "from Zoo zoo where exists elements(zoo.animals)" );	}	public void testNull() throws Exception {		assertTranslation( "from Human h where h.nickName is null" );		assertTranslation( "from Human h where h.nickName is not null" );	}	public void testSubstitutions() throws Exception {		Map replacements = buildTrueFalseReplacementMapForDialect();		replacements.put("yes", "'Y'");		assertTranslation( "from Human h where h.pregnant = true", replacements );		assertTranslation( "from Human h where h.pregnant = yes", replacements );		assertTranslation( "from Human h where h.pregnant = foo", replacements );	}	public void testWhere() throws Exception {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -