Package org.hibernate.classic

Examples of org.hibernate.classic.Session.createCriteria()


  @SuppressWarnings("unchecked")
    public Collection<Item> getItems(Proyecto proyecto){
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();
   
    Criteria criteria = session.createCriteria(Item.class)
    .add(Restrictions.eq("proyecto", proyecto));

    List<Item> items = criteria.list();
   
    session.close();
View Full Code Here


  @SuppressWarnings("unchecked")
    public Collection<EstadoItem> getEstadosHistoricosItem(Item item){
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();
   
    Criteria criteria = session.createCriteria(EstadoHistorico.class)
    .setProjection(Projections.property("estadoHistorico"))
    .createCriteria("estadoActual")
    .add(Restrictions.eq("item", item))
    .addOrder(Order.asc("fechaInicio") );
   
View Full Code Here

                                }
                            }
                        }

                        if (mustCheckInDB) {
                            Criteria criteria = session.createCriteria(HistoryEntry.class);
                            criteria.add(Restrictions.eq("uuid", nodeIdentifier));
                            criteria.add(Restrictions.eq("date", date != null ? Long.valueOf(date.getTime()) : null));
                            criteria.add(Restrictions.eq("propertyName", propertyName));
                            criteria.add(Restrictions.eq("action", action));
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public List<HistoryEntry> getNodeHistory(JCRNodeWrapper node, boolean withLanguageNodes) {
        Session session = sessionFactoryBean.openSession();
        Criteria criteria = session.createCriteria(HistoryEntry.class);
        try {
            criteria.add(Restrictions.eq("uuid", node.getIdentifier()));
            List<HistoryEntry> result = (List<HistoryEntry>) criteria.list();
            if (withLanguageNodes) {
                List<Locale> existingLocales = node.getExistingLocales();
View Full Code Here

            List<HistoryEntry> result = (List<HistoryEntry>) criteria.list();
            if (withLanguageNodes) {
                List<Locale> existingLocales = node.getExistingLocales();
                for (Locale existingLocale : existingLocales) {
                    Node localeNode = node.getI18N(existingLocale);
                    criteria = session.createCriteria(HistoryEntry.class);
                    criteria.add(Restrictions.eq("uuid", localeNode.getIdentifier()));
                    List<HistoryEntry> languageHistoryEntries = (List<HistoryEntry>) criteria.list();
                    for (HistoryEntry languageHistoryEntry : languageHistoryEntries) {
                        languageHistoryEntry.setLocale(existingLocale);
                        result.add(languageHistoryEntry);
View Full Code Here

    Single b = new Single();
    b.setId("asdfa");
    b.setString("asdfasdf");
    s.save(f);
    s.save(b);
    List list = s.createCriteria(Object.class).list();
    assertTrue( list.size()==2 );
    assertTrue( list.contains(f) && list.contains(b) );
    s.delete(f);
    s.delete(b);
    txn.commit();
View Full Code Here

    t.commit();
    s.close();

    s = openSession();
    t = s.beginTransaction();
    Master m1 = (Master) s.createCriteria(Master.class)
      .add( Example.create(m).enableLike().ignoreCase().excludeProperty("bigDecimal") )
      .uniqueResult();
    assertTrue( m1.getOtherMaster()==m1 );
    m1 = (Master) s.createCriteria(Master.class)
      .add( Restrictions.eq("name", "foobar") )
View Full Code Here

    t = s.beginTransaction();
    Master m1 = (Master) s.createCriteria(Master.class)
      .add( Example.create(m).enableLike().ignoreCase().excludeProperty("bigDecimal") )
      .uniqueResult();
    assertTrue( m1.getOtherMaster()==m1 );
    m1 = (Master) s.createCriteria(Master.class)
      .add( Restrictions.eq("name", "foobar") )
      .uniqueResult();
    assertTrue( m1==null );
    m1 = (Master) s.createCriteria(Master.class)
      .add( Example.create(m).excludeProperty("bigDecimal") )
View Full Code Here

    assertTrue( m1.getOtherMaster()==m1 );
    m1 = (Master) s.createCriteria(Master.class)
      .add( Restrictions.eq("name", "foobar") )
      .uniqueResult();
    assertTrue( m1==null );
    m1 = (Master) s.createCriteria(Master.class)
      .add( Example.create(m).excludeProperty("bigDecimal") )
      .createCriteria("otherMaster")
        .add( Example.create(m).excludeZeroes().excludeProperty("bigDecimal") )
      .uniqueResult();
    assertTrue( m1.getOtherMaster()==m1 );
View Full Code Here

      .add( Example.create(m).excludeProperty("bigDecimal") )
      .createCriteria("otherMaster")
        .add( Example.create(m).excludeZeroes().excludeProperty("bigDecimal") )
      .uniqueResult();
    assertTrue( m1.getOtherMaster()==m1 );
    Master m2 = (Master) s.createCriteria(Master.class)
      .add( Example.create(m).excludeNone().excludeProperty("bigDecimal") )
      .uniqueResult();
    assertTrue( m2==m1 );
    m.setName(null);
    m2 = (Master) s.createCriteria(Master.class)
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.