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.ShippingDao; import net.groupbuy.entity.Shipping; import org.springframework.stereotype.Repository; /** * Dao - ?? * * @author SHOP++ Team * @version 3.0 */ @Repository("shippingDaoImpl") public class ShippingDaoImpl extends BaseDaoImpl<Shipping, Long> implements ShippingDao { public Shipping findBySn(String sn) { if (sn == null) { return null; } String jpql = "select shipping from Shipping shipping where lower(shipping.sn) = lower(:sn)"; try { return entityManager.createQuery(jpql, Shipping.class).setFlushMode(FlushModeType.COMMIT) .setParameter("sn", sn).getSingleResult(); } catch (NoResultException e) { return null; } } }