本文整理汇总了Java中com.j256.ormlite.dao.Dao.CreateOrUpdateStatus类的典型用法代码示例。如果您正苦于以下问题:Java CreateOrUpdateStatus类的具体用法?Java CreateOrUpdateStatus怎么用?Java CreateOrUpdateStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CreateOrUpdateStatus类属于com.j256.ormlite.dao.Dao包,在下文中一共展示了CreateOrUpdateStatus类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: insertOrUpdate
import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus; //导入依赖的package包/类
private static <E extends Entity> boolean insertOrUpdate(final Dao<E, ?> dao, final E entity, final Date now) throws SQLException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("insertOrUpdate: " + ReflectionToStringBuilder.toString(dao) + ", " + entity);
}
final Date createdAt = entity.getCreatedAt();
entity.setCreatedAt(createdAt != null ? createdAt : now);
final Date updatedAt = entity.getUpdatedAt();
entity.setUpdatedAt(updatedAt != null ? updatedAt : now);
final CreateOrUpdateStatus status = dao.createOrUpdate(entity);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("insertOrUpdate: " + ReflectionToStringBuilder.toString(status) + ", " + entity);
}
final boolean created = (status != null) && status.isCreated();
final boolean updated = (status != null) && status.isUpdated();
entity.setCreatedAt(created ? now : createdAt);
entity.setUpdatedAt(updated ? now : updatedAt);
final boolean result = (updated && ((updatedAt == null) || now.equals(updatedAt))) || (dao.update(entity) == 1);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("insertOrUpdate: " + result + ", " + entity);
}
return result;
}
开发者ID:t3t5u,项目名称:common-ormlite,代码行数:23,代码来源:AbstractDao.java
示例2: addOrUpdateRace
import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus; //导入依赖的package包/类
public boolean addOrUpdateRace(Race race) {
try {
CreateOrUpdateStatus status = mHelper.getRaceDao().createOrUpdate(race);
for (Rule rule : race.getRules()) {
rule.setRace(race);
// Rules could have been added or removed, so remove persisted
// rules and add current rules
if (status.isUpdated()) {
DeleteBuilder<Rule, Long> deleteBuilder = mHelper.getRuleDao().deleteBuilder();
deleteBuilder.where().eq("ruleId", rule.getRuleId()).and().eq("race_id", race.getRaceId());
deleteBuilder.delete();
}
mHelper.getRuleDao().createOrUpdate(rule);
}
return true;
} catch (SQLException e) {
Log.e(TAG, "Failed to cache a race", e);
return false;
}
}
开发者ID:jrobinson3k1,项目名称:Path-of-Exile-Racer,代码行数:25,代码来源:DatabaseManager.java
示例3: testCreateOrUpdate
import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus; //导入依赖的package包/类
@Test
public void testCreateOrUpdate() throws Exception {
Dao<NotQuiteFoo, Integer> dao = createDao(NotQuiteFoo.class, true);
NotQuiteFoo foo1 = new NotQuiteFoo();
foo1.stuff = "wow";
CreateOrUpdateStatus status = dao.createOrUpdate(foo1);
assertTrue(status.isCreated());
assertFalse(status.isUpdated());
assertEquals(1, status.getNumLinesChanged());
String stuff2 = "4134132";
foo1.stuff = stuff2;
status = dao.createOrUpdate(foo1);
assertFalse(status.isCreated());
assertTrue(status.isUpdated());
assertEquals(1, status.getNumLinesChanged());
NotQuiteFoo result = dao.queryForId(foo1.id);
assertEquals(stuff2, result.stuff);
}
开发者ID:j256,项目名称:ormlite-jdbc,代码行数:21,代码来源:JdbcBaseDaoImplTest.java
示例4: testCreateOrUpdateNullId
import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus; //导入依赖的package包/类
@Test
public void testCreateOrUpdateNullId() throws Exception {
Dao<CreateOrUpdateObjectId, Integer> dao = createDao(CreateOrUpdateObjectId.class, true);
CreateOrUpdateObjectId foo = new CreateOrUpdateObjectId();
String stuff = "21313";
foo.stuff = stuff;
CreateOrUpdateStatus status = dao.createOrUpdate(foo);
assertTrue(status.isCreated());
assertFalse(status.isUpdated());
assertEquals(1, status.getNumLinesChanged());
CreateOrUpdateObjectId result = dao.queryForId(foo.id);
assertNotNull(result);
assertEquals(stuff, result.stuff);
String stuff2 = "pwojgfwe";
foo.stuff = stuff2;
dao.createOrUpdate(foo);
result = dao.queryForId(foo.id);
assertNotNull(result);
assertEquals(stuff2, result.stuff);
}
开发者ID:j256,项目名称:ormlite-jdbc,代码行数:24,代码来源:JdbcBaseDaoImplTest.java
示例5: testCreateOrUpdate
import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus; //导入依赖的package包/类
public void testCreateOrUpdate() throws Exception {
Dao<NotQuiteFoo, Integer> dao = createDao(NotQuiteFoo.class, true);
NotQuiteFoo foo1 = new NotQuiteFoo();
foo1.stuff = "wow";
CreateOrUpdateStatus status = dao.createOrUpdate(foo1);
assertTrue(status.isCreated());
assertFalse(status.isUpdated());
assertEquals(1, status.getNumLinesChanged());
String stuff2 = "4134132";
foo1.stuff = stuff2;
status = dao.createOrUpdate(foo1);
assertFalse(status.isCreated());
assertTrue(status.isUpdated());
assertEquals(1, status.getNumLinesChanged());
NotQuiteFoo result = dao.queryForId(foo1.id);
assertEquals(stuff2, result.stuff);
}
开发者ID:j256,项目名称:ormlite-android-tests,代码行数:20,代码来源:AndroidJdbcBaseDaoImplTest.java
示例6: testCreateOrUpdateNullId
import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus; //导入依赖的package包/类
public void testCreateOrUpdateNullId() throws Exception {
Dao<CreateOrUpdateObjectId, Integer> dao = createDao(CreateOrUpdateObjectId.class, true);
CreateOrUpdateObjectId foo = new CreateOrUpdateObjectId();
String stuff = "21313";
foo.stuff = stuff;
CreateOrUpdateStatus status = dao.createOrUpdate(foo);
assertTrue(status.isCreated());
assertFalse(status.isUpdated());
assertEquals(1, status.getNumLinesChanged());
CreateOrUpdateObjectId result = dao.queryForId(foo.id);
assertNotNull(result);
assertEquals(stuff, result.stuff);
String stuff2 = "pwojgfwe";
foo.stuff = stuff2;
dao.createOrUpdate(foo);
result = dao.queryForId(foo.id);
assertNotNull(result);
assertEquals(stuff2, result.stuff);
}
开发者ID:j256,项目名称:ormlite-android-tests,代码行数:23,代码来源:AndroidJdbcBaseDaoImplTest.java
示例7: testCreateOrUpdate
import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus; //导入依赖的package包/类
@Test
public void testCreateOrUpdate() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
Foo foo1 = new Foo();
int equal1 = 21313;
foo1.equal = equal1;
CreateOrUpdateStatus status = dao.createOrUpdate(foo1);
assertTrue(status.isCreated());
assertFalse(status.isUpdated());
assertEquals(1, status.getNumLinesChanged());
int equal2 = 4134132;
foo1.equal = equal2;
status = dao.createOrUpdate(foo1);
assertFalse(status.isCreated());
assertTrue(status.isUpdated());
assertEquals(1, status.getNumLinesChanged());
Foo fooResult = dao.queryForId(foo1.id);
assertEquals(equal2, fooResult.equal);
}
开发者ID:j256,项目名称:ormlite-core,代码行数:22,代码来源:BaseDaoImplTest.java
示例8: createOrUpdateItem
import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus; //导入依赖的package包/类
public static int createOrUpdateItem(Item item) {
RuntimeExceptionDao<Item, UUID> itemDao = DsaTabApplication.getInstance().getDBHelper().getItemDao();
CreateOrUpdateStatus status = itemDao.createOrUpdate(item);
int result = status.getNumLinesChanged();
for (ItemSpecification itemSpec : item.getSpecifications()) {
RuntimeExceptionDao itemSpecDao = DsaTabApplication.getInstance().getDBHelper()
.getRuntimeDao(itemSpec.getClass());
itemSpecDao.createOrUpdate(itemSpec);
}
DsaTabApplication.getInstance().getContentResolver().notifyChange(ITEMS_URI,null);
return result;
}
开发者ID:gandulf,项目名称:DsaTab,代码行数:17,代码来源:DataManager.java
示例9: confirmAddMobile
import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus; //导入依赖的package包/类
private void confirmAddMobile() {
if (TextUtils.isEmpty(mPhoneNumInput.getEditableText().toString())) {
Toast.makeText(getActivity(), "电话号码不能为空", Toast.LENGTH_SHORT).show();
} else {
String mobile = mPhoneNumInput.getEditableText().toString();
BlackList entity = new BlackList();
entity.setCreateTime(System.currentTimeMillis());
entity.setIsReplay(mMessageReplayChecked == true ? 1 : 0);
entity.setMarkMessage(mMessageChecked == true ? 1 : 0);
entity.setMarkPhone(mPhoneChecked == true ? 1 : 0);
entity.setMobile(mobile);
entity.setPhoneName(mNote.getEditableText().toString());
entity.setReplayMessage(mMessageRelayInput.getEditableText().toString());
RuntimeExceptionDao<BlackList, Integer> dao = getDBHelper().getBlackListDao();
try {
BlackList blackList = dao.queryBuilder().where().eq(BlackList.MOBILE, mobile)
.queryForFirst();
if (blackList != null) {
entity.setId(blackList.getId());
}
CreateOrUpdateStatus status = getDBHelper().getBlackListDao().createOrUpdate(entity);
if (status.isCreated()) {
Toast.makeText(getActivity(), "添加号码成功", Toast.LENGTH_SHORT).show();
} else if (status.isUpdated()) {
Toast.makeText(getActivity(), "更新号码成功", Toast.LENGTH_SHORT).show();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
开发者ID:facetome,项目名称:Interceptor,代码行数:33,代码来源:EditFragment.java
示例10: onDownloadFileCreated
import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus; //导入依赖的package包/类
@Override
public void onDownloadFileCreated(DownloadFileInfo downloadFileInfo) {
if (downloadFileInfo != null && downloadFileInfo.getUrl() != null && downloadFileInfo.getUrl().equals
(mCourseUrl)) {
// add this CoursePreviewInfo in database download record
//
// the reason why to save this CoursePreviewInfo in course database is
// that when the user enter the CourseDownloadFragment,the fragment need to show the course title to the
// user,however the DownloadFileInfo in FileDownloader can not provide the course title,also the fragment
// need to know how many course items need to show,so it is depends on the size of the course database,
// because FileDownloader is just a tool to download, record and manage all the files which were
// downloaded from the internet
try {
if (mCourseDbHelper == null) {
return;
}
Dao<CoursePreviewInfo, Integer> dao = mCourseDbHelper.getDao(CoursePreviewInfo.class);
CreateOrUpdateStatus status = dao.createOrUpdate(this);
if (status.isCreated() || status.isUpdated()) {
this.mDownloadFileInfo = downloadFileInfo;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
开发者ID:wlfcolin,项目名称:file-downloader,代码行数:30,代码来源:CoursePreviewInfo.java
示例11: onDownloadFileUpdated
import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus; //导入依赖的package包/类
@Override
public void onDownloadFileUpdated(DownloadFileInfo downloadFileInfo, Type type) {
if (downloadFileInfo != null && downloadFileInfo.getUrl() != null && downloadFileInfo.getUrl().equals
(mCourseUrl)) {
if (this.mDownloadFileInfo == null) {
try {
if (mCourseDbHelper == null) {
return;
}
UpdateBuilder builder = mCourseDbHelper.getDao(CoursePreviewInfo.class).updateBuilder();
builder.where().eq(CoursePreviewInfo.COLUMN_NAME_OF_FIELD_COURSE_URL, downloadFileInfo.getUrl());
int result = builder.update();
if (result == 1) {
this.mDownloadFileInfo = downloadFileInfo;
} else {
Dao<CoursePreviewInfo, Integer> dao = mCourseDbHelper.getDao(CoursePreviewInfo.class);
CreateOrUpdateStatus status = dao.createOrUpdate(this);
if (status.isCreated() || status.isUpdated()) {
this.mDownloadFileInfo = downloadFileInfo;
}
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
开发者ID:wlfcolin,项目名称:file-downloader,代码行数:30,代码来源:CoursePreviewInfo.java
示例12: save
import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus; //导入依赖的package包/类
public CreateOrUpdateStatus save( Model model ) {
updateDate( model );
try {
if( model instanceof CategoryModel ) {
return getCategoriesDao().createOrUpdate( (CategoryModel) model );
} else if( model instanceof MaterialModel ) {
return getMaterialsDao().createOrUpdate( (MaterialModel) model );
} else if( model instanceof ImageModel ) {
return getImagesDao().createOrUpdate( (ImageModel) model );
}
} catch( SQLException e ) {
Log.e( TAG, e.getMessage() );
}
return new CreateOrUpdateStatus( false, false, 0 );
}
开发者ID:felixWackernagel,项目名称:Android-Card-Design,代码行数:16,代码来源:DatabaseHelper.java
示例13: testCreateOrUpdateNull
import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus; //导入依赖的package包/类
@Test
public void testCreateOrUpdateNull() throws Exception {
Dao<Foo, String> dao = createDao(Foo.class, true);
CreateOrUpdateStatus status = dao.createOrUpdate(null);
assertFalse(status.isCreated());
assertFalse(status.isUpdated());
assertEquals(0, status.getNumLinesChanged());
}
开发者ID:j256,项目名称:ormlite-jdbc,代码行数:9,代码来源:JdbcBaseDaoImplTest.java
示例14: testVersionFieldInsertOrUpdate
import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus; //导入依赖的package包/类
@Test
public void testVersionFieldInsertOrUpdate() throws Exception {
Dao<VersionField, Integer> dao = createDao(VersionField.class, true);
VersionField foo1 = new VersionField();
assertEquals(1, dao.create(foo1));
assertEquals(1, foo1.id);
assertEquals(0, foo1.version);
CreateOrUpdateStatus status = dao.createOrUpdate(foo1);
assertTrue(status.isUpdated());
assertEquals(1, status.getNumLinesChanged());
assertEquals(1, foo1.version);
status = dao.createOrUpdate(foo1);
assertTrue(status.isUpdated());
assertEquals(1, status.getNumLinesChanged());
assertEquals(2, foo1.version);
VersionField result = dao.queryForId(foo1.id);
// we update this one to a new version number
assertEquals(1, dao.update(result));
assertEquals(3, result.version);
// the old one doesn't change
assertEquals(2, foo1.version);
// but when we try to update the earlier foo, the version doesn't match
assertEquals(0, dao.update(foo1));
}
开发者ID:j256,项目名称:ormlite-jdbc,代码行数:31,代码来源:JdbcBaseDaoImplTest.java
示例15: testCreateOrUpdateNull
import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus; //导入依赖的package包/类
public void testCreateOrUpdateNull() throws Exception {
Dao<Foo, String> dao = createDao(Foo.class, true);
CreateOrUpdateStatus status = dao.createOrUpdate(null);
assertFalse(status.isCreated());
assertFalse(status.isUpdated());
assertEquals(0, status.getNumLinesChanged());
}
开发者ID:j256,项目名称:ormlite-android-tests,代码行数:8,代码来源:AndroidJdbcBaseDaoImplTest.java
示例16: testVersionFieldInsertOrUpdate
import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus; //导入依赖的package包/类
public void testVersionFieldInsertOrUpdate() throws Exception {
Dao<VersionField, Integer> dao = createDao(VersionField.class, true);
VersionField foo1 = new VersionField();
assertEquals(1, dao.create(foo1));
assertEquals(1, foo1.id);
assertEquals(0, foo1.version);
CreateOrUpdateStatus status = dao.createOrUpdate(foo1);
assertTrue(status.isUpdated());
assertEquals(1, status.getNumLinesChanged());
assertEquals(1, foo1.version);
status = dao.createOrUpdate(foo1);
assertTrue(status.isUpdated());
assertEquals(1, status.getNumLinesChanged());
assertEquals(2, foo1.version);
VersionField result = dao.queryForId(foo1.id);
// we update this one to a new version number
assertEquals(1, dao.update(result));
assertEquals(3, result.version);
// the old one doesn't change
assertEquals(2, foo1.version);
// but when we try to update the earlier foo, the version doesn't match
assertEquals(0, dao.update(foo1));
}
开发者ID:j256,项目名称:ormlite-android-tests,代码行数:30,代码来源:AndroidJdbcBaseDaoImplTest.java
示例17: testCreateOrUpdateNull
import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus; //导入依赖的package包/类
@Test
public void testCreateOrUpdateNull() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
CreateOrUpdateStatus status = dao.createOrUpdate(null);
assertFalse(status.isCreated());
assertFalse(status.isUpdated());
assertEquals(0, status.getNumLinesChanged());
}
开发者ID:j256,项目名称:ormlite-core,代码行数:9,代码来源:BaseDaoImplTest.java
注:本文中的com.j256.ormlite.dao.Dao.CreateOrUpdateStatus类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论