Search in sources :

Example 1 with DoubleType

use of org.hibernate.type.DoubleType in project Gemma by PavlidisLab.

the class DifferentialExpressionResultDaoImpl method findGeneInResultSets.

@Override
public List<Double> findGeneInResultSets(Gene gene, ExpressionAnalysisResultSet resultSet, Collection<Long> arrayDesignIds, Integer limit) {
    StopWatch timer = new StopWatch();
    timer.start();
    List<Double> results;
    Session session = this.getSessionFactory().getCurrentSession();
    org.hibernate.SQLQuery queryObject = session.createSQLQuery(DifferentialExpressionResultDaoImpl.fetchResultsByResultSetAndGeneQuery);
    queryObject.setLong("gene_id", gene.getId());
    queryObject.setLong("rs_id", resultSet.getId());
    if (limit != null) {
        queryObject.setMaxResults(limit);
    }
    queryObject.addScalar("CORRECTED_PVALUE", new DoubleType());
    // noinspection unchecked
    results = queryObject.list();
    timer.stop();
    if (AbstractDao.log.isDebugEnabled())
        AbstractDao.log.debug("Fetching probeResults from resultSet " + resultSet.getId() + " for gene " + gene.getId() + "and " + arrayDesignIds.size() + "arrays took : " + timer.getTime() + " ms");
    return results;
}
Also used : DoubleType(org.hibernate.type.DoubleType) org.hibernate(org.hibernate) StopWatch(org.apache.commons.lang3.time.StopWatch)

Example 2 with DoubleType

use of org.hibernate.type.DoubleType in project dhis2-core by dhis2.

the class HibernatePropertyIntrospector method createProperty.

private Property createProperty(Class<?> klass, org.hibernate.mapping.Property hibernateProperty, MetamodelImplementor metamodelImplementor) {
    Property property = new Property(klass);
    property.setRequired(false);
    property.setPersisted(true);
    property.setWritable(true);
    property.setOwner(true);
    Type type = hibernateProperty.getType();
    property.setName(hibernateProperty.getName());
    property.setFieldName(hibernateProperty.getName());
    property.setCascade(hibernateProperty.getCascade());
    property.setCollection(type.isCollectionType());
    property.setSetterMethod(hibernateProperty.getSetter(klass).getMethod());
    property.setGetterMethod(hibernateProperty.getGetter(klass).getMethod());
    if (property.isCollection()) {
        initCollectionProperty(metamodelImplementor, property, (CollectionType) type);
    }
    if (type instanceof SingleColumnType || type instanceof CustomType || type instanceof ManyToOneType) {
        Column column = (Column) hibernateProperty.getColumnIterator().next();
        property.setUnique(column.isUnique());
        property.setRequired(!column.isNullable());
        property.setMin(0d);
        property.setMax((double) column.getLength());
        property.setLength(column.getLength());
        if (type instanceof TextType) {
            property.setMin(0d);
            property.setMax((double) Integer.MAX_VALUE);
            property.setLength(Integer.MAX_VALUE);
        } else if (type instanceof IntegerType) {
            property.setMin((double) Integer.MIN_VALUE);
            property.setMax((double) Integer.MAX_VALUE);
            property.setLength(Integer.MAX_VALUE);
        } else if (type instanceof LongType) {
            property.setMin((double) Long.MIN_VALUE);
            property.setMax((double) Long.MAX_VALUE);
            property.setLength(Integer.MAX_VALUE);
        } else if (type instanceof DoubleType) {
            property.setMin(-Double.MAX_VALUE);
            property.setMax(Double.MAX_VALUE);
            property.setLength(Integer.MAX_VALUE);
        }
    }
    if (type instanceof ManyToOneType) {
        property.setManyToOne(true);
        property.setRequired(property.isRequired() && !property.isCollection());
        if (property.isOwner()) {
            property.setOwningRole(klass.getName() + "." + property.getName());
        } else {
            property.setInverseRole(klass.getName() + "." + property.getName());
        }
    } else if (type instanceof OneToOneType) {
        property.setOneToOne(true);
    } else if (type instanceof OneToMany) {
        property.setOneToMany(true);
    }
    return property;
}
Also used : CustomType(org.hibernate.type.CustomType) IntegerType(org.hibernate.type.IntegerType) CustomType(org.hibernate.type.CustomType) CollectionType(org.hibernate.type.CollectionType) ManyToOneType(org.hibernate.type.ManyToOneType) IntegerType(org.hibernate.type.IntegerType) TextType(org.hibernate.type.TextType) LongType(org.hibernate.type.LongType) SingleColumnType(org.hibernate.type.SingleColumnType) OneToOneType(org.hibernate.type.OneToOneType) SetType(org.hibernate.type.SetType) DoubleType(org.hibernate.type.DoubleType) Type(org.hibernate.type.Type) LongType(org.hibernate.type.LongType) SingleColumnType(org.hibernate.type.SingleColumnType) ManyToOneType(org.hibernate.type.ManyToOneType) Column(org.hibernate.mapping.Column) DoubleType(org.hibernate.type.DoubleType) OneToMany(org.hibernate.mapping.OneToMany) Property(org.hisp.dhis.schema.Property) TextType(org.hibernate.type.TextType) OneToOneType(org.hibernate.type.OneToOneType)

Aggregations

DoubleType (org.hibernate.type.DoubleType)2 StopWatch (org.apache.commons.lang3.time.StopWatch)1 org.hibernate (org.hibernate)1 Column (org.hibernate.mapping.Column)1 OneToMany (org.hibernate.mapping.OneToMany)1 CollectionType (org.hibernate.type.CollectionType)1 CustomType (org.hibernate.type.CustomType)1 IntegerType (org.hibernate.type.IntegerType)1 LongType (org.hibernate.type.LongType)1 ManyToOneType (org.hibernate.type.ManyToOneType)1 OneToOneType (org.hibernate.type.OneToOneType)1 SetType (org.hibernate.type.SetType)1 SingleColumnType (org.hibernate.type.SingleColumnType)1 TextType (org.hibernate.type.TextType)1 Type (org.hibernate.type.Type)1 Property (org.hisp.dhis.schema.Property)1