Package org.hibernate.criterion

Examples of org.hibernate.criterion.Example$AllPropertySelector


    @SuppressWarnings("unchecked")
    @Override
    public List<T> findByExample(T exampleInstance, String[] excludeProperty) {
        Criteria crit = getSession().createCriteria(getPersistentClass());
        Example example = Example.create(exampleInstance);
        for (String exclude : excludeProperty) {
            example.excludeProperty(exclude);
        }
        crit.add(example);
        return crit.list();
    }
View Full Code Here


        Session s = openSession();

        Transaction t = s.beginTransaction();
        Componentizable master = getMaster("hibernate", "open sourc%", "open source1");
        Criteria crit = s.createCriteria(Componentizable.class);
        Example ex = Example.create(master).enableLike();
        crit.add(ex);
        List result = crit.list();
        assertNotNull(result);
        assertEquals(1, result.size());
View Full Code Here

        initData();
        Session s = openSession();
        Transaction t = s.beginTransaction();
        Componentizable master = getMaster("hibernate", null, "ope%");
        Criteria crit = s.createCriteria(Componentizable.class);
        Example ex = Example.create(master).enableLike();

        crit.add(Expression.or(Expression.not(ex), ex));

        List result = crit.list();
        assertNotNull(result);
View Full Code Here

        initData();
        Session s = openSession();
        Transaction t = s.beginTransaction();
        Componentizable master = getMaster("hibernate", null, "ope%");
        Criteria crit = s.createCriteria(Componentizable.class);
        Example ex = Example.create(master).enableLike()
            .excludeProperty("component.subComponent");
        crit.add(ex);
        List result = crit.list();
        assertNotNull(result);
        assertEquals(3, result.size());
View Full Code Here

  @Override
  public <E extends Entity> List<E> findByExample(EntityManager em, E example)
  {
    Session session = (Session) em.getDelegate();
    Example customerExample = Example.create(example).excludeZeroes();
    Criteria criteria = session.createCriteria(example.getClass()).add(customerExample);
    @SuppressWarnings("unchecked")
    List<E> list = criteria.list();
    return list;
  }
View Full Code Here

  public Person findByExactMatch(Person pPerson) {
    if (pPerson == null || TreebaseUtil.isEmpty(pPerson.getLastName())) {
      return null;
    }

    Example examplePerson = Example.create(pPerson);
    Criteria c = getSession().createCriteria(Person.class);
    c.add(examplePerson);

    // Notes: the query by criteria does not work!
    // c.add(Expression.eq("lastName", pPerson.getLastName()));
View Full Code Here

    HibernateCallback generateExampleCallback(final T exampleInstance, final String... excludeProperty) {
        HibernateCallback callback = new HibernateCallback() {
            public Object doInHibernate(Session session) throws HibernateException, SQLException {
                // Using Hibernate, more difficult with EntityManager and EJB-QL
                Criteria crit = session.createCriteria(getPersistentClass());
                Example example = Example.create(exampleInstance);
                for (String exclude : excludeProperty) {
                    example.excludeProperty(exclude);
                }
                crit.add(example);
                return crit.list();
            }
View Full Code Here

    HibernateCallback generateOneByExampleCallback(final T exampleInstance, final String... excludeProperty) {
        HibernateCallback callback = new HibernateCallback() {
            public Object doInHibernate(Session session) throws HibernateException, SQLException {
                // Using Hibernate, more difficult with EntityManager and EJB-QL
                Criteria crit = session.createCriteria(getPersistentClass());
                Example example = Example.create(exampleInstance);
                for (String exclude : excludeProperty) {
                    example.excludeProperty(exclude);
                }
                crit.add(example);
                return crit.uniqueResult();
            }
View Full Code Here

TOP

Related Classes of org.hibernate.criterion.Example$AllPropertySelector

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.