4 Replies Latest reply on Aug 6, 2007 2:32 PM by mladen babic

    Getting a session from entityManager

    mladen babic Newbie

      Hi ,

      I 've tried to use query by example.Problem is thet I get error when I try to get session.This is fragment of my code:

      public List<DistributorEntity> findDistributors(String name,BigDecimal time,BigDecimal costs,String account){
       DistributorEntity newDistributor=new DistributorEntity();
       newDistributor.setName(name);
       newDistributor.setDeliveryTime(time.intValue());
       newDistributor.setDeliveryCosts(costs);
       newDistributor.setAccount(account);
       Session session = (Session)entityManager.getDelegate();
       Example distributorExample=Example.create(newDistributor)
       .ignoreCase()
       .excludeZeroes()
       .enableLike();
       List list = session.createCriteria(DistributorEntity.class)
       .add(distributorExample).list();
       return list;
      


      In debug mode I have found that problem is in entityManager. getDelegate().It return null.How will i solve a problem?
      Best regards,
      mb