Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package net.java.ao.types;
 
 
 import static java.sql.Types.INTEGER;
 
final class EntityType<K, T extends RawEntity<K>> extends AbstractLogicalType<T>
    private final TypeInfo<K> primaryKeyTypeInfo;
    private final Class<K> primaryKeyClass;
    
    public EntityType(Class<T> entityClass,
                      TypeInfo<K> primaryKeyTypeInfo,
                      Class<K> primaryKeyClass)
    {
        super("Entity(" + entityClass.getName() + ")",
              new Class<?>[] { RawEntity.class },
              new Integer[] { });
        this. = primaryKeyTypeInfo;
        this. = primaryKeyClass;
    }
    
    @Override
    public int getDefaultJdbcWriteType()
    {
        return .getJdbcWriteType();
    }
    
    @Override
    public Object validate(Object value)
    {
        // We currently support passing the primary key type as a database parameter in place of the
        // entity, so we need to bypass the regular type validation here.
        return value;
    }
    
    @Override
    public T pullFromDatabase(EntityManager managerResultSet resClass<T> typeString columnName)
        throws SQLException
    {
        return Common.createPeer(managertype,
                                 .getLogicalType().pullFromDatabase(managerrescolumnName));
    }
    @Override
    public void putToDatabase(EntityManager managerPreparedStatement stmtint index, T valueint jdbcType)
        throws SQLException
    {
        .getLogicalType().putToDatabase(managerstmtindex, Common.getPrimaryKeyValue(value),
                                                          .getJdbcWriteType());
    }
    
    @Override
    public boolean equals(Object other)
    {
        if (other instanceof EntityType)
        {
            EntityType<?, ?> et = (EntityType<?, ?>) other;
            return et.primaryKeyTypeInfo.equals()
                && et.primaryKeyClass.equals();
        }
        return false;
    }
New to GrepCode? Check out our FAQ X