Package javax.persistence

Examples of javax.persistence.Table


    sqlNameToParameter = ImmutableMap.copyOf(n);
    idParameters = ImmutableMap.copyOf(id);
    manyToOneParameters = ImmutableMap.copyOf(m);
    simpleParameters = ImmutableMap.copyOf(s);
   
    Table t = objectType.getAnnotation(Table.class);
    if (t != null && t.name() != null) {
      sqlName = t.name();
    }
    else {
      sqlName = config.getNamingStrategy().classToTableName(objectType.getSimpleName());
    }
  }
View Full Code Here


            pair.writeMethod = getMethod(descriptor.getWriteMethod(), name, pair);
            pair.dataType = descriptor.getPropertyType();
            propertyMap.put(name, pair);
    }
   
    Table annot = (Table) clazz.getAnnotation(Table.class);
    if (annot != null) {
      table = annot.name();
    } else {
      table = clazz.getSimpleName();
    }
   
    makeInsertSql();
View Full Code Here

      //no element but might have some default or some annotation
      if ( StringHelper.isNotEmpty( defaults.getCatalog() )
          || StringHelper.isNotEmpty( defaults.getSchema() ) ) {
        AnnotationDescriptor annotation = new AnnotationDescriptor( Table.class );
        if ( defaults.canUseJavaAnnotations() ) {
          Table table = getJavaAnnotation( Table.class );
          if ( table != null ) {
            annotation.setValue( "name", table.name() );
            annotation.setValue( "schema", table.schema() );
            annotation.setValue( "catalog", table.catalog() );
            annotation.setValue( "uniqueConstraints", table.uniqueConstraints() );
            annotation.setValue( "indexes", table.indexes() );
          }
        }
        if ( StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) )
            && StringHelper.isNotEmpty( defaults.getSchema() ) ) {
          annotation.setValue( "schema", defaults.getSchema() );
View Full Code Here

      Entity e = beanDescriptor.getAnnotation(Entity.class);
      if (Conditions.isNotEmpty(e.name())) {
        entity.setAttribute("name", e.name());
      }

      Table t = beanDescriptor.getAnnotation(Table.class);
      if (t != null) {
        XmlElement table = entity.addElement("table");
        table.setAttribute("name", t.name());
        if (Conditions.isNotEmpty(t.schema())) {
          table.setAttribute("schema", t.schema());
        }
      }

      XmlElement attributes = entity.addElement("attributes");
View Full Code Here

        return this;
    }

    public SelectBuilder forClass(Class clazz) {
        this.clazz = clazz;
        Table table = Classes.getClassAnnotation(clazz, Table.class);
        if (table == null) {
            throw new TableNameNotFoundException("@Table annotation not found");
        }
        this.tableName = table.name();
        return this;
    }
View Full Code Here

      Entity e = beanDescriptor.getAnnotation(Entity.class);
      if (ConditionUtils.isNotEmpty(e.name())) {
        entity.setAttribute("name", e.name());
      }

      Table t = beanDescriptor.getAnnotation(Table.class);
      if (t != null) {
        XmlElement table = entity.addElement("table");
        table.setAttribute("name", t.name());
        if (ConditionUtils.isNotEmpty(t.schema())) {
          table.setAttribute("schema", t.schema());
        }
      }

      XmlElement attributes = entity.addElement("attributes");
View Full Code Here

      if (annotatedClass.equals(Object.class)) {
        throw new RuntimeException("There is no @Entity annotation on " + entityClass);
      }
    }
    final String tableName;
    Table table = annotatedClass.getAnnotation(Table.class);
    if (table == null) {
      tableName = annotatedClass.getSimpleName().toLowerCase();
    } else {
      tableName = table.name();
    }
    return tableName;
  }
View Full Code Here

      //no element but might have some default or some annotation
      if ( StringHelper.isNotEmpty( defaults.getCatalog() )
          || StringHelper.isNotEmpty( defaults.getSchema() ) ) {
        AnnotationDescriptor annotation = new AnnotationDescriptor( Table.class );
        if ( defaults.canUseJavaAnnotations() ) {
          Table table = getJavaAnnotation( Table.class );
          if ( table != null ) {
            annotation.setValue( "name", table.name() );
            annotation.setValue( "schema", table.schema() );
            annotation.setValue( "catalog", table.catalog() );
            annotation.setValue( "uniqueConstraints", table.uniqueConstraints() );
            annotation.setValue( "indexes", table.indexes() );
          }
        }
        if ( StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) )
            && StringHelper.isNotEmpty( defaults.getSchema() ) ) {
          annotation.setValue( "schema", defaults.getSchema() );
View Full Code Here

      //no element but might have some default or some annotation
      if ( StringHelper.isNotEmpty( defaults.getCatalog() )
          || StringHelper.isNotEmpty( defaults.getSchema() ) ) {
        AnnotationDescriptor annotation = new AnnotationDescriptor( Table.class );
        if ( defaults.canUseJavaAnnotations() ) {
          Table table = getJavaAnnotation( Table.class );
          if ( table != null ) {
            annotation.setValue( "name", table.name() );
            annotation.setValue( "schema", table.schema() );
            annotation.setValue( "catalog", table.catalog() );
            annotation.setValue( "uniqueConstraints", table.uniqueConstraints() );
          }
        }
        if ( StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) )
            && StringHelper.isNotEmpty( defaults.getSchema() ) ) {
          annotation.setValue( "schema", defaults.getSchema() );
View Full Code Here

    @DB(txn=false)
    protected void setField(final Object entity, final ResultSet rs, ResultSetMetaData meta, final int index) throws SQLException {
        Attribute attr = _allColumns.get(new Pair<String, String>(meta.getTableName(index), meta.getColumnName(index)));
        if ( attr == null ){
            // work around for mysql bug to return original table name instead of view name in db view case
            Table tbl = entity.getClass().getSuperclass().getAnnotation(Table.class);
            if ( tbl != null ){
                attr = _allColumns.get(new Pair<String, String>(tbl.name(), meta.getColumnLabel(index)));
            }
        }
        assert (attr != null) : "How come I can't find " + meta.getCatalogName(index) + "." + meta.getColumnName(index);
        setField(entity, attr.field, rs, index);
    }
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.