本文整理汇总了Java中org.openyu.commons.lang.ClassHelper.isVoClass方法的典型用法代码示例。如果您正苦于以下问题:Java ClassHelper.isVoClass方法的具体用法?Java ClassHelper.isVoClass怎么用?Java ClassHelper.isVoClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openyu.commons.lang.ClassHelper
的用法示例。
在下文中一共展示了ClassHelper.isVoClass方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: delete
import org.openyu.commons.lang.ClassHelper; //导入方法依赖的package包/类
@CommonTx
@SuppressWarnings("unchecked")
public <T> T delete(Class<?> entityClass, Serializable seq, String modifiedUser) {
T result = null;
// 此時為po
Object entity = findReturnVoOrNot(entityClass, seq, false);
int del = delete(entity, modifiedUser);
if (del > 0) {
boolean isVoClass = ClassHelper.isVoClass(entityClass);
if (isVoClass) {
result = ClassHelper.copyProperties(entity, entityClass);// po->vo
} else {
result = (T) entity;
}
}
return result;
}
示例2: rowCount
import org.openyu.commons.lang.ClassHelper; //导入方法依赖的package包/类
public long rowCount(Class<?> entityClass) {
long result = 0L;
try {
boolean isVoClass = ClassHelper.isVoClass(entityClass);
if (isVoClass) {
Class<?> poClass = ClassHelper.vo2PoClass(entityClass);
if (poClass != null) {
result = commonDao.rowCount(poClass);
}
} else {
result = commonDao.rowCount(entityClass);
}
} catch (Exception ex) {
throw new CommonServiceException(ex);
}
return result;
}
示例3: insert
import org.openyu.commons.lang.ClassHelper; //导入方法依赖的package包/类
@CommonTx
@SuppressWarnings("unchecked")
public <T> Serializable insert(T entity, String modifiedUser) {
Serializable result = null;
try {
if (entity != null) {
Class<?> entityClass = entity.getClass();
Object poEntity = null;// po
Object voEntity = null;// vo
boolean isVoClass = ClassHelper.isVoClass(entityClass);
// #1 entityClass=voClass, 傳入 vo class
if (isVoClass) {
// po
poEntity = ClassHelper.copyProperties(entity);
// vo
voEntity = entity;
}
// #2 entityClass=poClass,傳入 po class
else {
// po
poEntity = entity;
// vo
voEntity = ClassHelper.copyProperties(entity);
}
//
if (poEntity != null) {
// 觸發事件傳入vo/po,voEntity!=null,則vo,voEntity==null,則po
EventAttach<T, T> eventAttach = EventHelper.eventAttach(null,
(voEntity != null ? (T) voEntity : (T) poEntity));
fireBeanInserting(this, eventAttach);
result = commonDao.insert(poEntity, modifiedUser);
// System.out.println("poEntity: "+poEntity);
if (result != null) {
// 因insert到db,有些欄位是寫入db時才會有值
// 所以將po再塞回到vo
// #issue,當集合時,會重複添加,原本+新的
if (isVoClass) {
// System.out.println("poEntity: " + poEntity);
voEntity = ClassHelper.copyProperties(poEntity, voEntity);
// System.out.println("entity: " + entity);
}
eventAttach = EventHelper.eventAttach(null, (voEntity != null ? (T) voEntity : (T) poEntity));
fireBeanInserted(this, eventAttach);
}
}
}
} catch (Exception ex) {
throw new CommonServiceException(ex);
}
return result;
}
示例4: update
import org.openyu.commons.lang.ClassHelper; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@CommonTx
public <T> int update(T entity, String modifiedUser) {
int ret = 0;
try {
if (entity != null) {
Class<?> entityClass = entity.getClass();
Object poEntity = null;// po
Object voEntity = null;// vo
boolean isVoClass = ClassHelper.isVoClass(entityClass);
// #1 entityClass=voClass, 傳入 vo class
if (isVoClass) {
// po
poEntity = ClassHelper.copyProperties(entity);
// vo
voEntity = entity;
}
// #2 entityClass=poClass,傳入 po class
else {
// po
poEntity = entity;
// vo
voEntity = ClassHelper.copyProperties(entity);
}
//
if (poEntity != null) {
// 觸發事件傳入vo/po,voEntity!=null,則vo,voEntity==null,則po
EventAttach<T, T> eventAttach = EventHelper.eventAttach(null,
(voEntity != null ? (T) voEntity : (T) poEntity));
fireBeanUpdating(this, eventAttach);
// System.out.println("before version: "
// + ((SeqEntity) poEntity).getVersion());
ret = commonDao.update(poEntity, modifiedUser);
// System.out.println("after version: "
// + ((SeqEntity) poEntity).getVersion());
if (ret > 0) {
// 因update到db,有些欄位是寫入db時才會有值
// 所以將po再塞回到vo
if (isVoClass) {
// #issue version沒+1,怪了
// 原因還沒commit所以version沒+1,不是這個原因
//
// #fix 手動version+1
// 2014/09/30
if (poEntity instanceof SeqEntity) {
SeqEntity idEntity = (SeqEntity) poEntity;
idEntity.setVersion(idEntity.getVersion() + 1);
}
// #fix version已有加1,不要再加了
// 2014/09/30又沒加1,所以又改成手動+1
voEntity = ClassHelper.copyProperties(poEntity, voEntity);
// System.out.println("copy version: "
// + ((SeqBean) voEntity).getVersion());
}
eventAttach = EventHelper.eventAttach(null, (voEntity != null ? (T) voEntity : (T) poEntity));
fireBeanUpdated(this, eventAttach);
}
}
}
} catch (Exception ex) {
throw new CommonServiceException(ex);
}
return ret;
}