📄 subquerytest.java
字号:
package org.jbpm.persistence.hibernate;
import net.sf.hibernate.*;
import org.apache.commons.logging.*;
import org.jbpm.*;
import org.jbpm.model.definition.impl.*;
import junit.framework.*;
public class SubQueryTest extends TestCase {
static { TestHelper.initLogging(); }
private HibernateTestHelper hibernate = null;
public void setUp() {
hibernate = new HibernateTestHelper();
}
public void testIfDatabaseSupportsSubQueries() throws Exception {
// create the definition
DefinitionImpl definition = null;
hibernate.startTransaction();
definition = new DefinitionImpl("the versioned process");
definition.setVersion( new Integer( 1 ) );
hibernate.getSession().save( definition );
definition = new DefinitionImpl("the versioned process");
definition.setVersion( new Integer( 2 ) );
hibernate.getSession().save( definition );
definition = new DefinitionImpl("the versioned process");
definition.setVersion( new Integer( 3 ) );
hibernate.getSession().save( definition );
hibernate.commitTransaction();
String subQuery =
"select d " +
"from d in class org.jbpm.model.definition.impl.DefinitionImpl " +
"where d.name = ? " +
" and d.version = ( " +
" select max(d2.version) " +
" from d2 in class org.jbpm.model.definition.impl.DefinitionImpl " +
" where d2.name = d.name )";
hibernate.startTransaction();
definition = (DefinitionImpl) hibernate.getSession().find( subQuery, "the versioned process", Hibernate.STRING ).get(0);
assertEquals( "the versioned process", definition.getName() );
assertEquals( new Integer( 3 ), definition.getVersion() );
hibernate.commitTransaction();
}
private static Log log = LogFactory.getLog(SubQueryTest.class);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -