-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Metamodel field is null
PostPosted: Fri Mar 13, 2015 8:02 am 
Newbie

Joined: Fri Mar 13, 2015 7:55 am
Posts: 1
I have a model called UnitDayStatistics that extends from DayStatistics with single table inheritance. I have generated metamodels UnitDayStatistics_ that inherits from DayStatistics_. In DayStatistics I have a field called day. But UnitDayStatistics_.day is null when I am trying to use it. Why?

UnitDayStatistics:
Code:
package models;

import javax.annotation.Generated;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;

@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
@StaticMetamodel(UnitDayStatistics.class)
public abstract class UnitDayStatistics_ extends models.DayStatistics_ {

   public static volatile SingularAttribute<UnitDayStatistics, Unit> unit;

}


DayStatistics:
Code:
package models;

import javax.annotation.Generated;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
import org.joda.time.DateTime;

@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
@StaticMetamodel(DayStatistics.class)
public abstract class DayStatistics_ extends models.AbstractModel_ {

   public static volatile SingularAttribute<DayStatistics, DateTime> day;

}


Usage:
Code:
public List<UnitDayStatistics> findByTimeSpanAndUnit(DateTime from, DateTime to, Unit unit) {
        CriteriaQuery<UnitDayStatistics> cq = cb.createQuery(classType);
        Root<UnitDayStatistics> root = cq.from(UnitDayStatistics.class);

        cq.where(cb.equal(root.get(UnitDayStatistics_.unit), unit));
        if(UnitDayStatistics_.day == null)
            Logger.error("UnitDayStatistics_.day Null!!");
        cq.where(cb.between(root.get(UnitDayStatistics_.day), from, to));

        cq.orderBy(cb.desc(root.get(UnitDayStatistics_.day)));

        return em.createQuery(cq).getResultList();
    }


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.