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


  /**
   * Gets the table name from annotation.
   */
  protected TableName getTableNameFromAnnotation(Class<?> beanClass) {

    final Table t = findTableAnnotation(beanClass);

    // Take the annotation if defined
    if (t != null && !isEmpty(t.name())) {
      // Note: empty catalog and schema are converted to null
      // Only need to convert quoted identifiers from annotations
      return new TableName(quoteIdentifiers(t.catalog()), quoteIdentifiers(t.schema()),
          quoteIdentifiers(t.name()));
    }

    // No annotation
    return null;
  }
View Full Code Here

   */
  protected Table findTableAnnotation(Class<?> cls) {
    if (cls.equals(Object.class)) {
      return null;
    }
    Table table = cls.getAnnotation(Table.class);
    if (table != null) {
      return table;
    }
    return findTableAnnotation(cls.getSuperclass());
  }
View Full Code Here

     * {@inheritDoc}
     */
    public String getUserPassword(Long userId) {
        JdbcTemplate jdbcTemplate =
                new JdbcTemplate(SessionFactoryUtils.getDataSource(getSessionFactory()));
        Table table = AnnotationUtils.findAnnotation(User.class, Table.class);
        return jdbcTemplate.queryForObject(
                "select password from " + table.name() + " where id=?", String.class, userId);
    }
View Full Code Here

        void onEntity(
                JpaEntity entity,
                AnnotatedElement element,
                AnnotationProcessorStack context) {

            Table annotation = element.getAnnotation(Table.class);
            entity.setTable(new JpaTable(annotation));
        }
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 = curClass.getAnnotation(Table.class);

    if (tabObj == null) {
            s_logger.trace(curClass + "does not have a Table annotation");
      return null;
    }

    return tabObj.name();
  }
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

            return null;
        }
    }
   
    public static String getTableName(Class<?> entity) {
        Table tableAnnotation = entity.getAnnotation(Table.class);
        if (tableAnnotation != null) {
            String name = tableAnnotation.name();
            if (name.isEmpty()) {
                name = entity.getSimpleName();
            }

            return name.toUpperCase();
View Full Code Here

     * @param entityClass Class of entity
     * @return The table name
     */
    public static String getTableName(final Class entityClass) {
        if (entityClass.isAnnotationPresent(Table.class)) {
            Table table = (Table) entityClass.getAnnotation(Table.class);
            return table.name();
        } else {
            return null;
        }
    }
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.