javax.persistence.Table.uniqueConstraints()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(517)

本文整理了Java中javax.persistence.Table.uniqueConstraints()方法的一些代码示例,展示了Table.uniqueConstraints()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.uniqueConstraints()方法的具体详情如下:
包路径:javax.persistence.Table
类名称:Table
方法名:uniqueConstraints

Table.uniqueConstraints介绍

暂无

代码示例

代码示例来源:origin: hibernate/hibernate-orm

  1. annotation.setValue( "schema", table.schema() );
  2. annotation.setValue( "catalog", table.catalog() );
  3. annotation.setValue( "uniqueConstraints", table.uniqueConstraints() );
  4. annotation.setValue( "indexes", table.indexes() );

代码示例来源:origin: jamesagnew/hapi-fhir

  1. if (table != null) {
  2. assertNotADuplicateName(table.name(), theNames);
  3. for (UniqueConstraint nextConstraint : table.uniqueConstraints()) {
  4. assertNotADuplicateName(nextConstraint.name(), theNames);
  5. Validate.isTrue(nextConstraint.name().startsWith("IDX_"), nextConstraint.name() + " must start with IDX_");

代码示例来源:origin: hibernate/hibernate-orm

  1. schema = tabAnn.schema();
  2. catalog = tabAnn.catalog();
  3. uniqueConstraints = TableBinder.buildUniqueConstraintHolders( tabAnn.uniqueConstraints() );

代码示例来源:origin: org.bitbucket.risu8/hibernate

  1. @Override
  2. public void initialize(UniqueProperties constraintAnnotation) {
  3. clazz = constraintAnnotation.value();
  4. Table table = clazz.getAnnotation(Table.class);
  5. if (table == null) {
  6. return;
  7. }
  8. uniqueConstraints = table.uniqueConstraints();
  9. }

代码示例来源:origin: michaelliao/warpdb

  1. String getUniqueKey() {
  2. Table table = this.entityClass.getAnnotation(Table.class);
  3. if (table != null) {
  4. return Arrays.stream(table.uniqueConstraints()).map((c) -> {
  5. String name = c.name().isEmpty() ? "UNI_" + String.join("_", c.columnNames()) : c.name();
  6. return " CONSTRAINT " + name + " UNIQUE (" + String.join(", ", c.columnNames()) + "),\n";
  7. }).reduce("", (acc, s) -> {
  8. return acc + s;
  9. });
  10. }
  11. return "";
  12. }

代码示例来源:origin: jaxio/jpa-query-by-example

  1. private List<String> validateCompositeUniqueConstraints(Identifiable<?> entity) {
  2. Class<?> entityClass = getClassWithoutInitializingProxy(entity);
  3. Table table = entityClass.getAnnotation(Table.class);
  4. if (table == null) {
  5. return emptyList();
  6. }
  7. List<String> errors = newArrayList();
  8. for (UniqueConstraint uniqueConstraint : table.uniqueConstraints()) {
  9. if (!checkCompositeUniqueConstraint(entity, entityClass, uniqueConstraint)) {
  10. errors.add(compositeUniqueConstraintErrorCode(entity, uniqueConstraint));
  11. }
  12. }
  13. return errors;
  14. }

代码示例来源:origin: jaxio/generated-projects

  1. private List<String> validateCompositeUniqueConstraints(Identifiable<?> entity) {
  2. Class<?> entityClass = getClassWithoutInitializingProxy(entity);
  3. Table table = entityClass.getAnnotation(Table.class);
  4. if (table == null) {
  5. return emptyList();
  6. }
  7. List<String> errors = newArrayList();
  8. for (UniqueConstraint uniqueConstraint : table.uniqueConstraints()) {
  9. if (!checkCompositeUniqueConstraint(entity, entityClass, uniqueConstraint)) {
  10. errors.add(compositeUniqueConstraintErrorCode(entity, uniqueConstraint));
  11. }
  12. }
  13. return errors;
  14. }

代码示例来源:origin: micromata/projectforge

  1. public Table(final Class<?> entityClass)
  2. {
  3. this.entityClass = entityClass;
  4. final Entity entity = entityClass.getAnnotation(Entity.class);
  5. final javax.persistence.Table table = entityClass.getAnnotation(javax.persistence.Table.class);
  6. final DiscriminatorValue discriminatorValue = entityClass.getAnnotation(DiscriminatorValue.class);
  7. discriminatorColumn = entityClass.getAnnotation(DiscriminatorColumn.class);
  8. if (entity == null) {
  9. log.info("Unsupported class (@Entity expected): " + entityClass);
  10. return;
  11. }
  12. if (table != null && StringUtils.isNotEmpty(table.name()) == true) {
  13. this.name = table.name();
  14. uniqueConstraints = table.uniqueConstraints();
  15. } else if (discriminatorValue != null) {
  16. this.superTable = new Table(entityClass.getSuperclass());
  17. } else {
  18. log.info("Unsupported class (@Table and @Table.name or @DiscriminatorValue expected): " + entityClass);
  19. }
  20. }

代码示例来源:origin: org.javabeanstack/jbs-business

  1. /**
  2. * Devuelve una lista conteniendo los campos que conforman la clave unica.
  3. *
  4. * @param <T>
  5. * @param classType
  6. * @return lista conteniendo los campos que conforman la clave unica.
  7. */
  8. public static <T extends IDataRow> String[] getUniqueFields(Class<T> classType) {
  9. try {
  10. String[] uniqueConst = classType.getAnnotation(Table.class).uniqueConstraints()[0].columnNames();
  11. if (uniqueConst != null) {
  12. return uniqueConst;
  13. }
  14. } catch (Exception ex) {
  15. ErrorManager.showError(ex, LOGGER);
  16. }
  17. return null;
  18. }

代码示例来源:origin: ebean-orm/ebean

  1. UniqueConstraint[] uniqueConstraints = table.uniqueConstraints();
  2. for (UniqueConstraint c : uniqueConstraints) {
  3. descriptor.addIndex(new IndexDefinition(c.columnNames()));

代码示例来源:origin: BatooOrg/BatooJPA

  1. /**
  2. * @param locator
  3. * the java locator
  4. * @param annotation
  5. * the annotation
  6. *
  7. * @since 2.0.0
  8. */
  9. public TableMetadataImpl(AbstractLocator locator, Table annotation) {
  10. super();
  11. this.locator = locator;
  12. this.catalog = annotation.catalog();
  13. this.schema = annotation.schema();
  14. this.name = annotation.name();
  15. for (final UniqueConstraint constraint : annotation.uniqueConstraints()) {
  16. this.uniqueConstraints.add(new UniqueConstraintMetadataImpl(locator, constraint));
  17. }
  18. }

代码示例来源:origin: org.batoo.jpa/batoo-jpa

  1. /**
  2. * @param locator
  3. * the java locator
  4. * @param annotation
  5. * the annotation
  6. *
  7. * @since 2.0.0
  8. */
  9. public TableMetadataImpl(AbstractLocator locator, Table annotation) {
  10. super();
  11. this.locator = locator;
  12. this.catalog = annotation.catalog();
  13. this.schema = annotation.schema();
  14. this.name = annotation.name();
  15. for (final UniqueConstraint constraint : annotation.uniqueConstraints()) {
  16. this.uniqueConstraints.add(new UniqueConstraintMetadataImpl(locator, constraint));
  17. }
  18. }

代码示例来源:origin: org.batoo.jpa/parser

  1. /**
  2. * @param locator
  3. * the java locator
  4. * @param annotation
  5. * the annotation
  6. *
  7. * @since 2.0.0
  8. */
  9. public TableMetadataImpl(AbstractLocator locator, Table annotation) {
  10. super();
  11. this.locator = locator;
  12. this.catalog = annotation.catalog();
  13. this.schema = annotation.schema();
  14. this.name = annotation.name();
  15. for (final UniqueConstraint constraint : annotation.uniqueConstraints()) {
  16. this.uniqueConstraints.add(new UniqueConstraintMetadataImpl(locator, constraint));
  17. }
  18. }

代码示例来源:origin: org.hibernate/hibernate-annotations

  1. annotation.setValue( "schema", table.schema() );
  2. annotation.setValue( "catalog", table.catalog() );
  3. annotation.setValue( "uniqueConstraints", table.uniqueConstraints() );

代码示例来源:origin: toplink.essentials/toplink-essentials

  1. /**
  2. * INTERNAL:
  3. */
  4. public MetadataTable(Table table, MetadataLogger logger) {
  5. this(logger);
  6. if (table != null) {
  7. m_name = table.name();
  8. m_schema = table.schema();
  9. m_catalog = table.catalog();
  10. processName();
  11. processUniqueConstraints(table.uniqueConstraints());
  12. }
  13. }

代码示例来源:origin: org.hibernate/hibernate-annotations

  1. schema = tabAnn.schema();
  2. catalog = tabAnn.catalog();
  3. uniqueConstraints = TableBinder.buildUniqueConstraintHolders( tabAnn.uniqueConstraints() );

代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa

  1. /**
  2. * Set class table.
  3. */
  4. private void parseTable(ClassMapping cm, Table table) {
  5. String tableName = toTableName(table.schema(), table.name());
  6. if (tableName != null)
  7. cm.getMappingInfo().setTableName(tableName);
  8. for (UniqueConstraint uniqueConstraint:table.uniqueConstraints()) {
  9. Unique unique = newUnique(cm, null, uniqueConstraint.columnNames());
  10. cm.getMappingInfo().addUnique(unique);
  11. }
  12. }

代码示例来源:origin: org.apache.openjpa/openjpa-all

  1. /**
  2. * Set class table.
  3. */
  4. private void parseTable(ClassMapping cm, Table table) {
  5. if (cm.isAbstract())
  6. throw new UserException(_loc.get("table-not-allowed", cm));
  7. DBIdentifier tName = toTableIdentifier(table.schema(), table.name());
  8. if (!DBIdentifier.isNull(tName)) {
  9. cm.getMappingInfo().setTableIdentifier(tName);
  10. }
  11. addUniqueConstraints(tName.getName(), cm, cm.getMappingInfo(),
  12. table.uniqueConstraints());
  13. }

代码示例来源:origin: org.apache.openjpa/openjpa-persistence-jdbc

  1. /**
  2. * Set class table.
  3. */
  4. private void parseTable(ClassMapping cm, Table table) {
  5. if (cm.isAbstract())
  6. throw new UserException(_loc.get("table-not-allowed", cm));
  7. DBIdentifier tName = toTableIdentifier(table.schema(), table.name());
  8. if (!DBIdentifier.isNull(tName)) {
  9. cm.getMappingInfo().setTableIdentifier(tName);
  10. }
  11. addUniqueConstraints(tName.getName(), cm, cm.getMappingInfo(),
  12. table.uniqueConstraints());
  13. }

代码示例来源:origin: org.apache.openejb.patch/openjpa

  1. /**
  2. * Set class table.
  3. */
  4. private void parseTable(ClassMapping cm, Table table) {
  5. if (cm.isAbstract())
  6. throw new UserException(_loc.get("table-not-allowed", cm));
  7. DBIdentifier tName = toTableIdentifier(table.schema(), table.name());
  8. if (!DBIdentifier.isNull(tName)) {
  9. cm.getMappingInfo().setTableIdentifier(tName);
  10. }
  11. addUniqueConstraints(tName.getName(), cm, cm.getMappingInfo(),
  12. table.uniqueConstraints());
  13. }

相关文章