本文整理汇总了Java中org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer类的典型用法代码示例。如果您正苦于以下问题:Java DataFieldMaxValueIncrementer类的具体用法?Java DataFieldMaxValueIncrementer怎么用?Java DataFieldMaxValueIncrementer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataFieldMaxValueIncrementer类属于org.springframework.jdbc.support.incrementer包,在下文中一共展示了DataFieldMaxValueIncrementer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testGetIncrementer_nextValues
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
/**
* Tests that the incrementer returned from the factory returns the proper next int, long, and String values.
*/
@Test
public void testGetIncrementer_nextValues() {
DataFieldMaxValueIncrementer incrementer = (DataFieldMaxValueIncrementer) context.getBean(TEST_INCREMENTER);
assertNotNull(incrementer);
// now that we have our incrementer, let's get the next value
int nextIntValue = incrementer.nextIntValue();
assertTrue("nextIntValue should be greater than 0", nextIntValue > 0);
// do it again, should be 1 larger!
int nextNextIntValue = incrementer.nextIntValue();
assertEquals("Next value should be one higher", nextIntValue + 1, nextNextIntValue);
// try getting the next value as a long
long nextLongValue = incrementer.nextLongValue();
assertEquals(nextNextIntValue + 1, nextLongValue);
// try getting it as a String now
String nextStringValue = incrementer.nextStringValue();
assertEquals(nextLongValue + 1, Long.parseLong(nextStringValue));
}
开发者ID:kuali,项目名称:kc-rice,代码行数:25,代码来源:MaxValueIncrementerFactoryBeanIntegrationTest.java
示例2: testGetIncrementer_nextValues
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
/**
* Tests that the incrementer returned from the factory returns the proper next int, long, and String values.
*/
@Test
public void testGetIncrementer_nextValues() {
DataSource dataSource = TestHarnessServiceLocator.getDataSource();
DataFieldMaxValueIncrementer incrementer =
MaxValueIncrementerFactory.getIncrementer(dataSource, ARBITRARY_SEQUENCE);
assertNotNull(incrementer);
// now that we have our incrementer, let's get the next value
int nextIntValue = incrementer.nextIntValue();
assertTrue("nextIntValue should be greater than 0", nextIntValue > 0);
// do it again, should be 1 larger!
int nextNextIntValue = incrementer.nextIntValue();
assertEquals("Next value should be one higher", nextIntValue + 1, nextNextIntValue);
// try getting the next value as a long
long nextLongValue = incrementer.nextLongValue();
assertEquals(nextNextIntValue + 1, nextLongValue);
// try getting it as a String now
String nextStringValue = incrementer.nextStringValue();
assertEquals(nextLongValue + 1, Long.parseLong(nextStringValue));
}
开发者ID:kuali,项目名称:kc-rice,代码行数:27,代码来源:MaxValueIncrementerFactoryIntegrationTest.java
示例3: testCustomIncrementerDatasourceVersion
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
@Test
public void testCustomIncrementerDatasourceVersion() throws Exception {
SimpleConfig config = new SimpleConfig();
config.putProperty("rice.krad.data.platform.incrementer.mysql.5",
"org.kuali.rice.krad.data.platform.testincrementers.CustomIncrementerMySQLVersion5");
config.putProperty("rice.krad.data.platform.incrementer.oracle.11",
"org.kuali.rice.krad.data.platform.testincrementers.CustomIncrementerOracleVersion11");
ConfigContext.init(config);
DataFieldMaxValueIncrementer mySQLMaxVal = MaxValueIncrementerFactory.getIncrementer(mysql,"test_mySQL");
assertTrue("Found MySQL custom incrementer",mySQLMaxVal != null);
assertTrue("Custom incrementer for MySQL should be mySQL5 for String val",
StringUtils.equals(mySQLMaxVal.nextStringValue(),"mySQL5"));
DataFieldMaxValueIncrementer oracleMaxVal = MaxValueIncrementerFactory.getIncrementer(oracle,"test_oracle");
assertTrue("Found Oracle custom incrementer", oracleMaxVal != null);
}
开发者ID:kuali,项目名称:kc-rice,代码行数:18,代码来源:MaxValueIncrementerFactoryTest.java
示例4: testCustomIncrementerDatasourceNoVersion
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
@Test
public void testCustomIncrementerDatasourceNoVersion() throws Exception {
SimpleConfig config = new SimpleConfig();
config.putProperty("rice.krad.data.platform.incrementer.mysql",
"org.kuali.rice.krad.data.platform.testincrementers.CustomIncrementerMySQLVersion5");
config.putProperty("rice.krad.data.platform.incrementer.oracle",
"org.kuali.rice.krad.data.platform.testincrementers.CustomIncrementerOracleVersion11");
ConfigContext.init(config);
DataFieldMaxValueIncrementer mySQLMaxVal = MaxValueIncrementerFactory.getIncrementer(mysql,"test_mySQL");
assertTrue("Found MySQL custom incrementer",mySQLMaxVal != null);
assertTrue("Custom incrementer for MySQL should be mySQL5 for String val",
StringUtils.equals(mySQLMaxVal.nextStringValue(),"mySQL5"));
DataFieldMaxValueIncrementer oracleMaxVal = MaxValueIncrementerFactory.getIncrementer(oracle,"test_oracle");
assertTrue("Found Oracle custom incrementer", oracleMaxVal != null);
}
开发者ID:kuali,项目名称:kc-rice,代码行数:18,代码来源:MaxValueIncrementerFactoryTest.java
示例5: testGetIncrementer_CaseInsensitive
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
/**
* Tests that the sequence name is case insensitive. We will do this by using the same sequence name as the
* previous test, but changing the case to all lowercase.
*/
@Test
public void testGetIncrementer_CaseInsensitive() {
DataFieldMaxValueIncrementer incrementer = (DataFieldMaxValueIncrementer) context.getBean(TEST_INCREMENTER);
assertNotNull(incrementer);
// now that we have our incrementer, let's get the next value
int nextIntValue = incrementer.nextIntValue();
assertTrue("nextIntValue should be greater than 0", nextIntValue > 0);
}
开发者ID:kuali,项目名称:kc-rice,代码行数:14,代码来源:MaxValueIncrementerFactoryBeanIntegrationTest.java
示例6: testGetIncrementer_BadSequence
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
/**
* Tests that if you try to use the factory with an invalid sequence name, it will throw a DataAccessException.
*/
@Test(expected = DataAccessException.class)
public void testGetIncrementer_BadSequence() {
DataFieldMaxValueIncrementer incrementer = (DataFieldMaxValueIncrementer) context.getBean(INVALID_TEST_INCREMENTER);
// the incrementer *may* still be retrieved successfully (depending on the database this integration test is run against)
assertNotNull(incrementer);
// but at the very least it should throw an exception when executed
incrementer.nextLongValue();
}
开发者ID:kuali,项目名称:kc-rice,代码行数:14,代码来源:MaxValueIncrementerFactoryBeanIntegrationTest.java
示例7: testGetIncrementer_CaseInsensitive
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
/**
* Tests that the sequence name is case insensitive. We will do this by using the same sequence name as the
* previous test, but changing the case to all lowercase.
*/
@Test
public void testGetIncrementer_CaseInsensitive() {
DataSource dataSource = TestHarnessServiceLocator.getDataSource();
DataFieldMaxValueIncrementer incrementer =
MaxValueIncrementerFactory.getIncrementer(dataSource, ARBITRARY_SEQUENCE.toLowerCase());
assertNotNull(incrementer);
// now that we have our incrementer, let's get the next value
int nextIntValue = incrementer.nextIntValue();
assertTrue("nextIntValue should be greater than 0", nextIntValue > 0);
}
开发者ID:kuali,项目名称:kc-rice,代码行数:16,代码来源:MaxValueIncrementerFactoryIntegrationTest.java
示例8: testGetIncrementer_BadSequence
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
/**
* Tests that if you try to use the factory with an invalid sequence name, it will throw a DataAccessException.
*/
@Test(expected = DataAccessException.class)
public void testGetIncrementer_BadSequence() {
DataSource dataSource = TestHarnessServiceLocator.getDataSource();
DataFieldMaxValueIncrementer incrementer =
MaxValueIncrementerFactory.getIncrementer(dataSource, "OH_NO_YOU_DIDNT!");
// the incrementer *may* still be retrieved successfully (depending on the database this integration test is run against)
assertNotNull(incrementer);
// but at the very least it should throw an exception when executed
incrementer.nextLongValue();
}
开发者ID:kuali,项目名称:kc-rice,代码行数:16,代码来源:MaxValueIncrementerFactoryIntegrationTest.java
示例9: getIncrementer
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
/**
* Either constructs a new incrementer or retrieves a cached instance for the given DataSource and target
* incrementer name.
*
* @param dataSource the {@link DataSource} for which to retrieve the incrementer.
* @param incrementerName the case-insensitive name of the incrementer to use, this will generally be the name of
* the database object which is used to implement the incrementer.
* @return an incrementer that can be used to generate the next incremented value for the given incrementer against
* the specified {@link DataSource}.
*
* @throws IllegalArgumentException if dataSource or incrementerName are null or blank.
*/
public static DataFieldMaxValueIncrementer getIncrementer(DataSource dataSource, String incrementerName) {
if (dataSource == null) {
throw new IllegalArgumentException("DataSource must not be null");
}
if (StringUtils.isBlank(incrementerName)) {
throw new IllegalArgumentException("Incrementer name must not be null or blank");
}
// yes, we want to check if it's there first, then put if absent, for max speed! This is like ConcurrentMap's
// version of double-checked locking.
ConcurrentMap<String, DataFieldMaxValueIncrementer> incrementerCache = cache.get(dataSource);
if (incrementerCache == null) {
cache.put(dataSource,
new ConcurrentHashMap<String, DataFieldMaxValueIncrementer>(8, 0.9f, 1));
if (incrementerCache == null) {
incrementerCache = cache.get(dataSource);
}
}
// now check if we have a cached incrementer
DataFieldMaxValueIncrementer incrementer = incrementerCache.get(incrementerName.toUpperCase());
if (incrementer == null) {
incrementer = incrementerCache.putIfAbsent(incrementerName.toUpperCase(), createIncrementer(dataSource,
incrementerName));
if (incrementer == null) {
incrementer = incrementerCache.get(incrementerName.toUpperCase());
}
}
return incrementer;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:45,代码来源:MaxValueIncrementerFactory.java
示例10: getGeneratedValue
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Object getGeneratedValue(Accessor accessor, AbstractSession writeSession, String seqName) {
DataSource dataSource = ((JNDIConnector) writeSession.getLogin().getConnector()).getDataSource();
DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(dataSource,
sequenceName);
return Long.valueOf(incrementer.nextLongValue());
}
开发者ID:kuali,项目名称:kc-rice,代码行数:11,代码来源:KradEclipseLinkCustomizer.java
示例11: testGetIncrementer_Oracle
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
@Test
public void testGetIncrementer_Oracle() throws Exception {
DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(oracle, "MY_SEQUENCE");
assertTrue(incrementer instanceof OracleSequenceMaxValueIncrementer);
OracleSequenceMaxValueIncrementer oracleIncrementer = (OracleSequenceMaxValueIncrementer)incrementer;
assertEquals("MY_SEQUENCE", oracleIncrementer.getIncrementerName());
// ensure that it's caching the incrementer
assertSame(incrementer, MaxValueIncrementerFactory.getIncrementer(oracle, "MY_SEQUENCE"));
// ensure that different sequence gives a different incrementer
assertNotSame(incrementer, MaxValueIncrementerFactory.getIncrementer(oracle, "MY_SEQUENCE_2"));
}
开发者ID:kuali,项目名称:kc-rice,代码行数:14,代码来源:MaxValueIncrementerFactoryTest.java
示例12: testGetIncrementer_MySQL
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
@Test
public void testGetIncrementer_MySQL() throws Exception {
DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(mysql, "MY_SEQUENCE");
assertTrue(incrementer instanceof MaxValueIncrementerFactory.EnhancedMySQLMaxValueIncrementer);
MaxValueIncrementerFactory.EnhancedMySQLMaxValueIncrementer mysqlIncrementer =
(MaxValueIncrementerFactory.EnhancedMySQLMaxValueIncrementer)incrementer;
assertEquals("MY_SEQUENCE", mysqlIncrementer.getIncrementerName());
assertEquals("ID", mysqlIncrementer.getColumnName());
// ensure that it's caching the incrementer
assertSame(incrementer, MaxValueIncrementerFactory.getIncrementer(mysql, "MY_SEQUENCE"));
// ensure that different sequence gives a different incrementer
assertNotSame(incrementer, MaxValueIncrementerFactory.getIncrementer(mysql, "MY_SEQUENCE_2"));
}
开发者ID:kuali,项目名称:kc-rice,代码行数:16,代码来源:MaxValueIncrementerFactoryTest.java
示例13: testGetIncrementer_CaseInsensitive
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
@Test
public void testGetIncrementer_CaseInsensitive() throws Exception {
DataFieldMaxValueIncrementer incrementer1 = MaxValueIncrementerFactory.getIncrementer(mysql, "MY_SEQUENCE");
DataFieldMaxValueIncrementer incrementer2 = MaxValueIncrementerFactory.getIncrementer(mysql, "MY_sequence");
DataFieldMaxValueIncrementer incrementer3 = MaxValueIncrementerFactory.getIncrementer(mysql, "my_sequence");
assertSame(incrementer1, incrementer2);
assertSame(incrementer2, incrementer3);
}
开发者ID:kuali,项目名称:kc-rice,代码行数:9,代码来源:MaxValueIncrementerFactoryTest.java
示例14: testCustomIncrementerDatasourceInvalidClass
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
@Test(expected = InstantiationError.class)
public void testCustomIncrementerDatasourceInvalidClass() throws Exception {
SimpleConfig config = new SimpleConfig();
config.putProperty("rice.krad.data.platform.incrementer.mysql",
"org.kuali.rice.krad.data.platform.testincrementers.NonExistent");
ConfigContext.init(config);
DataFieldMaxValueIncrementer mySQLMaxVal = MaxValueIncrementerFactory.getIncrementer(mysql,"test_mySQL");
assertTrue("Cannot create incrementer", mySQLMaxVal == null);
}
开发者ID:kuali,项目名称:kc-rice,代码行数:11,代码来源:MaxValueIncrementerFactoryTest.java
示例15: initializeResponsibilityId
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
private void initializeResponsibilityId(Object dataObject) {
if (dataObject instanceof ReviewResponsibilityBo) {
ReviewResponsibilityBo responsibilityBo = (ReviewResponsibilityBo) dataObject;
if (StringUtils.isBlank(responsibilityBo.getId())) {
DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(
KimImplServiceLocator.getDataSource(), KimConstants.SequenceNames.KRIM_RSP_ID_S);
responsibilityBo.setId(incrementer.nextStringValue());
}
}
}
开发者ID:kuali,项目名称:kc-rice,代码行数:12,代码来源:ReviewResponsibilityMaintainable.java
示例16: initializeDocumentForNewRole
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
public void initializeDocumentForNewRole() {
if (StringUtils.isBlank(this.roleId)) {
DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(KimImplServiceLocator.getDataSource(), KimConstants.SequenceNames.KRIM_ROLE_ID_S);
this.roleId = incrementer.nextStringValue();
}
if (StringUtils.isBlank(this.roleTypeId)) {
this.roleTypeId = "1";
}
}
开发者ID:kuali,项目名称:kc-rice,代码行数:10,代码来源:IdentityManagementRoleDocument.java
示例17: initializeDocumentForNewGroup
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
public void initializeDocumentForNewGroup() {
if (StringUtils.isBlank(this.groupId)) {
DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(KimImplServiceLocator.getDataSource(), KimConstants.SequenceNames.KRIM_GROUP_ID_S);
this.groupId = incrementer.nextStringValue();
}
if (StringUtils.isBlank(this.groupTypeId)) {
this.groupTypeId = "1";
}
}
开发者ID:kuali,项目名称:kc-rice,代码行数:10,代码来源:IdentityManagementGroupDocument.java
示例18: initializePermissionId
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
private void initializePermissionId(Object dataObject) {
if (dataObject instanceof GenericPermissionBo) {
GenericPermissionBo permissionBo = (GenericPermissionBo) dataObject;
if (StringUtils.isBlank(permissionBo.getId())) {
DataFieldMaxValueIncrementer incrementer = MaxValueIncrementerFactory.getIncrementer(
KimImplServiceLocator.getDataSource(), KimConstants.SequenceNames.KRIM_PERM_ID_S);
permissionBo.setId(incrementer.nextStringValue());
}
}
}
开发者ID:kuali,项目名称:kc-rice,代码行数:12,代码来源:GenericPermissionMaintainable.java
示例19: getRuleSequenceIncrementer
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
private DataFieldMaxValueIncrementer getRuleSequenceIncrementer() {
if (ruleSequenceIncrementer == null) {
ruleSequenceIncrementer = MaxValueIncrementerFactory.getIncrementer(dataSource, RULE_SEQ_NAME);
}
return ruleSequenceIncrementer;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:8,代码来源:RuleManagementServiceImpl.java
示例20: getReferenceObjectBindingSequenceIncrementer
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入依赖的package包/类
private DataFieldMaxValueIncrementer getReferenceObjectBindingSequenceIncrementer() {
if (referenceObjectBindingSequenceIncrementer == null) {
referenceObjectBindingSequenceIncrementer = MaxValueIncrementerFactory.getIncrementer(dataSource, REF_OBJ_SEQ_NAME);
}
return referenceObjectBindingSequenceIncrementer;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:8,代码来源:RuleManagementServiceImpl.java
注:本文中的org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论