jpaqlcompliancetest.java

来自「好东西,hibernate-3.2.0,他是一开元的树杖hibernate-3.」· Java 代码 · 共 56 行

JAVA
56
字号
package org.hibernate.test.jpa.ql;

import org.hibernate.test.jpa.AbstractJPATest;
import org.hibernate.Session;
import org.hibernate.hql.ast.QuerySyntaxException;
import junit.framework.Test;
import junit.framework.TestSuite;

/**
 * Tests for various JPAQL compliance issues
 *
 * @author Steve Ebersole
 */
public class JPAQLComplianceTest extends AbstractJPATest {
	public JPAQLComplianceTest(String name) {
		super( name );
	}

	public static Test suite() {
		return new TestSuite( JPAQLComplianceTest.class );
	}

	public void testAliasNameSameAsUnqualifiedEntityName() {
		Session s = openSession();
		s.beginTransaction();
		s.createQuery( "select item from Item item" ).list();
		s.createQuery( "select item from Item item where item.name = 'a'" ).list();
		s.getTransaction().commit();
		s.close();
	}

	public void testNoSelectClause() {
		Session s = openSession();
		try {
			s.createQuery( "from Part" ).list();
			fail( "expecting parse failure" );
		}
		catch( QuerySyntaxException qe ) {
			// expected behavior
		}
		s.close();
	}

	public void testIdentifierCaseSensitive() throws Exception {
		Session s = openSession( );
		s.createQuery( "select object(I) from Item i").list();
		s.close();
	}

	public void testGeneratedSubquery() {
		Session s = openSession();
		s.createQuery( "select c FROM Item c WHERE c.parts IS EMPTY" ).list();
		s.close();
	}
}

⌨️ 快捷键说明

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