本文整理汇总了Java中sample.context.Entity类的典型用法代码示例。如果您正苦于以下问题:Java Entity类的具体用法?Java Entity怎么用?Java Entity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Entity类属于sample.context包,在下文中一共展示了Entity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tx
import sample.context.Entity; //导入依赖的package包/类
/** トランザクション処理を行います。 */
protected <T> T tx(Supplier<T> callable) {
return new TransactionTemplate(txm).execute((status) -> {
T ret = callable.get();
if (ret instanceof Entity) {
ret.hashCode(); // for lazy loading
}
return ret;
});
}
示例2: get
import sample.context.Entity; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public <T extends Entity> Optional<T> get(Class<T> clazz, Serializable id) {
T m = em().find(clazz, id);
if (m != null) m.hashCode(); // force loading
return Optional.ofNullable(m);
}
示例3: load
import sample.context.Entity; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public <T extends Entity> T load(Class<T> clazz, Serializable id) {
try {
T m = em().getReference(clazz, id);
m.hashCode(); // force loading
return m;
} catch (EntityNotFoundException e) {
throw new ValidationException(ErrorKeys.EntityNotFound);
}
}
示例4: loadForUpdate
import sample.context.Entity; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public <T extends Entity> T loadForUpdate(Class<T> clazz, Serializable id) {
T m = em().find(clazz, id, LockModeType.PESSIMISTIC_WRITE);
if (m == null) throw new ValidationException(ErrorKeys.EntityNotFound);
m.hashCode(); // force loading
return m;
}
示例5: save
import sample.context.Entity; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public <T extends Entity> T save(T entity) {
interceptor().ifPresent(i -> i.touchForCreate(entity));
em().persist(entity);
return entity;
}
示例6: criteria
import sample.context.Entity; //导入依赖的package包/类
/** 指定したEntityクラスを軸にしたCriteriaを生成します。 */
public <T extends Entity> OrmCriteria<T> criteria(Class<T> clazz) {
return OrmCriteria.of(em(), clazz);
}
示例7: exists
import sample.context.Entity; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public <T extends Entity> boolean exists(Class<T> clazz, Serializable id) {
return get(clazz, id).isPresent();
}
示例8: findAll
import sample.context.Entity; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public <T extends Entity> List<T> findAll(Class<T> clazz) {
return tmpl().loadAll(clazz);
}
示例9: saveOrUpdate
import sample.context.Entity; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public <T extends Entity> T saveOrUpdate(T entity) {
interceptor().ifPresent(i -> i.touchForUpdate(entity));
return em().merge(entity);
}
示例10: update
import sample.context.Entity; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public <T extends Entity> T update(T entity) {
interceptor().ifPresent(i -> i.touchForUpdate(entity));
return em().merge(entity);
}
示例11: delete
import sample.context.Entity; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public <T extends Entity> T delete(T entity) {
em().remove(entity);
return entity;
}
示例12: criteria
import sample.context.Entity; //导入依赖的package包/类
public <T extends Entity> JpaCriteria<T> criteria(Class<T> clazz) {
return new JpaCriteria<T>(clazz, em().getCriteriaBuilder());
}
示例13: get
import sample.context.Entity; //导入依赖的package包/类
@Override
public <T extends Entity> T get(Class<T> clazz, Serializable id) {
return em().find(clazz, id);
}
示例14: load
import sample.context.Entity; //导入依赖的package包/类
@Override
public <T extends Entity> T load(Class<T> clazz, Serializable id) {
return em().getReference(clazz, id);
}
示例15: exists
import sample.context.Entity; //导入依赖的package包/类
@Override
public <T extends Entity> boolean exists(Class<T> clazz, Serializable id) {
return get(clazz, id) != null;
}