当前位置: 首页>>代码示例>>Java>>正文


Java QueryFactory.from方法代码示例

本文整理汇总了Java中ch.digitalfondue.npjt.QueryFactory.from方法的典型用法代码示例。如果您正苦于以下问题:Java QueryFactory.from方法的具体用法?Java QueryFactory.from怎么用?Java QueryFactory.from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ch.digitalfondue.npjt.QueryFactory的用法示例。


在下文中一共展示了QueryFactory.from方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: autogeneratedKeyQueries

import ch.digitalfondue.npjt.QueryFactory; //导入方法依赖的package包/类
@Test
public void autogeneratedKeyQueries() {
	QueryFactory qf = new QueryFactory("hsqldb", dataSource);

	AutogeneratedKeyQueries aq = qf.from(AutogeneratedKeyQueries.class);

	aq.createTable();

	AffectedRowCountAndKey<Integer> res = aq.insert("test");
	AffectedRowCountAndKey<Integer> res2 = aq.insert("test2");
	AffectedRowCountAndKey<Integer> res3 = aq.insert("test3");

	Assert.assertEquals(aq.findKeyByValue("test"), res.getKey());
	Assert.assertEquals(1, res.getAffectedRowCount());
	
	Assert.assertEquals(aq.findKeyByValue("test2"), res2.getKey());
	Assert.assertEquals(1, res2.getAffectedRowCount());
	
	Assert.assertEquals(aq.findKeyByValue("test3"), res3.getKey());
	Assert.assertEquals(1, res3.getAffectedRowCount());
}
 
开发者ID:digitalfondue,项目名称:npjt-extra,代码行数:22,代码来源:AutogeneratedKeyQueriesTest.java

示例2: enumQueriesTest

import ch.digitalfondue.npjt.QueryFactory; //导入方法依赖的package包/类
@Test
public void enumQueriesTest() {
	QueryFactory qf = new QueryFactory("hsqldb", new JdbcTemplate(dataSource));
	EnumQueries eq = qf.from(EnumQueries.class);
	
	eq.createTable();

	eq.insert(null);
	
	eq.insert(TestEnum.TEST);
	eq.insert(TestEnum.TEST2);

	Assert.assertEquals(null, eq.findByNull());
	Assert.assertEquals(TestEnum.TEST, eq.findByKey(TestEnum.TEST));
	Assert.assertEquals(TestEnum.TEST2, eq.findByKey(TestEnum.TEST2));
	
	Assert.assertEquals(TestEnum.TEST, eq.findContainerByKey(TestEnum.TEST).key);
	Assert.assertEquals(null, eq.findContainerByKeyNull().key);
	
	List<TestEnum> all = eq.findAll();
	Assert.assertTrue(all.contains(TestEnum.TEST));
	Assert.assertTrue(all.contains(TestEnum.TEST2));
	Assert.assertTrue(all.contains(null));
}
 
开发者ID:digitalfondue,项目名称:npjt-extra,代码行数:25,代码来源:EnumQueriesTest.java

示例3: testSimpleAnnotationQuery

import ch.digitalfondue.npjt.QueryFactory; //导入方法依赖的package包/类
@Test
public void testSimpleAnnotationQuery() {
	QueryFactory qf = new QueryFactory("HSQLDB", jdbc);

	QueryTest qt = qf.from(QueryTest.class);

	Assert.assertEquals("SELECT * FROM LA_BOARD_COLUMN_FULL WHERE BOARD_COLUMN_ID = :columnId", qt.findById());
}
 
开发者ID:digitalfondue,项目名称:npjt-extra,代码行数:9,代码来源:QueryFactoryTest.java

示例4: testOverrideAnnotation

import ch.digitalfondue.npjt.QueryFactory; //导入方法依赖的package包/类
@Test
public void testOverrideAnnotation() {
	QueryFactory qf = new QueryFactory("HSQLDB", jdbc);
	QueryTest qt = qf.from(QueryTest.class);
	Assert.assertEquals("SELECT * FROM LA_BOARD_COLUMN_FULL WHERE BOARD_COLUMN_ID = :columnId", qt.overrideQuery());

	QueryFactory qfMysql = new QueryFactory("MYSQL", jdbc);
	QueryTest qtMysql = qfMysql.from(QueryTest.class);
	Assert.assertEquals("SELECT * FROM LA_BOARD_COLUMN_FULL_MYSQL WHERE BOARD_COLUMN_ID = :columnId", qtMysql.overrideQuery());
}
 
开发者ID:digitalfondue,项目名称:npjt-extra,代码行数:11,代码来源:QueryFactoryTest.java

示例5: dateQueriesTest

import ch.digitalfondue.npjt.QueryFactory; //导入方法依赖的package包/类
@Test
public void dateQueriesTest() {
	QueryFactory qf = new QueryFactory("hsqldb", new JdbcTemplate(dataSource));
	
	qf.addColumnMapperFactory(new ZonedDateTimeMapper.Factory());
	qf.addParameterConverters(new ZonedDateTimeMapper.Converter());
	
	qf.addColumnMapperFactory(new LocalDateMapper.Factory());
	qf.addParameterConverters(new LocalDateMapper.Converter());
	
	qf.addColumnMapperFactory(new LocalDateTimeMapper.Factory());
	qf.addParameterConverters(new LocalDateTimeMapper.Converter());
	
	qf.addColumnMapperFactory(new InstantMapper.Factory());
	qf.addParameterConverters(new InstantMapper.Converter());
	
	DateQueries dq = qf.from(DateQueries.class);
	
	dq.createTable();
	
	ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC"));
	
	dq.insertValue("KEY", now);
	check(dq, "KEY", now);
	
	dq.insertValue("KEY2", now.toLocalDate());
	check(dq, "KEY2", now.toLocalDate());
	
	dq.insertValue("KEY3", now.toLocalDateTime());
	check(dq, "KEY3", now);
	
	Instant iNow = Instant.now();
	dq.insertValue("KEY4", iNow);
	Assert.assertEquals(iNow, dq.findInstantByKey("KEY4"));
	Assert.assertEquals(iNow, dq.findConfInstantByKey("KEY4").value);
	
}
 
开发者ID:digitalfondue,项目名称:npjt-extra,代码行数:38,代码来源:DateTimeQueriesTest.java

示例6: simpleQueriesTest

import ch.digitalfondue.npjt.QueryFactory; //导入方法依赖的package包/类
@Test
public void simpleQueriesTest() {
	QueryFactory qf = new QueryFactory("hsqldb", new JdbcTemplate(dataSource));

	BoolQueries bq = qf.from(BoolQueries.class);

	bq.createTable();

	bq.insertValue("KEY", true, true, true);
	
	BoolConf bc = bq.findByKey("KEY");
	
	Assert.assertTrue(bc.confBool);
	Assert.assertTrue(bc.confStr);
	Assert.assertTrue(bc.confInt);
	
	bq.insertValue("KEY2", false, true, false);
	BoolConf bc2 = bq.findByKey("KEY2");
	
	Assert.assertFalse(bc2.confBool);
	Assert.assertTrue(bc2.confStr);
	Assert.assertFalse(bc2.confInt);
	
	Assert.assertTrue(bq.findConfBoolByKey("KEY"));
	Assert.assertFalse(bq.findConfBoolByKey("KEY2"));
	
}
 
开发者ID:digitalfondue,项目名称:npjt-extra,代码行数:28,代码来源:BooleanQueriesTest.java

示例7: simpleQueriesTest

import ch.digitalfondue.npjt.QueryFactory; //导入方法依赖的package包/类
/**
 * Simple DB interaction.
 */
@Test
public void simpleQueriesTest() {
	QueryFactory qf = new QueryFactory("hsqldb", dataSource);

	MySimpleQueries mq = qf.from(MySimpleQueries.class);

	mq.createTable();

	Assert.assertTrue(mq.findAll().isEmpty());
	Assert.assertEquals(1, mq.insertValue("MY_KEY", "MY_VALUE"));

	Conf conf = mq.findByKey("MY_KEY");

	Assert.assertEquals("MY_KEY", conf.key);
	Assert.assertEquals("MY_VALUE", conf.value);

	Assert.assertFalse(mq.findAll().isEmpty());

	Assert.assertEquals(1, mq.update("MY_KEY", "MY_VALUE_UPDATED"));

	Conf confUpd = mq.findByKey("MY_KEY");
	Assert.assertEquals("MY_KEY", confUpd.key);
	Assert.assertEquals("MY_VALUE_UPDATED", confUpd.value);
	
	Assert.assertTrue(mq.findAllKeys().contains("MY_KEY"));
	
	Assert.assertEquals("MY_VALUE_UPDATED", mq.findValueForKey("MY_KEY"));
	
	Assert.assertEquals("MY_TEMPLATE", mq.template());
	
	//Assert.assertEquals("defaultMethod", mq.defaultMethod());
	
	Assert.assertNotNull(mq.getNamedParameterJdbcTemplate());
	
	Assert.assertEquals("MY_VALUE_UPDATED", mq.findOptionalValueForKey("MY_KEY").get());
	
	Assert.assertFalse(mq.findOptionalValueForKey("MY_KEY_NOT").isPresent());
	
	Assert.assertEquals("MY_VALUE_UPDATED", mq.findOptionalWrappedValueForKey("MY_KEY").get().value);
	
	Assert.assertFalse(mq.findOptionalWrappedValueForKey("MY_KEY_NOT").isPresent());

	Assert.assertEquals("defaultMethod", mq.defaultMethod());
}
 
开发者ID:digitalfondue,项目名称:npjt-extra,代码行数:48,代码来源:SimpleQueriesTest.java


注:本文中的ch.digitalfondue.npjt.QueryFactory.from方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。