Java tutorial
/* * Copyright 2005-2013 shopxx.net. All rights reserved. * Support: http://www.shopxx.net * License: http://www.shopxx.net/license */ package net.groupbuy.dao.impl; import javax.persistence.FlushModeType; import javax.persistence.NoResultException; import net.groupbuy.dao.PaymentDao; import net.groupbuy.entity.Payment; import org.springframework.stereotype.Repository; /** * Dao - ? * * @author SHOP++ Team * @version 3.0 */ @Repository("paymentDaoImpl") public class PaymentDaoImpl extends BaseDaoImpl<Payment, Long> implements PaymentDao { public Payment findBySn(String sn) { if (sn == null) { return null; } String jpql = "select payment from Payment payment where lower(payment.sn) = lower(:sn)"; try { return entityManager.createQuery(jpql, Payment.class).setFlushMode(FlushModeType.COMMIT) .setParameter("sn", sn).getSingleResult(); } catch (NoResultException e) { return null; } } }