Package javax.persistence

Examples of javax.persistence.Table


      //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


@Table
public class JpaTableTest extends TestCase {

    public void testEmptyAnnotationConstructor() throws Exception {
        Table annotation = getClass().getAnnotation(Table.class);

        JpaTable t = new JpaTable(annotation);
        assertNull(t.getName());
        assertNull(t.getCatalog());
        assertNull(t.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

       
        /*
         * Check if the field has a different column name
         */
        try {
            Table tab = ((Class<?>) ammd.getType()).getAnnotation(Table.class);
            if (tab != null) {
                String renamedField = tab.name();
                if (renamedField != null && renamedField.length() > 0) {
                    ret = getColumnByForceApiName(renamedField);
                }
            }
        } catch (Exception ignored) {
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

        return sts;
    }

    public static final String getTableName(Class<?> clazz) {
        Table table = clazz.getAnnotation(Table.class);
        return table != null ? table.name() : clazz.getSimpleName();
    }
View Full Code Here

    while (curClass.getSuperclass() != null && curClass.getSuperclass().getName() != "java.lang.Object") {
      curClass = curClass.getSuperclass();
    }
    // At this point, curClass is the root base class of proxyObj's class, and curClass is not java.lang.Object.

    Table tabObj = (Table)curClass.getAnnotation(Table.class);

    if (tabObj == null) {
      s_logger.info("\n" + curClass + "does not have a Table annotation\n");
      return null;
    }
   
    return tabObj.name();
  }
View Full Code Here

       
        return sts;
    }
   
    public static final String getTableName(Class<?> clazz) {
        Table table = clazz.getAnnotation(Table.class);
        return table != null ? table.name() : clazz.getSimpleName();
    }
View Full Code Here

        }
    }

    private void putTableDeclaration(AnnotationInfo ai, Class<?> c)
  {
      Table table = c.getAnnotation(Table.class);
      if(table != null)
      {
        if(table.name() == null)
          throw new PersistenceException("You must specify a name= for @Table on " + c.getName());
       
        ai.setDomainName(table.name());
      }
  }
View Full Code Here

    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

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.