Tabnine Logo
GenericEntityService.tryValidate
Code IndexAdd Tabnine to your IDE (free)

How to use
tryValidate
method
in
org.hswebframework.web.service.GenericEntityService

Best Java code snippets using org.hswebframework.web.service.GenericEntityService.tryValidate (Showing top 4 results out of 315)

origin: hs-web/hsweb-framework

@Override
public int updateByPk(PK pk, E entity) {
  Assert.notNull(pk, "primary key can not be null");
  Assert.hasText(String.valueOf(pk), "primary key can not be null");
  Assert.notNull(entity, "entity can not be null");
  entity.setId(pk);
  tryValidate(entity, UpdateGroup.class);
  return createUpdate(entity)
      //如果是RecordCreationEntity则不修改creator_id和creator_time
      .when(entity instanceof RecordCreationEntity,
          update -> update.and().excludes(((RecordCreationEntity) entity).getCreatorIdProperty(), RecordCreationEntity.createTime))
      .where(GenericEntity.id, pk)
      .exec();
}
origin: hs-web/hsweb-framework

@Override
public PK insert(E entity) {
  if (!StringUtils.isEmpty(entity.getId())) {
    if ((entity.getId() instanceof String) && !StringUtils.isEmpty(entity.getId())) {
      tryValidateProperty(entity.getId().toString().matches("[a-zA-Z0-9_\\-]+"), "id", "只能由数字,字母,下划线,和-组成");
    }
    tryValidateProperty(selectByPk(entity.getId()) == null, "id", entity.getId() + "已存在");
  }
  if (StringUtils.isEmpty(entity.getId()) && getIDGenerator() != null) {
    entity.setId(getIDGenerator().generate());
  }
  if (entity instanceof RecordCreationEntity) {
    ((RecordCreationEntity) entity).setCreateTimeNow();
  }
  tryValidate(entity, CreateGroup.class);
  getDao().insert(entity);
  return entity.getId();
}
origin: org.hswebframework.web/hsweb-commons-service-simple

@Override
public PK insert(E entity) {
  if (!StringUtils.isEmpty(entity.getId())) {
    if ((entity.getId() instanceof String) && !StringUtils.isEmpty(entity.getId())) {
      tryValidateProperty(entity.getId().toString().matches("[a-zA-Z0-9_\\-]+"), "id", "只能由数字,字母,下划线,和-组成");
    }
    tryValidateProperty(selectByPk(entity.getId()) == null, "id", entity.getId() + "已存在");
  }
  if (StringUtils.isEmpty(entity.getId()) && getIDGenerator() != null) {
    entity.setId(getIDGenerator().generate());
  }
  if (entity instanceof RecordCreationEntity) {
    ((RecordCreationEntity) entity).setCreateTimeNow();
  }
  tryValidate(entity, CreateGroup.class);
  getDao().insert(entity);
  return entity.getId();
}
origin: org.hswebframework.web/hsweb-commons-service-simple

@Override
public int updateByPk(PK pk, E entity) {
  Assert.notNull(pk, "primary key can not be null");
  Assert.hasText(String.valueOf(pk), "primary key can not be null");
  Assert.notNull(entity, "entity can not be null");
  entity.setId(pk);
  tryValidate(entity, UpdateGroup.class);
  return createUpdate(entity)
      //如果是RecordCreationEntity则不修改creator_id和creator_time
      .when(entity instanceof RecordCreationEntity,
          update -> update.and().excludes(((RecordCreationEntity) entity).getCreatorIdProperty(), RecordCreationEntity.createTime))
      .where(GenericEntity.id, pk)
      .exec();
}
org.hswebframework.web.serviceGenericEntityServicetryValidate

Popular methods of GenericEntityService

  • deleteByPk
  • updateByPk
  • insert
  • saveOrUpdate
  • selectByPk
  • count
  • createQuery
  • createUpdate
  • dataExisted
  • getDao
  • getEntityInstanceType
  • getIDGenerator
    获取ID生成器,在insert的时候,如果ID为空,则调用生成器进行生成
  • getEntityInstanceType,
  • getIDGenerator,
  • select,
  • tryValidateProperty

Popular in Java

  • Updating database using SQL prepared statement
  • getApplicationContext (Context)
  • setRequestProperty (URLConnection)
  • putExtra (Intent)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • JFrame (javax.swing)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now