Package javax.persistence

Examples of javax.persistence.Table


     * @throws RuleValidationException
     */
    private void validateGeneratedValueAnnotation(final Class<?> clazz, Field field)
    {

        Table table = clazz.getAnnotation(Table.class);
        // Still we need to validate for this after post metadata
        // population.
        if (table != null)
        {
            String schemaName = table.schema();
            if (schemaName != null && schemaName.indexOf('@') > 0)
            {
                schemaName = schemaName.substring(0, schemaName.indexOf('@'));
                GeneratedValue generatedValue = field.getAnnotation(GeneratedValue.class);
                if (generatedValue != null && generatedValue.generator() != null
View Full Code Here


     * @param clazz
     * @param field
     */
    private void validateGeneratedValueAnnotation(final Class<?> clazz, Field field)
    {
        Table table = clazz.getAnnotation(Table.class);
        // Still we need to validate for this after post metadata population.
        if (table != null)
        {
            String schemaName = table.schema();
            if (schemaName != null && schemaName.indexOf('@') > 0)
            {
                schemaName = schemaName.substring(0, schemaName.indexOf('@'));
                GeneratedValue generatedValue = field.getAnnotation(GeneratedValue.class);
                if (generatedValue != null && generatedValue.generator() != null
View Full Code Here

        }
    }

    private void setSchemaAndPU(Class<?> clazz, EntityMetadata metadata)
    {
        Table table = clazz.getAnnotation(Table.class);
        if (table != null)
        {
//            log.debug("In set schema and pu, class is " + clazz.getName());
            // Set Name of persistence object
            metadata.setTableName(!StringUtils.isBlank(table.name()) ?
                     table.name() : clazz.getSimpleName());
            // Add named/native query related application metadata.
            addNamedNativeQueryMetadata(clazz);
            // set schema name and persistence unit name (if provided)
            String schemaStr = table.schema();

            MetadataUtils.setSchemaAndPersistenceUnit(metadata, schemaStr, puProperties);
        }
        if (metadata.getPersistenceUnit() == null)
        {
View Full Code Here

    return config;
  }

  public String getEntityName(Class<?> clazz) {
    Entity entityAnnotation = clazz.getAnnotation(Entity.class);
    Table tableAnnotation = clazz.getAnnotation(Table.class);

    if (entityAnnotation != null && stringNotEmpty(entityAnnotation.name())) {
      return entityAnnotation.name();
    }
    if (tableAnnotation != null && stringNotEmpty(tableAnnotation.name())) {
      return tableAnnotation.name();
    }
    return null;
  }
View Full Code Here

    boolean isEntity = ! (entityType instanceof MappedSuperclassType);
   
    AmberTable table = null;

    getInternalTableConfig(type, _annotationCfg);
    Table tableAnn = (Table) _annotationCfg.getAnnotation();
    TableConfig tableConfig = _annotationCfg.getTableConfig();

    String tableName = null;

    if (tableAnn != null)
      tableName = tableAnn.name();
    else if (tableConfig != null)
      tableName = tableConfig.getName();

    // jpa/0gg0, jpa/0gg2
    if (isEntity) { // && ! type.isAbstract()) {

      boolean hasTableConfig = true;

      if (tableName == null || tableName.equals("")) {
  hasTableConfig = false;
  tableName = toSqlName(entityType.getName());
      }

      /*
      InheritanceType strategy = null;
     
      if (parentType != null)
        strategy = parentType.getInheritanceStrategy();

      if (inheritanceAnn != null)
  strategy = (InheritanceType) inheritanceAnn.get("strategy");
      else if (inheritanceConfig != null)
  strategy = inheritanceConfig.getStrategy();
       */

      // jpa/0gg2
      if (! entityType.isEntity())
        return;
      /*
      if (type.isAbstract()
    && strategy != InheritanceType.JOINED
    && ! hasTableConfig) {
  // jpa/0gg0
      }
       */
      else if (parentType == null || parentType.getTable() == null) {
  entityType.setTable(_persistenceUnit.createTable(tableName));
      }
      else if (parentType.isJoinedSubClass()) {
  entityType.setTable(_persistenceUnit.createTable(tableName));

  EntityType rootType = parentType.getRootType();

  Class rootClass = rootType.getBeanClass();
  getInternalTableConfig(rootClass, _annotationCfg);
  Table rootTableAnn = (Table) _annotationCfg.getAnnotation();
  TableConfig rootTableConfig = _annotationCfg.getTableConfig();

  String rootTableName = null;

  if (rootTableAnn != null)
    rootTableName = rootTableAnn.name();
  else if (rootTableConfig != null)
    rootTableName = rootTableConfig.getName();

  if (rootTableName == null || rootTableName.equals("")) {
    String rootEntityName = rootType.getName();
View Full Code Here

  @Override
  public void handleClass(ClusterClassMetaInfo metaInfo, Class entityClass)
      throws ClusteredObjectAnalyzeException {
    if (entityClass.isAnnotationPresent(Table.class)) {
      Table tableAnnotation=(Table) entityClass.getAnnotation(Table.class);
      if (tableAnnotation.name()!=null && !tableAnnotation.name().isEmpty()) {
        metaInfo.setTableName(tableAnnotation.name());
      }
     
    }
    // table annotation not found or no name attribute in annotation
    if (metaInfo.getTableName()==null) {
View Full Code Here

    }
  }

  private static String extractTableName(Class<?> entityClass) {
    final String tableName;
    Table table = entityClass.getAnnotation(Table.class);
    if (table == null) {
      tableName = entityClass.getSimpleName().toLowerCase();
    } else {
      tableName = table.name();
    }
    return tableName;
  }
View Full Code Here

  @Override
  @Transactional
  public <T> void createIndex(Class<T> t, String key) {
   
    try {
      Table table = t.getAnnotation(Table.class);
      String tableName = table.name();

      Field property = getField(t, key);
      Column column = property.getAnnotation(Column.class);
      String columnName = column.name();
View Full Code Here

   */
  @Override
  @Transactional
  public <T> void createIndex(Class<T> t, List<String> keys) {
    try {
      Table table = t.getAnnotation(Table.class);
      String tableName = table.name();

      String columnNames = "";
      String columnIndexName = "";
      int position = 0;
      for (String key : keys) {
View Full Code Here

TOP

Related Classes of javax.persistence.Table

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.